Ticket #24539: admin.py
File admin.py, 426 bytes (added by , 10 years ago) |
---|
Line | |
---|---|
1 | from django.contrib import admin |
2 | from django.forms.models import modelform_factory |
3 | |
4 | from .models import Product |
5 | |
6 | |
7 | @admin.register(Product) |
8 | class ProductAdmin(admin.ModelAdmin): |
9 | |
10 | def get_form(self, *args, **kwargs): |
11 | class ProductForm(modelform_factory(Product, fields=['reference'])): |
12 | |
13 | def clean(self): |
14 | # Implement some custom validation |
15 | pass |
16 | |
17 | return ProductForm |