Hi all django lovers,
I've got the problem that I want to check a model using the clean()
method on the model class. My model has a generic relationship and i
have to access the content_type property within the clean() method to
get the job done.
Now content_type is _sometimes_ defined and sometimes not, which leads
to a DoesNotExist exception.
The root of the problem seems to be in django/db/models/fields/related.py at
cache_name = self.field.get_cache_name()
try:
return getattr(instance, cache_name)
except AttributeError:
val = getattr(instance, self.field.attname)
if val is None:
# If NULL is an allowed value, return it.
if self.field.null:
return None
raise self.field.rel.to.DoesNotExist
My models properties have a _prop_cache field on instance, but
content_type does not and that raises the exception.
I cannot really reproduce the error, but I know that it has something to
do with the database, because changing or rebuilding it sometimes lead
to the problem described.
Can anyone tell me what that cache does or how it's build or how to
solve my problem in another way?
Any hint is appreciated!
Thx && have a nice day! :)
Basti
--
Bastian Ballmann / Web Developer
Notch Interactive GmbH / Badenerstrasse 571 / 8048 Zürich
Phone +41 43 818 20 91 / www.notch-interactive.com
--
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
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.