django admin save as
How to override save behaviour for Django admin?¶. ModelAdmin has a save_model method, which is used for creating and updating model objects. , 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 ).,I think you want the ModelAdmin.save_as option: class MyAdmin(admin.ModelAdmin): ... save_as = True. , You need to save the car object def save_model(self, request, obj, form, change): if obj.confirm == _('approved') : obj.car.confirm =_('approved') ...,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 ... , I had the same problem. I solved it like this : class ModelAAdmin(admin.ModelAdmin): save_as = True def save_related(self, request, form, ..., 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 ...,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.
相關軟體 Python 資訊 | |
---|---|
Python(以流行電視劇“Monty Python 的飛行馬戲團”命名)是一種年輕而且廣泛使用的面向對象編程語言,它是在 20 世紀 90 年代初期開發的,在 2000 年代得到了很大的普及,現代 Web 2.0 的運動帶來了許多靈活的在線服務的開發,這些服務都是用這種偉大的語言提供的這是非常容易學習,但功能非常強大,可用於創建緊湊,但強大的應用程序.8997423 選擇版本:Python 3.... 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 |