#30626: InlineModelAdmin fails validation of an empty form when there are
ForeignKey and DecimalField with default="0.00"
-----------------------------------------+------------------------
               Reporter:  dchaplinsky    |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  contrib.admin  |        Version:  2.2
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 I have following code for the model:

 {{{
 class PayrollItem(models.Model):
     payroll = models.ForeignKey(
         "Payroll",
         verbose_name="Payroll",
         on_delete=models.CASCADE,
         related_name="items",
     )
     contract = models.ForeignKey(
         "Contract",
         verbose_name="Contract",
         on_delete=models.CASCADE,
         related_name="payments",
     )
     hours = models.DecimalField("Hours", decimal_places=2, default="0.00",
 max_digits=7, blank=True)
     current_rate = models.DecimalField(
         "Hourly rate", decimal_places=2, default="0.00", max_digits=7,
 blank=True
     )

 }}}


 which is then added as an `InlineModelAdmin`:


 {{{
 class PayrollItemInline(admin.TabularInline):
     extra = 1
     model = PayrollItem
 }}}


 when I hit save parent object, Django raises validation error for foreign
 key of an empty inline form like in attached file

 If I exclude "hours", "current_rate" everything works as expected!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30626>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.ef93b5cd626cd82ba6b824ef6e4f3b16%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to