Am 28.08.2012 um 00:13 schrieb Melvyn Sopacua:
>>
>> Another question: How can I expand the right fieldset dependent of
>> current content of my choices field (as loaded from db) while
>> rendering the change page initially?
>
> Look in django/contrib/admin/options.py for get_fieldsets(). Also look
> at this bugreport for it's limitations:
> <https://code.djangoproject.com/ticket/18681>
>
> Short version: the method as it is implemented requires that you have at
> least some declared fieldsets.
>
> In case you're also new to python, you should convert your declared
> fieldsets from a tuple to a list, so it's easier to modify it.
This method belongs to InlineModelAdmin.
I never worked with Inlines before. It seems, they work only with parent-
child situations (as documented). Unfortunately my form deals only with one
model.
Trying this:
---
class MailboxInline(InlineModelAdmin):
model = Mailbox
def get_fieldsets(self, request, obj=None):
t = 2
if self.type == 'M':
t = 1
return [self.declared_fieldsets[0], self.declared_fieldsets[t], self.declared_fieldsets[3]]
class MailboxAdmin(admin.ModelAdmin):
list_display = ('localpart', 'localdomainfk', 'type', 'aliastargetaddresses', 'created', 'updated')
fieldsets = [
(None, {
'fields': (('localpart', 'localdomainfk'), 'accountfk', 'lifetime', 'type')
}),
(_('Mailbox'), {
##'classes': ('collapse',),
'fields': ('aoxuserid', 'quota')
}),
(_('Alias'), {
##'classes': ('collapse',),
'fields': ('aliastargetaddresses',)
}),
(None, {
'fields': ('remarks',)
})
]
inlines = [MailboxInline]
---
Raises: <class 'erdb.models.Mailbox'> has no ForeignKey to <class 'erdb.models.Mailbox'>
Any chance to get around this?
Axel
---
PGP-Key:29E99DD6 ☀ +49 151 2300 9283 ☀ computing @ chaos claudius
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment