Re: Generic Relations and Django Admin?

2010-01-20 Thread Victor Hooi
heya, Hmm, I'm using generic.GenericTabularInline for the Address Inline, is that the same? class AddressAdmin(VersionAdmin): exclude = ('content_type', 'object_id',) ... class AddressInline(generic.GenericTabularInline): model = Address ... class HospitalAdmin(admin.ModelAdmin):

Re: Generic Relations and Django Admin?

2010-01-20 Thread Victor Hooi
heya, The thing is, it's a one-to-many for UserProfile/Hospital/Institution to Addresses - that is, each entity can (and probably will) have multiple addresses. That's why the FK field is on Address. Also, I thought that was the way it was traditionally modelled in database design? (I admit I'm

Re: Generic Relations and Django Admin?

2010-01-19 Thread LostCruz
Hi Victor, You are trying to do this the wrong way around. It shouldn't be the Adress class on which you want to define a relationship, but on the other classes. An address is an address whether it's the address of a User or the address of an Institution. class Address(models.Model): # the

Re: Generic Relations and Django Admin?

2010-01-19 Thread Daniel Roseman
On Jan 19, 10:35 am, Victor Hooi wrote: > heya, > > Thanks for the reply =). > > I tried that, and the fields aren't there, but when I try to save the > object, I get a: > >     IntegrityError at /admin/people/address/add/ >     people_address.content_type_id may not be NULL

Re: Generic Relations and Django Admin?

2010-01-19 Thread Raffaele Salmaso
Victor Hooi wrote: > I tried that, and the fields aren't there, but when I try to save the > object, I get a: > > IntegrityError at /admin/people/address/add/ > people_address.content_type_id may not be NULL > > so obvoiusly Django doesn't like it if those fields aren't filled. it's a

Re: Generic Relations and Django Admin?

2010-01-19 Thread Victor Hooi
heya, Thanks for the reply =). I tried that, and the fields aren't there, but when I try to save the object, I get a: IntegrityError at /admin/people/address/add/ people_address.content_type_id may not be NULL so obvoiusly Django doesn't like it if those fields aren't filled. How do

Re: Generic Relations and Django Admin?

2010-01-19 Thread Victor Hooi
heya, The thing is, the foreign key field is on the Address object, linking to another object that *has* an address. AFAIK, that's how it's meant to be in database design. That's why I need to put something there - e.g. class Address(models.Model): ... user =

Re: Generic Relations and Django Admin?

2010-01-18 Thread greatlemer
On Jan 19, 5:25 am, Victor Hooi wrote: > heya, > > I'm trying to use an "Address" model as a generic relation against > multiple other models (e.g. in a "User Profile", for each User, as > well as for "Building", "Institution", and various other ones). > > So I've added the

Re: Generic Relations and Django Admin?

2010-01-18 Thread Raffaele Salmaso
Victor Hooi wrote: > class AddressAdmin(VersionAdmin): > pass > class AddressInline(generic.GenericTabularInline): > model = Address > ... fields = (the fields you want to display) or exclude = ('content_type', 'object_id',) > class HospitalAdmin(admin.ModelAdmin): >

Generic Relations and Django Admin?

2010-01-18 Thread Victor Hooi
heya, I'm trying to use an "Address" model as a generic relation against multiple other models (e.g. in a "User Profile", for each User, as well as for "Building", "Institution", and various other ones). So I've added the content_type, object_id and content_object fields to Address. class