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):
inli
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 o
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 fi
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
>
> so obvoiusly Djang
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 bug
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 pe
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 = models.ForeignKey(UserProfi
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 content_type, object_id
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):
> inline
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 Addres
10 matches
Mail list logo