heya,
I have an address object, which is setup as a generic relation.
class Address(models.Model):
street_address = models.CharField(max_length=50)
... (etc.)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
It's used in a few places, such as by UserProfile, in a Department
object, and elsewhere. Each of those has a GenericRelation back to
Address.
In the admin.py, I've tried to setup Generic Inlines, to edit the
Address for each Department.
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from people.models import UserProfile, Department, Address
from django.contrib.contenttypes import generic
class UserProfileInline(admin.StackedInline):
model = UserProfile
class UserAdmin(UserAdmin):
inlines = [UserProfileInline]
class AddressInline(generic.GenericTabularInline):
models = Address
class DepartmentAdmin(admin.ModelAdmin):
inlines = [
AddressInline
]
However, when I add in the inline code for Addresses, I get an error
message such as this:
AttributeError at /admin/
type object 'AddressInline' has no attribute 'date_hierarchy'
or:
ImproperlyConfigured at /admin/
'model' is a required attribute of 'DepartmentAdmin.inlines[0]'.
But then, if I hit refresh in the browser, the Admin interface
displays, albeit with the Department and Address sections missing.
There aren't any error messages on the console.
What's the proper way to setup generic inlines in the admin? Am I
doing something wrong in the above?
Also, I noticed that when I add a Department, next to a field that has
a FK to a user, there's a little green cross to add a new user. Is it
possible to have something setup for other FK fields, including
generic ones?
Cheers,
Victor
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.