2
I’m blogging and the question arose, has how to use the user system of Django 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)