Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. $ python3 manage.py createsuperuser username=Admin
  2. System check identified some issues:
  3.  
  4. WARNINGS:
  5. ?: (urls.W001) Your URL pattern '^$' uses include with a regex ending with a '$'. Remove the dollar from the regex to avoid problems including URLs.
  6. Email address: admin@example.com
  7. Password:
  8. Password (again):
  9. Traceback (most recent call last):
  10. File "manage.py", line 22, in <module>
  11. execute_from_command_line(sys.argv)
  12. File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
  13. utility.execute()
  14. File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 355, in execute
  15. self.fetch_command(subcommand).run_from_argv(self.argv)
  16. File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 283, in run_from_argv
  17. self.execute(*args, **cmd_options)
  18. File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 63, in execute
  19. return super(Command, self).execute(*args, **options)
  20. File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 330, in execute
  21. output = self.handle(*args, **options)
  22. File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 183, in handle
  23. self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
  24. File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/models.py", line 170, in create_superuser
  25. return self._create_user(username, email, password, **extra_fields)
  26. File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/models.py", line 153, in _create_user
  27. user.save(using=self._db)
  28. File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/base_user.py", line 80, in save
  29. super(AbstractBaseUser, self).save(*args, **kwargs)
  30. File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 807, in save
  31. force_update=force_update, update_fields=update_fields)
  32. File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 834, in save_base
  33. with transaction.atomic(using=using, savepoint=False):
  34. File "/usr/local/lib/python3.5/dist-packages/django/db/transaction.py", line 158, in __enter__
  35. if not connection.get_autocommit():
  36. File "/usr/local/lib/python3.5/dist-packages/django/db/backends/base/base.py", line 385, in get_autocommit
  37. self.ensure_connection()
  38. File "/usr/local/lib/python3.5/dist-packages/django/db/backends/dummy/base.py", line 20, in complain
  39. raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
  40. django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
  41.  
  42. DATABASES = {
  43. 'default': {
  44. 'ENGINE' : 'django.db.backends.dummy',
  45. 'NAME' : 'my_database'
  46. },
  47. 'users': {
  48. 'NAME': 'nra_gpb_users',
  49. 'ENGINE': 'django.db.backends.mysql',
  50. 'USER': 'django'
  51. }
  52. }
  53. class AuthRouter(object):
  54. """
  55. A router to control all database operations on models in the
  56. auth application.
  57. """
  58. def db_for_read(model, **hints):
  59. """
  60. Attempts to read auth models go to auth_db.
  61. """
  62. if model._meta.app_label == 'auth':
  63. return 'users'
  64. return 'default'
  65.  
  66. def db_for_write(model, **hints):
  67. """
  68. Attempts to write auth models go to auth_db.
  69. """
  70. print(model._meta.app_label)
  71. if model._meta.app_label == 'auth':
  72. return 'users'
  73. return 'default'
  74.  
  75. def allow_relation(obj1, obj2, **hints):
  76. """
  77. Allow relations if a model in the auth app is involved.
  78. """
  79. return False
  80.  
  81. def allow_migrate(db, app_label, model_name=None, **hints):
  82. """
  83. Make sure the auth app only appears in the 'auth_db'
  84. database.
  85. """
  86. return db == 'auth_db'
  87. DATABASE_ROUTERS = [AuthRouter]
  88.  
  89. Type "help", "copyright", "credits" or "license" for more information.
  90. >>> import django
  91. >>> django.setup()
  92. >>> from django.contrib.auth.models import User
  93. >>> user = User.objects.create_user('Admin', 'admin@example.com', 'password')
  94. >>> user.save()
  95. >>> exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement