#14095: Objects not saved when readonly_fields is set for inline admin
----------------------------------------------------+-----------------------
Reporter: [email protected] | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: 1.2
Keywords: TabularInline, inline, readonly_fields | Stage: Unreviewed
Has_patch: 0 |
----------------------------------------------------+-----------------------
= Code =
'''models.py:'''
{{{
class BalanceCode(models.Model):
created_at = models.DateField(auto_now_add=True)
code = models.CharField(max_length=BALANCE_CODE_LENGTH, unique=True,
default=generate_balance_code, help_text=code_help)
value =
models.PositiveIntegerField(default=BALANCE_CODE_DEFAULT_VALUE)
refill_series = models.ForeignKey(RefillSeries)
used_by = models.ForeignKey(Student, null=True, blank=True)
used_at = models.DateField(blank=True, null=True)
}}}
{{{
class RefillSeries(models.Model):
issued = models.DateField(default=default_issued)
least_valid_until =
models.DateField(default=default_least_valid_until)
}}}
'''admin.py:'''
{{{
class BalanceCodeInline(admin.TabularInline):
readonly_fields = ('code', )
model = BalanceCode
extra = SERIES_CODE_COUNT
max_num = SERIES_CODE_COUNT
}}}
{{{
class BalanceCodeAdmin(admin.ModelAdmin):
readonly_fields = ('code', )
}}}
{{{
class RefillSeriesAdmin(admin.ModelAdmin):
inlines = (BalanceCodeInline,)
}}}
= Problem Description =
== Expected ==
When a new `RefillSeries` is created, `SERIES_CODE_COUNT BalanceCode`s
should
be created as well.
== Actual ==
No `BalanceCode`s are created. When `readonly_fields` is unset,
`SERIES_CODE_COUNT` objects are created, as expected.
Creating new `BalanceCode`s directly (not inlined in the `RefillSeries`
admin
interface) works as expected when `readonly_fields` is set.
--
Ticket URL: <http://code.djangoproject.com/ticket/14095>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.