Answer the question
In order to leave comments, you need to log in
How to define a relationship object for a model in django?
There are two models:
from django.db import models
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, null=True, blank=True)
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