Django + Mongo + djongo. Trouble with adding new models with ForeignKey

46 Views Asked by At

i use django + mongo with djongo. I have 2 models: Deck and Card;

class Deck(models.Model):
deckName = models.TextField(max_length=100)
deckDetail = models.TextField(max_length=1400)

class Card(models.Model):
cardName = models.TextField(max_length=100)
cardDetail = models.TextField(max_length=1400)
deckCard = models.ForeignKey(Deck, on_delete=models.CASCADE)
dailyCard = models.BooleanField(default=False, unique=True)

when i add new Deck model with http://127.0.0.1:8000/admin/app/deck/add/ (django admin standart) it's ok. But when i add new Card model i have "Exception Type: DatabaseError at /admin/app/card/add/ Exception Value: " ;

in py manage.py shell i create 2 new models (card, deck) and it's ok! I think the point is that when saving the Card, the string (id) is passed to the deck field, but do you need int? Or something like that? Do I really have to make my own admin page and override the methods for saving models there?

0

There are 0 best solutions below