1

I have created a simple project called djangowallet and inside that project, I have created an app called wallet with a model wallet and just one field called raddress.

I have created the serializer, views and URLs and when I runserver it gives the following error.

PS C:\Users\Ahmed\djangowallet> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\runserver.py", line 124, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 438, in check
    all_issues = checks.run_checks(
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\registry.py", line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 448, in check
    for pattern in self.url_patterns:
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 634, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 627, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\Ahmed\djangowallet\djangowallet\urls.py", line 22, in <module>
    path('wallet/', include('wallet.urls'))
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\xml\etree\ElementInclude.py", line 128, in include
    _include(elem, loader, base_url, max_depth, set())
  File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python310\lib\xml\etree\ElementInclude.py", line 136, in _include
    if e.tag == XINCLUDE_INCLUDE:
AttributeError: 'str' object has no attribute 'tag'

This is my URL file in the project directory.

from xml.etree.ElementInclude import include
from django.contrib import admin
from django.urls import path

urlpatterns = [
    path('admin/', admin.site.urls),
    path('wallet/', include('wallet.urls'))
]

This is the URL file in the wallet app


from django.urls import include, path
from rest_framework import routers
from . import views

router = routers.DefaultRouter()
router.register(r'wallet', views.WalletViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
    path('', include(router.urls)),
]

1 Answer 1

1

Seems you are looking to use include..[Django-doc] so just change:

from xml.etree.ElementInclude import include

to:

from django.urls import include
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks mate, it resolved error and got the API root on 127.0.0.8000 but after clicking the root it gives the following error The 'fields' option must be a list or tuple or "__all__". Got str. TypeError at /wallet/
That seems to be a separate issue. Might be better to ask a separate question for it with the whole stack trace and the relevant code included
Thanks Brian, check this out as well stackoverflow.com/questions/71246440/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.