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)
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)
MyModel
(i.e. navigate to the list of Models and click on the "Add new" buttontext
field. Below that, an Inline form is displayed with 3 empty rows for potential related instances of RelatedModel
Discount
is the related Model). Please note that I get the same result with both StackedInline and TabularInline.class TestMyModelCreate(admin.ModelAdmin):
model = MyModel
fields = ['text', ]
inlines = [RelatedModelInlineTabular]
--
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...@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.