Guest User

Untitled

a guest
Jun 28th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. $ python manage.py makemigrations
  2.  
  3. Migrations for 'core':
  4. core/migrations/0001_initial.py
  5. - Create model User
  6.  
  7. class Migration(migrations.Migration):
  8.  
  9. initial = True
  10.  
  11. dependencies = [
  12. ('auth', '0009_alter_user_last_name_max_length'),
  13. ]
  14.  
  15. $ python manage.py migrate
  16. Operations to perform:
  17. Apply all migrations: admin, auth, contenttypes, core, sessions
  18. Running migrations:
  19. Applying contenttypes.0001_initial... OK
  20. Applying contenttypes.0002_remove_content_type_name... OK
  21. Applying auth.0001_initial... OK
  22. Applying auth.0002_alter_permission_name_max_length... OK
  23. Applying auth.0003_alter_user_email_max_length... OK
  24. Applying auth.0004_alter_user_username_opts... OK
  25. Applying auth.0005_alter_user_last_login_null... OK
  26. Applying auth.0006_require_contenttypes_0002... OK
  27. Applying auth.0007_alter_validators_add_error_messages... OK
  28. Applying auth.0008_alter_user_username_max_length... OK
  29. Applying auth.0009_alter_user_last_name_max_length... OK
  30. Applying core.0001_initial... OK
  31. Applying admin.0001_initial... OK
  32. Applying admin.0002_logentry_remove_auto_add... OK
  33. Applying sessions.0001_initial... OK
  34.  
  35. class Migration(migrations.Migration):
  36.  
  37. initial = True
  38.  
  39. dependencies = [
  40. migrations.swappable_dependency(settings.AUTH_USER_MODEL),
  41. ]
  42.  
  43. class UserManager(BaseUserManager):
  44. def create_user(self, email, password=None):
  45. if not email:
  46. raise ValueError('Email not defined.')
  47.  
  48. user = self.model(email=self.normalize_email(email))
  49.  
  50. user.set_password(password)
  51. user.save(using=self._db)
  52. return user
  53.  
  54. def create_superuser(self, email, password):
  55. user = self.create_user(
  56. email,
  57. password=password,
  58. )
  59. user.is_staff = True
  60. user.save(using=self._db)
  61. return user
  62.  
  63.  
  64. class User(AbstractBaseUser, PermissionsMixin):
  65. email = models.EmailField(unique=True)
  66. created_at = models.DateTimeField(auto_now_add=True)
  67. is_staff = models.BooleanField(default=False)
  68. is_active = models.BooleanField(default=True)
  69.  
  70. EMAIL_FIELD = 'email'
  71. USERNAME_FIELD = 'email'
  72.  
  73. objects = UserManager()
  74.  
  75. def __str__(self):
  76. return self.email
  77.  
  78. def has_perm(self, perm, obj=None):
  79. return True
  80.  
  81. def has_module_perms(self, app_label):
  82. return True
Add Comment
Please, Sign In to add comment