9👍
You can raise whatever exception you want within the pre_save
listener function, it will propagate to your save()
call and prevent it from suceeding.
It will bubble up to where you call save()
, from here, you can catch it (try/except…) and notify the user.
0👍
I guess you should either use Model.clean() method (http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#django.db.models.Model.clean) or form clean http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-clean-method.
- Could not import 'oauth2_provider.ext.rest_framework.OAuth2Authentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'
- Add extra field to ModelForm
- Admin panel recent actions
- Difference between ViewSet and GenericViewSet in Django rest framework
Source:stackexchange.com