django user fields
# Django User Model Fields
username
first_name
last_name
email
password
groups
user_permissions
is_staff
is_active
is_superuser
last_login
date_joined
django user fields
# Django User Model Fields
username
first_name
last_name
email
password
groups
user_permissions
is_staff
is_active
is_superuser
last_login
date_joined
import abstractuser
from django.contrib.auth.models import AbstractUser
django create user
from django.contrib.auth.models import User
user = User.objects.create_user(value['USERNAME'], value['EMAIL'], value['PASSWORD'])
user.first_name = value['NAME']
user.last_name = value['SURNAME']
user.save()
Django Custom user model
...
class User(AbstractUser):
def __unicode__(self):
return self.username
balance = models.IntegerField(default=0)
total_pledged = models.IntegerField(default=0)
last_pledged = models.ForeignKey('Transaction', related_name='pledger', blank=True, null=True)
extension_key = models.CharField(max_length=100, null=True, blank=True)
plugin_key = models.CharField(max_length=100, null=True, blank=True)
ghosted = models.BooleanField(default=False)
def save(self, *args, **kwargs):
print('saving')
try:
self.company.save()
except:
print('no company')
super(User, self).save(*args, **kwargs)
...
Django Custom User Model
ChangeSwappableModel(
setting="AUTH_USER_MODEL",
old="auth.User",
new="my_auth.User"
)
Django Custom User Model
./manage.py shell
>>>
>>> from django.contrib.admin.models import LogEntry
>>> from django.contrib.contenttypes.models import ContentType
>>>
>>> auth_user = ContentType.objects.get(app_label='auth', model='user')
>>> accouts_user = ContentType.objects.get(app_label='Accounts', model='user')
>>>
>>> for le in LogEntry.objects.filter(content_type=auth_user):
... le.content_type = accouts_user
... le.save()
...
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us