Skip to content Skip to sidebar Skip to footer

Using Multiple Input Fields For One Model's Attribute With Django

In models.py I have class myModel: period = models.CharField(max_length = 100, blank=True) the period should contain something like: DD:HH:MM:SS. In the HTML template, I want

Solution 1:

This is well documented: you need to create a subclass of forms.MultiValueField, which implements a compress method which returns the combined value of the fields. Note that there is already a SplitDateTimeField, but that just have two separate fields for each of the date and time.


Post a Comment for "Using Multiple Input Fields For One Model's Attribute With Django"