1

I am new to Django and i am trying to create a superuser ( i'm on Linux mint) and everytime i get a very weird error that i did not get with other Django projects. The error is the following : ( I did not modify anything in the django project besides adding my app in the installed apps list and the url of the app in urls.)

  File "/home/user/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 538, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/user/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/home/user/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/.local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/user/.local/lib/python3.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 59, in execute
    return super().execute(*args, **options)
  File "/home/user/.local/lib/python3.6/site-packages/django/core/management/base.py", line 332, in execute
    self.check()
  File "/home/user/.local/lib/python3.6/site-packages/django/core/management/base.py", line 364, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/user/.local/lib/python3.6/site-packages/django/core/management/base.py", line 351, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/user/.local/lib/python3.6/site-packages/django/core/checks/registry.py", line 73, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/user/.local/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/home/user/.local/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/home/user/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in check
    warnings.extend(check_resolver(pattern))
  File "/home/user/.local/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/home/user/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 397, in check
    for pattern in self.url_patterns:
  File "/home/user/.local/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/user/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 545, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'pleasework' from '/home/user/example.com/attempt/pleasework/__init__.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

Can you please tell me what am i doing wrong? I tried creating a virtual enivronment but it did not work.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Mary Poppins
  • 79
  • 13

2 Answers2

0

Please add more detailed code so I could try to help better, in any case, try the following -

  1. Use the --username flag instead of directly passing a username:
python manage.py createsuperuser --username yourusername
  1. Make sure you imported the model correctly in the admin.py file.
  2. Check that this row appears in the INSTALLED_APPS:
'django.contrib.admin',
  1. Try migrating the changes and then run createsuperuser.

I hope one of them solves the problem.

Netanel
  • 26
  • 1
0
  1. To check migrations, run python3 manage.py migrate.
  2. Check the row appears in <project_root>/<project>/settings.py's INSTALLED_APPS list.

Then using python3 manage.py createsuperuser should work properly. It should prompt you:

Username (leave blank to use '<user>'):
E-mail: 
Password:

where <user> is your computer's user name.