Hey!
I want to make abstract classes for models in models_set.py
from django.db import models
from .models import Recipe
class RecipeBaseModel(models.Model):
recipe = models.ForeignKey(
Recipe,
verbose_name='recipe',
on_delete=models.CASCADE,
)
class Meta:
abstract = True
in models.py I want to use it:
class Recipe(…)…
class AmountOfIngredient(RecipeBaseModel):
ingredient = models.ForeignKey(
Ingredient,
verbose_name='ingredient_name',
on_delete=models.CASCADE,
)
amount = models.PositiveIntegerField(
verbose_name='ingredient_amount',
validators=(
MinValueValidator(
1, message='min_is 1'),),
)
class Meta:
default_related_name = 'amount'
verbose_name = 'amounts of ingredient '
ordering = ('ingredient',)
constraints = [
models.UniqueConstraint(
fields=['ingredient', 'amount'],
name='unique_amount_ingredient'
)
]
during makemigrations have got error:
ImportError: cannot import name ‘Recipe’ from ‘recipes.models’ (/Users/pavelserdiukov/Documents/Dev/foodgram-project-react/backend/recipes/models.py)
Why? And how to fix it? Thanks.