Opened 7 years ago

Closed 7 years ago

#6762 closed (duplicate)

TabularInline in Admin breaks when fields have default values

Reported by: ingenieroariel Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Keywords: inline, default, save, newforms-admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In the following code, everytime the save button is hit in the parent change_form it complains about empty inline model.
I guess it is because default values are assigned to some fields and it tries to save the partially empty objects.

Here is a simple example that works ok, without the default

from django.db import models
from django.contrib import admin
# Create your models here.

class Parent(models.Model):
    name=models.CharField(max_length=20)

CHOICES = (

        ('choice', 'choice'),

        ('choice1', 'choice1'),

    ) 
class Son(models.Model):
    name=models.CharField(max_length=20)
    parent=models.ForeignKey(Parent)
    choice=models.CharField(max_length=20, choices=CHOICES, default='choice')

class SonModelInline(admin.TabularInline):
    model = Son
    extra = 1

class ParentOptions(admin.ModelAdmin):
    inlines = [SonModelInline]

admin.site.register(Son)
admin.site.register(Parent, ParentOptions)

Change History (1)

comment:1 Changed 7 years ago by Karen Tracey <kmtracey@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Dup of #5878, I believe.

Note: See TracTickets for help on using tickets.
Back to Top