Hi,

While building a blog type application, I seem to have stumbled upon a
bug. In a nut shell all object attributes have become read only when I 
fetch the object from a query set which is fetched using the xxx_set() 
API.

Please see the pdb trace for details. I have added comments to depict
the erroneous logs. (pdb was started from within a unit test). I do 
get similar behavior when using the shell.

Any suggestions for debugging this one?

regards,
CP 

class Blog (models.Model):
    title = models.CharField (maxlength = 300, default=None)
    blog_id = models.CharField (unique=True, null=False, blank=False,
    default=None, maxlength=64)

class Post (models.Model):
    blog = models.ForeignKey (Blog)
    post_id = models.CharField (maxlength = 64, null=False, unique=True)
    title = models.CharField (maxlength = 200, null=False)

pdb logs
---------

(Pdb) blog.post_set.all()
[<Post: Blogger Post id: 6497585470310212022, title: check accidents>]
(Pdb) m = blog.post_set.all()                              
(Pdb) m[0].title
'check accidents'
(Pdb) print m[0]
Blogger Post id: 6497585470310212022, title: check accidents
(Pdb) m[0].title = "dfdf"
(Pdb) m[0].title  #NOTE: that the title does not change
'check accidents'
(Pdb) print m[0]
Blogger Post id: 6497585470310212022, title: check accidents
(Pdb) m[0].__dict__
{'blog_id': 2, 'title': 'check accidents',
'post_id': '6497585470310212022', 'id': 1}
(Pdb) m[0].__dict__["title"] = "dfdf"
(Pdb) m[0].__dict__
{'blog_id': 2, 'title': 'check accidents',
'post_id': '6497585470310212022', 'id': 1}
(Pdb) ps = Post.objects.all()
(Pdb) ps
[<Post: Blogger Post id: 6497585470310212022, title: check accidents>]
(Pdb) ps[0].title = "dfdF"
(Pdb) ps
[<Post: Blogger Post id: 6497585470310212022, title: dfdF>]
(Pdb)


python logs
-----------

>>> blog = Blog.objects.get (url__contains = "abc")
>>> m = blog.post_set.all()
>>> m[0].title
'FDfdF'
>>> m[0].title="dfdF"
>>> m[0]
<Post: Blogger Post id: 3933440231595350836, title: FDfdF>
>>> m[0].title
'FDfdF'

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to