Я устанавливаю простое веб-приложение на Python. Пример взят из https://www.codementor.io/rogargon/simple-django-web-application-tutorial-du107rmn4. Почему код нарушается?
Я попытался добавить следующий код: из django.contrib.contenttypes.fields import GenericForeignKey && из django.contrib.contenttypes.models import ContentType
class Review(models.Model):
RATING_CHOICES = ((1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'), (5, 'five'))
rating = models.PositiveSmallIntegerField('Rating (stars)', blank=False, default=3, choices=RATING_CHOICES)
comment = models.TextField(blank=True, null=True)
user = models.ForeignKey(User, default=1, on_delete=models.CASCADE)
date = models.DateField(default=date.today)
class Meta:
abstract = True
class ShopReview(Review):
restaurant = models.ForeignKey(ShopInfo, on_delete=models.CASCADE)
class Article(models.Model):
category = models.ForeignKey('Category', on_delete=models.CASCADE)
title = models.CharField(max_length=55)
# ...
def __str__(self):
return self.title