I'm doing a blog and the question has arisen, how can I use the Django user system to make a ForeignKey in my author variable?
from django.db import models
class Category(DatastampMixin):
name = models.CharField(max_length=20)
active = models.BooleanField(default=True)
class Meta:
verbose_name = 'Categoria'
verbose_name_plural = 'Categorias'
def __str__(self):
return self.name
class Post(DatastampMixin):
title = models.CharField(max_length=30)
content = models.TextField()
author = # ?????????
category = models.ForeignKey(Category, on_delete=models.CASCADE)