Rudolph wrote:
> With meta.ForeignKey("self") you can create an object that can refer to
> objects from the same type. But how do I prevent loops? (like an object
> that refers to itself, or object A refers to object B which refers back
> to object A). With limit_choices_to I could prevent an object from
> selecting itself, but how do I prevent bigger loops?
The easiest way to iterate through and find a loop during the save()
call of the object. (Using _pre_save() for pre-magic-removal code.)
An example is provided in this cookbook entry:
http://code.djangoproject.com/wiki/CookBookCategoryDataModel
-
--Max Battcher--
http://www.worldmaker.net/
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---