Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ python3 manage.py createsuperuser username=Admin
- System check identified some issues:
- WARNINGS:
- ?: (urls.W001) Your URL pattern '^$' uses include with a regex ending with a '$'. Remove the dollar from the regex to avoid problems including URLs.
- Email address: admin@example.com
- Password:
- Password (again):
- Traceback (most recent call last):
- File "manage.py", line 22, in <module>
- execute_from_command_line(sys.argv)
- File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
- utility.execute()
- File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 355, in execute
- self.fetch_command(subcommand).run_from_argv(self.argv)
- File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 283, in run_from_argv
- self.execute(*args, **cmd_options)
- File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 63, in execute
- return super(Command, self).execute(*args, **options)
- File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 330, in execute
- output = self.handle(*args, **options)
- File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 183, in handle
- self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
- File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/models.py", line 170, in create_superuser
- return self._create_user(username, email, password, **extra_fields)
- File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/models.py", line 153, in _create_user
- user.save(using=self._db)
- File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/base_user.py", line 80, in save
- super(AbstractBaseUser, self).save(*args, **kwargs)
- File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 807, in save
- force_update=force_update, update_fields=update_fields)
- File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 834, in save_base
- with transaction.atomic(using=using, savepoint=False):
- File "/usr/local/lib/python3.5/dist-packages/django/db/transaction.py", line 158, in __enter__
- if not connection.get_autocommit():
- File "/usr/local/lib/python3.5/dist-packages/django/db/backends/base/base.py", line 385, in get_autocommit
- self.ensure_connection()
- File "/usr/local/lib/python3.5/dist-packages/django/db/backends/dummy/base.py", line 20, in complain
- raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
- django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
- DATABASES = {
- 'default': {
- 'ENGINE' : 'django.db.backends.dummy',
- 'NAME' : 'my_database'
- },
- 'users': {
- 'NAME': 'nra_gpb_users',
- 'ENGINE': 'django.db.backends.mysql',
- 'USER': 'django'
- }
- }
- class AuthRouter(object):
- """
- A router to control all database operations on models in the
- auth application.
- """
- def db_for_read(model, **hints):
- """
- Attempts to read auth models go to auth_db.
- """
- if model._meta.app_label == 'auth':
- return 'users'
- return 'default'
- def db_for_write(model, **hints):
- """
- Attempts to write auth models go to auth_db.
- """
- print(model._meta.app_label)
- if model._meta.app_label == 'auth':
- return 'users'
- return 'default'
- def allow_relation(obj1, obj2, **hints):
- """
- Allow relations if a model in the auth app is involved.
- """
- return False
- def allow_migrate(db, app_label, model_name=None, **hints):
- """
- Make sure the auth app only appears in the 'auth_db'
- database.
- """
- return db == 'auth_db'
- DATABASE_ROUTERS = [AuthRouter]
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import django
- >>> django.setup()
- >>> from django.contrib.auth.models import User
- >>> user = User.objects.create_user('Admin', 'admin@example.com', 'password')
- >>> user.save()
- >>> exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement