python - Why is save not working in Django? -
i'm using manage.py shell
, run this:
>>>d=document.objects.get(pk=1)
>>>d.scores
{1:0,2:0,3:0}
>>>d.scores[1]=5
>>>d.scores
{1:5,2:0,3:0}
>>>d.save()
but viewing d
in database reveals hasn't been updated. doing wrong?? checked out what's here, d
document
instance.
if helps, model.py looks this:
from django.db import models
class document(models.model):
filename=models.charfield(max_length=200)
fileurl=models.charfield(max_length=200)
scores={1:0,2:0,3:0}
your 'scores' class variable isn't instance of of django's *field classes. imagine 'scores' field isn't on table in db, since field classes defines of that, , gets saved db, among other things.
Comments
Post a Comment