5👍
You have created a model form, but you have not told Django to use it.
You should create a model admin, and set form
to your model form:
class ProviderAdmin(admin.ModelAdmin):
form = ProviderForm
Then register your model with your model admin class:
admin.site.register(Provider, ProviderAdmin)
1👍
You should call the super() int the clean method:
def clean(self):
cleaned_data = super(ProviderForm, self).clean()
EDIT:
This is not the correct answer, @Alasdair above is. As pointed by @scharette in the comments
This is relevant only if your form inherits another that doesn’t
return a cleaned_data dictionary in its clean() method. Also, if
you’re using python 3 there is no need to have parameters
- [Django]-Django-reversion revert ManyToMany fields outside admin
- [Django]-TypeError: the first argument must be callable when I import a scheduler in my views.py file of django?
- [Django]-Django Rest Framework Serializer Model Custom Method with parameters
- [Django]-Django admin download data as csv
0👍
Considering your indentation is only an issue of posting your code, my guess is you forgot to override the admin class. Here is what you need to do:
class ProviderAdmin(admin.ModelAdmin):
form = ProviderForm
admin.site.register(Provider,ProviderAdmin)
You were on the right path you just forgot to register an override on the admin class by specifying the form with clean
override
- [Django]-Your models have changes that are not yet reflected in a migration
- [Django]-Django – Prevent automatic related table fetch