Answer the question
In order to leave comments, you need to log in
Django ModelAdmin save_formset how to get saved changes?
Good afternoon!
I can not cope with a fairly simple task for a day.
The bottom line is, in the admin interface in the edit form I have an associated object with the parent ( TabularInline )
#-*- coding: utf-8 -*-
from django.contrib import admin
from core.models import Model, Field
import os
from django.conf import settings
from django import forms
class FieldAdminForm(forms.ModelForm):
class Meta:
model = Field
class FieldInline(admin.TabularInline):
model = Field
form = FieldAdminForm
extra = 1
class ModelAdmin(admin.ModelAdmin):
inlines = (FieldInline,)
def save_formset(self, request, form, formset, change):
super(ModelAdmin, self).save_formset(request, form, formset, change)
model = Model.objects.get(app__name='AppName', name=request.POST['name'])
admin.site.register(Model, ModelAdmin)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question