>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('john', 'lennon@thebeatles.com', '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()
from django.contrib.auth import get_user_model
User = get_user_model()
from django.contrib.auth import get_user_model
User = get_user_model()
from turtle import title
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.db import models
# Create your models here.
class Post(models.Model):
Title = models.CharField(max_length=200)
Text = models.TextField()
Author = get_user_model()
Created_date = models.DateTimeField(max_digits=None, decimal_places=None)
Published_date = models.DateTimeField(max_digits=None, decimal_places=None)
author = models.ForeignKey(settings.AUTH_USER_MODEL)
author = models.ForeignKey(settings.AUTH_USER_MODEL)
author = models.ForeignKey(settings.AUTH_USER_MODEL)