“importar usuário em django” Respostas de código

importar usuário em django

>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('john', '[email protected]', 'johnpassword')

# At this point, user is a User object that has already been saved
# to the database. You can continue to change its attributes
# if you want to change other fields.
>>> user.last_name = 'Lennon'
>>> user.save()
Clever Crocodile

Importar Get User Model Django

from django.contrib.auth import get_user_model
User = get_user_model()
Panicky Pintail

LoginRequiredMixin

from django.contrib.auth.mixins import LoginRequiredMixin

LOGIN_URL = 'your_url'
Virgin Programmer

Obtenha o usuário django

def sample_view(request):
    current_user = request.user
    print current_user.id
Awful Alpaca

LoginRequiredMixin Django

from django.contrib.auth.mixins import LoginRequiredMixin

class MyView(LoginRequiredMixin, View):
    login_url = '/login/'
    redirect_field_name = 'redirect_to'
Fragile Fox

Respostas semelhantes a “importar usuário em django”

Perguntas semelhantes a “importar usuário em django”

Mais respostas relacionadas para “importar usuário em django” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código