django admin save as
I've managed to find some workaround: I've overridden the original admin form (see here) to get it also include the old Model's ID in "save as ..., Besides adding button in change_form template, you would want to override response_change method of ModelAdmin (and response_add ).
相關軟體 Python 資訊 | |
---|---|
![]() django admin save as 相關參考資料
3. How to override save behaviour for Django admin ...
How to override save behaviour for Django admin?¶. ModelAdmin has a save_model method, which is used for creating and updating model objects. https://books.agiliq.com Django "Save as new" and keep Image fields - Stack Overflow
I've managed to find some workaround: I've overridden the original admin form (see here) to get it also include the old Model's ID in "save as ... https://stackoverflow.com Django admin "save and view on site" button - Stack Overflow
Besides adding button in change_form template, you would want to override response_change method of ModelAdmin (and response_add ). https://stackoverflow.com Django Admin Save and add another preselected fields - Stack Overflow
I think you want the ModelAdmin.save_as option: class MyAdmin(admin.ModelAdmin): ... save_as = True. https://stackoverflow.com django admin save override - Stack Overflow
You need to save the car object def save_model(self, request, obj, form, change): if obj.confirm == _('approved') : obj.car.confirm =_('approved') ... https://stackoverflow.com Django admin site modify save - Stack Overflow
The save() method is supposed to return the object, whether saved or not. It should rather look like: def save(self, commit=True): input_name ... https://stackoverflow.com Django Admin: "Save as New" ignores GenericForeignKey - Stack Overflow
I had the same problem. I solved it like this : class ModelAAdmin(admin.ModelAdmin): save_as = True def save_related(self, request, form, ... https://stackoverflow.com Override save method of Django Admin - Stack Overflow
You shouldn't be doing any kind of validation at all in the save method, models have a clean method so any validation you wish to do should be ... https://stackoverflow.com The Django admin site | Django documentation | Django
from django.contrib import admin from myproject.myapp.models import Author class ... Set save_as to enable a “save as new” feature on admin change forms. https://docs.djangoproject.com |