Created
March 16, 2013 09:53
-
-
Save matthiask/5175744 to your computer and use it in GitHub Desktop.
Product admin using specifications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductAdmin(TranslationAdmin): | |
list_filter = ['is_active', 'categories', 'specification', 'upgrades'] | |
filter_horizontal = ['upgrades', 'categories', 'matching_products'] | |
form = FormWithSpecification | |
inlines = [ | |
PriceInline, | |
SpecialPriceInline, | |
EducationPriceInline, | |
ProductImageInline, | |
] | |
list_display = ('sku', '__unicode__', 'get_price') | |
prepopulated_fields = { | |
'slug': ('title',), | |
} | |
save_as = True # TODO copy specification fields when saving as new | |
def get_fieldsets(self, request, obj=None): | |
fieldsets = super(ProductAdmin, self).get_fieldsets(request, obj=obj) | |
if obj is not None and obj.specification: | |
obj.specification.update_fields(obj) # TODO redundant? | |
# TODO groups! | |
fieldsets.append((_('Specification'), { | |
'fields': [field.formfield_name() for field in | |
obj.fields.select_related('field__group')], | |
})) | |
return fieldsets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment