Answer the question
In order to leave comments, you need to log in
How to display the filled formset of all data from the table at once?
There is a table with 10 entries, how to display the completed formset of all this data with the possibility of editing it? More precisely, I do not need to display all the data, but on a certain basis, but not the essence.
Answer the question
In order to leave comments, you need to log in
I think the documentation https://docs.djangoproject.com/en/1.8/ref/forms/models/
about filtering data in forsets will help you understand the formsets, examples - stackoverflow.com/questions/9711313/django-how-to- ... , stackoverflow.com/questions/2581049/filter-queryse...
well, if you are completely depressed, then an example:
form:
class DatesOperationForm(forms.ModelForm):
class Meta:
model = OperationDate
DateFormSet = inlineformset_factory(Operation, OperationDate, extra=1, can_delete=False, form=DatesOperationForm)
class OperationDetail(UpdateView):
form_class = OperationForm
def get_context_data(self, **kwargs):
context = super(OperationDetail, self).get_context_data(**kwargs)
context['form_dates'] = DateFormSet(instance=self.object)
return context
class Operation(models.Model):
name = models.CharField(u"Название", max_length=255)
sum = models.DecimalField(u"Сумма", max_digits=10, decimal_places=2)
category = models.ForeignKey(CategoryOperation, verbose_name=u"Категория", null=True, blank=True,
related_name='operations')
...
class OperationDate(models.Model):
operation = models.ForeignKey(Operation, verbose_name=u"Опреация")
....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question