Answer the question
In order to leave comments, you need to log in
Adding multiple categories to one item?
There is a code, how can I do this?
THE CODE:
from django.db import models
# Create your models here.
class Category(models.Model):
name_of_category = models.CharField(max_length=200)
def __str__(self):
return self.name_of_category
class Good(models.Model):
category = models.ForeignKey(Category, on_delete=models.CASCADE)
name = models.CharField(max_length=200)
description = models.CharField(max_length=200)
date_of_relise = models.DateField('Relise')
price = models.FloatField(default=0)
def __str__(self):
return self.name, self.description
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