django
Providing initial values to formset in django admin inline for a custom form
I have a model "Timings" that goes like this. weekday = models.CharField(choices=constants.WEEKDAYS, max_length=10) start_time = models.TimeField() end_time = models.TimeField() lab = models.ForeignKey('Lab') I had to override the form in django admin and display it as inline in Lab form. I created a form for Timings model and excluded all model fields and introduced some form fields. day = forms.CharField(label="Day", required=False) start_session1 = forms.TimeField(label="Session-1 Start", required=False) end_session1 = forms.TimeField(label="Session-1 End", required=False) start_session2 = forms.TimeField(label="Session-2 Start", required=False) end_session2 = forms.TimeField(label="Session-2 End", required=False) My purpose here is to display a table like structure to user in inline. & rows for the 7 days in the week with storing upto 2 sessions per day. I have overridden the form's save method. Now my instances are getting saved in the DB but in edit mode, I need to display the already present instances in the DB according to the same structure of the form. I ran over the concept of formsets but could not figure out how to override the initial values dynamically. Can somebody help? Stuck at this problem for a week.
Related Links
Django - how to write such widget / field for django fields?
Django models group-by related
Does adding a class to models.py ever cause “view does not exist” error?
Model form update page show to all register users
Multiple OR filters in django-nonrel are not allowed, workaround?
Case Insensitive search in containment filter
uwsgi: unrecognized option '--module=MyProject.wsgi:application'
Django - ImproperlyConfiguredError, Guardian's ANONYMOUS_USER_ID
django-pdb when running with nginx/fcgi?
“reverse editing” of generic inlines in django admin
Handling files in Django
I'm looking for working example of django mptt [closed]
How do I temporarily store input from unregistered user in Django?
Denormalizing a relationship through another model in django-denorm
Django-CMS plugin cmsplugin_blog is throwing a VariableDoesNotExist error
Redis is slow to get large strings