jinjie2088 / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

TagField is Not Added to __dict__ #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For some reason the tag fields is not added to the model instance __dict__ 
attribute.  

>>> from netcasts.models import Episode
>>> e = Episode.objects.get(pk=1)
>>> e.__dict__['tags']
Traceback (most recent call last):
  File "<console>", line 1, in <module>
KeyError: 'tags'
>>> e.__dict__['pub_date']
datetime.datetime(2007, 10, 16, 22, 0)
>>> 

 This makes it difficult to pass a __dict__ to a newform class for a bound form.  Instead the 
workaround is to do this:

form = EpisodeForm(dict(e.__dict__, tags=e.tags))

Original issue reported on code.google.com by mtr...@gmail.com on 30 Nov 2007 at 2:35

GoogleCodeExporter commented 9 years ago
This isn't guaranteed to even be consistent with Django any longer. I'd 
recommend using other approaches such 
as model_to_dict in django.forms.models.

Original comment by bros...@gmail.com on 22 Jan 2010 at 9:45