Answers for "create user in django"

0

create django user command line

user@hostname$ python3 -m django shell
>>> import django.contrib.auth
>>> User = django.contrib.auth.get_user_model()
>>> user = User.objects.create_user('username', password='userpassword')
>>> user.is_superuser = False
>>> user.is_staff = False
>>> user.save()
Posted by: Guest on February-20-2021
2

django admin password reset

python manage.py changepassword <user_name>
Posted by: Guest on May-11-2020
3

create super user in django

python3 manage.py createsuperuser
Posted by: Guest on April-27-2020
1

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()
Posted by: Guest on February-11-2021
-1

get user django

def sample_view(request):
    current_user = request.user
    print current_user.id
Posted by: Guest on May-22-2020
0

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)
...
Posted by: Guest on May-30-2021

Python Answers by Framework

Browse Popular Code Answers by Language