There's a way to do what you want to do, but I don't remember out of the top of my head. I can check it out on the week, but you'll need to customize some things on the Producer's ModelAdmin, not just set the list of inlines, because, as it was said, inlines are for "children" objects (i.e. other objects that have a FK pointing to self, not the other way around).
I don't remember exactly, but IIRC it went about making a single-form inline_formset and possibly some modifying of the model-specific admin template. Or maybe making a custom ModelForm in the ModelAdmin's get_form method On Sun, Feb 17, 2013 at 3:14 PM, Peter of the Norse <[email protected]> wrote: > Have you tried using unique_together? You could add unique_together = ( > ('type', 'producer',), ) to your Address model. There really isn't any way > for the default admin to edit a second table at the same time. > > https://docs.djangoproject.com/en/1.4/ref/models/options/#unique-together > > On Feb 14, 2013, at 8:42 AM, Ray Hatfield wrote: > >> Thanks, but I've omitted related_name and I've used distinct related_names >> and gotten the same errors. I don't want to reuse addresses. The one-to-one >> relationship you describe is precisely what I'm trying to do. >> >> On Feb 14, 2013, at 1:32 AM, Jani Tiainen <[email protected]> wrote: >> >>> Hi, >>> >>> You're trying to setup one-to-one relationship. >>> >>> It means that producer.mailing_address does have exactly one unique Address >>> entity. Same goes for physical_address. >>> >>> What you want is really ForeignKey to address which means that you reuse >>> addresses to multiple producer.mailing_address. >>> >>> Then you can omit related names, or like someone suggested use different >>> related names for both fields. >>> >>> 13.2.2013 21:25, Ray Hatfield kirjoitti: >>>> Hi, >>>> >>>> I have a model which requires two addresses: a mailing address and a >>>> physical address. From an OO perspective it makes sense to have an >>>> Address class and the Producer to have Address instances as properties, >>>> but I can't seem to achieve this in django while still being able to >>>> edit the addresses inline as part of the Producer admin. >>>> >>>> I've tried this sort of thing: >>>> >>>> class Address( models.Model ): >>>> street = models.CharField( ... ) >>>> # city state zip, etc. >>>> >>>> class Producer( models.Model ): >>>> mailing_address = models.OneToOneField( Address, related_name='+' ) >>>> physical_address = models.OneToOneField( Address, related_name='+' ) >>>> >>>> but when I attempt to inline the addresses in the django admin I run >>>> into trouble. I get errors like: >>>> >>>> <class 'producers.models.Address'> has no ForeignKey to <class >>>> 'producers.models.Producer'> >>>> >>>> (This error is true, of course. But I was under the apparently erroneous >>>> impression that including related_name='+' would prevent django from >>>> setting up the reverse relationship.) >>>> >>>> I realize I could add a foreign key to Address to associate it with a >>>> specific Producer but this feels backwards to me. An Address shouldn't >>>> need to know whether it's for a Producer or some other object. It's just >>>> an address. >>>> >>>> I've been banging my head on this for far too long. Advice? >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at http://groups.google.com/group/django-users?hl=en. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>> >>> >>> -- >>> Jani Tiainen >>> >>> - Well planned is half done and a half done has been sufficient before... >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/django-users?hl=en. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/django-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > Peter of the Norse > [email protected] > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.

