Answer the question
In order to leave comments, you need to log in
Why is there a django.db.utils.IntegrityError migration error?
I have 3 models:
from django.db import models
from django.db.models import AutoField, DateField, CharField, ForeignKey, DecimalField, TextField
class Marks(models.Model):
id = AutoField(primary_key=True)
name = CharField(max_length=150)
objects = models.Manager()
class Cats(models.Model):
id = AutoField(primary_key=True)
name = CharField(max_length=150)
location = CharField(max_length=150, default=None, null=True, blank=True)
objects = models.Manager()
class Items(models.Model):
id = AutoField(primary_key=True)
name = CharField(max_length=150)
marks = ForeignKey(Marks, on_delete=models.DO_NOTHING)
category = ForeignKey("Cats", on_delete=models.DO_NOTHING)
price = DecimalField(max_digits=7, decimal_places=2)
previous_price = DecimalField(max_digits=7, decimal_places=2)
article_number = CharField(max_length=150)
description = TextField()
picture = CharField(max_length=500)
objects = models.Manager()
class ItemsForm(ModelForm):
class Meta:
model = Items
fields = ['name', 'marks', 'category', 'picture', 'article_number', 'price', 'previous_price']
Answer the question
In order to leave comments, you need to log in
Why is default=None here?
location = CharField(max_length=150, default=None, null=True, blank=True)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question