django - When I try to add a deck of cards to my database i get: Integrity error decks_deck.cardID_id may not be NULL. What am I doing wrong? -
i made models this:
from django.db import models class attribute(models.model): idattr= models.charfield(primary_key=true, max_length=40) description= models.charfield(max_length=40) def __str__(self): return self.description class cardtype(models.model): idcardtype= models.charfield(primary_key=true, max_length=40) description= models.charfield(max_length=40) def __str__(self): return self.description class monstertype(models.model): idmonstertype= models.charfield(primary_key=true, max_length=40) description= models.charfield(max_length=40) def __str__(self): return self.description class cardclass(models.model): idcardclass= models.charfield(primary_key=true, max_length=40) description= models.charfield(max_length=40) def __str__(self): return self.description class card(models.model): idcard= models.charfield(primary_key=true, max_length=40) name= models.charfield(max_length=40) description= models.charfield(max_length=100) attrid= models.foreignkey(attribute) cardtypeid= models.foreignkey(cardtype, null=true, blank=true) monstertypeid= models.foreignkey(monstertype, null=true, blank=true) cardclassid= models.foreignkey(cardclass) def __str__(self): return self.name class deck(models.model): iddeck= models.charfield(primary_key=true, max_length=40) name= models.charfield(max_length=40) cardid= models.manytomanyfield(card) def __str__(self): return self.name
however when fill in required fields in database error cardid saying may not null.
the card class used add cards , deck should show list of added cards throught cardid field, does. fill in other fields , select cards want add deck. after clicking save error mentioned above.
i've read various posts on site , read djago documentation, haven't been able solve it. appreciate get.
can use this
id = models.autofield(primary_key=true)
Comments
Post a Comment