Reputation: 31
I'm just working on the Django admin page. It is just to collect data, so I'm using a simple model and Django admin to collect data. I've made a model using this code:
Adjoining_land_cover_1 = models.CharField('Adjoining land cover 1', max_length=100)
Adjoining_land_cover_2 = models.CharField('Adjoining land cover 2', max_length=100)
Adjoining_land_cover_3 = models.CharField('Adjoining land cover 3', max_length=100)
Adjoining_land_cover_4 = models.CharField('Adjoining land cover 4', max_length=100)
My question is: I want it to be dynamic. Is it possible to first make one "Adjoining land cover" and have an add button that will create another field and add as many as possible? I don't mind saving each value using a comma.
I appreciate any help you can provide.
Upvotes: 0
Views: 137
Reputation: 36
Try making that model a TabularInline
of another wrapper model in the admin. Then you will be able to add as many instances as you wish.
Here is the Django Documentation about the Tabular Inlines: https://docs.djangoproject.com/en/4.0/ref/contrib/admin/#django.contrib.admin.TabularInline
Upvotes: 1