I decided to move some functions from my admin site to the interface. Functionality includes administering the same model with some external key lines.
To do this, I installed the jQuery django-dynamic-formset plugin ( git link) and have been struggling with it for a couple of days. Here is one of the problems.
The same functionality is already implemented in the Django admin. I can add, modify, delete inline strings and modify the model instance as I want. I am wondering why I should use this jQuery plugin and why there arenβt so many good tutorials on this topic on the Internet?
I need a good and recent example of using django forms or inline forms on the interface side without third-party JS files. I would be happy if it has links (not checkboxes) to remove inline elements and add a button that will correctly add a new line.
To be more specific, because the question was considered too broad:
I have two School and SchoolPlace models:
class School(models.Model): name = models.CharField(_('School name'), max_length=100) class SchoolPlace(models.Model): school = models.ForeignKey(School, verbose_name=_('school place'), related_name='school_places', blank=True, null=True) name = models.CharField(_('School place name'), max_length=200) city = models.ForeignKey(City, blank=True, null=True, verbose_name=_('city'), help_text='city')
There are also relevant forms:
class SchoolForm(forms.ModelForm): name = forms.CharField( label=_('Name'), widget=forms.TextInput(attrs={ 'placeholder': _('school name')}), max_length=100, required=True) class SchoolPlaceForm(forms.ModelForm): name = forms.CharField(label=_('Name'), widget=forms.TextInput( attrs={'placeholder': _('school place name')}), max_length=200, required=False) city = forms.ModelChoiceField(label=_('City'), widget=forms.Select(attrs={'class': 'ui search dropdown'}), queryset=City.objects.all(), required=False) class Meta: model = SchoolPlace fields = ['name','city'] exclude = ['school']
I would like to edit these two models in the same way as in Django admin, but only on my own interface. Since all js files are already in django.contrib.admin, I would like to do this without using side applications and plugins.
I need the same functions as in Django admin: add, delete, change lines in SchoolPlace. Here is a screenshot: 