Home:ALL Converter>Override a form in Django admin

Override a form in Django admin

Ask Time:2012-04-06T15:23:19         Author:18bytes

Json Formatter

In Django admin I want to override and implement my own form for a model (e.g. Invoice model).

I want the invoice form to have auto-fill fields for customer name, product name and I also want to do custom validation (such as credit limit for a customer). How can I override the default form provided by Django admin and implement my own?

I am new to Django, I appreciate any pointers.

Author:18bytes,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/10040442/override-a-form-in-django-admin
fest :

You can override forms for django's built-in admin by setting form attribute of ModelAdmin to your own form class. See: \n\n\nhttps://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form\nhttps://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin\n\n\nIt's also possible to override form template - have a look at https://docs.djangoproject.com/en/dev/ref/contrib/admin/#custom-template-options\n\nIf you're looking specifically for autocomplete I can recommend https://github.com/crucialfelix/django-ajax-selects",
2012-04-06T09:16:10
yy