Nope, sorry I missread El mié, 1 de dic. de 2021 a la(s) 19:05, Gabo LaTo (elgatogabr...@gmail.com) escribió:
> Aren't you missing the model class attribute in TestMyModelCreate? > > Like this: > > class TestMyModelCreate(admin.ModelAdmin): > model = MyModel > fields = ['text', ] > inlines = [RelatedModelInlineTabular] > > > > El lun, 29 de nov. de 2021 a la(s) 20:28, 'Andrea Arighi' via Django users > (django-users@googlegroups.com) escribió: > >> Good evening, >> I am encountering a weird bug when rendering Inline forms on the "Add" >> view of a ModelAdmin. >> >> Here is a minimum example with Django version 2.2.4 >> >> - - - - - - - >> >> in models.py: >> >> class MyModel(models.Model): >> text = models.CharField(max_length=100) >> >> class RelatedModel(models.Model): >> parent = models.ForeignKey(MyModel, null=False, on_delete=models.CASCADE) >> number = models.DecimalField(decimal_places=2, max_digits=10, >> null=False, blank=False) >> >> >> in admin.py: >> >> class RelatedModelInlineTabular(admin.TabularInline): >> model = RelatedModel >> show_change_link = False >> fields = ("number", ) >> >> class TestMyModelCreate(admin.ModelAdmin): >> fields = ['text', ] >> inlines = [RelatedModelInlineTabular] >> >> admin.site.register(MyModel, TestMyModelCreate) >> >> >> Steps to replicate: >> >> - Login to django admin website >> - open the "add" view for MyModel (i.e. navigate to the list of >> Models and click on the "Add new" button >> >> >> Expected result: >> The form displays an empty text field. Below that, an Inline form is >> displayed with 3 empty rows for potential related instances of >> RelatedModel >> >> Actual result: >> The Inline form is displayed twice, each instance with its own 3 empty >> rows, as if I had specified it twice. >> >> - - - - - - >> I attach screenshots of the actual page ( Discount is the related >> Model). Please note that I get the same result with both StackedInline and >> TabularInline. >> >> [image: immagine.png] >> >> Am I making some trivial error here that could explain what's happening? >> Or is this is a known bug? Thank you in advance to anyone that will help. >> >> Best regards >> * * * * * >> Andrea Arighi ~ Software Developer >> Please consider the environment before printing this email >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAJzUX%3D68ejwz2Q0Lwvarw-hA%3DV5xsKfL%3D%2BHrsLzuHDkF2_ApmA%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAJzUX%3D68ejwz2Q0Lwvarw-hA%3DV5xsKfL%3D%2BHrsLzuHDkF2_ApmA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF6hzDOmrN4dOc_LHxQmfXSWAuaR63gcEPwou3S-Wq8XHkTxgQ%40mail.gmail.com.