Answer the question
In order to leave comments, you need to log in
How to make an optional foreignkey association in django?
There is an Item model, which, if desired , can suddenly start referring to the Category_item model (many-to-one relationship, if I'm not mistaken),
models.py:
class Category_item(models.Model):
name_category = models.CharField('Название категории', max_length=100)
class Item(models.Model):
name = models.CharField('Название пункта', max_length=100)
description = models.TextField('Описание пункта')
Category_item = models.ForeignKey(Category_item, on_delete=models.CASCADE)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question