java
html
css
ajax
python
database
linux
xcode
ruby-on-rails
regex
objective-c
eclipse
silverlight
html5
perl
algorithm
facebook
cocoa
tsql
jsp
Another way to achieve this without having to fully redefine the field would be:
class MySub1(MySuper): pass MySub1._meta.get_field('some_attr').help_text = 'sub1 help text' class MySub2(MySuper): pass MySub2._meta.get_field('some_attr').help_text = 'sub2 help text'
I needed to do this for two identical models that have different image sizes. There's probably some brilliant way to generalise this, but for two items my answer will do fine. First create a file called forms.py in your app.
from django import forms from .models import FeaturedProduct, ShopProduct class FeaturedProductForm(forms.ModelForm): class Meta: model = FeaturedProduct ihelp = "Image should be 500x220." src = forms.ImageField(help_text=ihelp,required=False) class ShopProductForm(forms.ModelForm): class Meta: model = FeaturedProduct ihelp = "Image should be 100x100." src = forms.ImageField(help_text=ihelp,required=False)
Note that required defaults to true, even if you have null=True, blank=True on your models. Then in admin.py define your ModelAdmins as follows:
required
null=True, blank=True
ModelAdmin
from .forms import FeaturedProductForm, ShopProductForm class ShopProductAdmin(admin.ModelAdmin): form = ShopProductForm class FeaturedProductAdmin(admin.ModelAdmin): form = FeaturedProductForm
I left out a few imports and the whole admin.site.register nonsense. Let me know if you need any more info. The complete list of forms.FIELDS can be found here:
admin.site.register
forms.FIELDS
https://docs.djangoproject.com/en/dev/ref/forms/fields/