well, u can add multiple FK relations to your model e.g.:

company = models.ForeignKey(Company, blank=True, null=True)
other_model = models.ForeignKey(OtherModel, blank=True, null=True)

And then in form you just define clean method which will ensure that
one and only one FK relation will be created. And as for admin
interface, just override clean method and save function (not
necessary, clean will prevent to save if it fails).

Or maybe it's possible to define it in Meta class of your model (don't
know, never tried it)

Radovan


On 26. Okt, 18:21 h., pixelcowboy <pixelcowbo...@gmail.com> wrote:
> I have a question regarding the best way to conceptualize a model. I
> have a tasks model, which I want to hook to a few different other
> models: The model Project, the model Company and a few other undefined
> models. The problem is that I want a particular instance of the task
> to be pluggable to one and only one of those models, which I dont know
> how I would achieve using 2 or more separate foreign keys. The only
> idea I have is to use generic relationships, and unique them. Any
> ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to