Admin fields with abstract classes

55 views
Skip to first unread message

tom

unread,
Jul 4, 2008, 2:31:00 AM7/4/08
to Django users
Hi,

I have an abstract class for some generic information about contact
information and need to have those fields in a number of other Models.
Therefore I defined the Contact Model as abstract:

class Contact(models.Model):
"""
Meta class for all models which needs to have contacts stored
"""
first_name = models.CharField(max_length = 30, blank = True)
last_name = models.CharField(max_length = 30, blank = True)
street = models.CharField(max_length = 30, blank = True)
zip = models.SmallIntegerField(blank = True)
address = models.CharField(max_length = 30, blank = True)

# Phone Stuff
mobile = models.PhoneNumberField(blank = True)
landline = models.PhoneNumberField(blank = True)
fax = models.PhoneNumberField(blank = True)

class Meta:
abstract = True

class Admin:
fields = (
(None, {'fields': ((' first_name', 'last_name'),)}),
('Address', {'fields': ('street', 'zip', 'address')}),
('Phone and Fax', {'classes': 'collapse',
'fields': ('mobile', 'landline',
'fax')}),
)
js = ('/m/js/tiny_mce/tiny_mce.js',
'/m/js/tiny_mce/textareas.js')

what's important for me is, that I need to group some fields within
the admin interface to make it "pretty" for editors. But when I use it
the way it is listed further up, it simply does not show up as
expected.

When I add the Admin stuff in the SubClass django throws an error,
because the fields are unknown.

Is there a way around it?

Many thanks and best regards,
Tom
Reply all
Reply to author
Forward
0 new messages