Django Pending and Resuming Forms

(Jhon) #1

I am trying to implement a feature where i can save partially filled form (ModelForm) and come back later and complete the form and finally submit it.


  1. Display an empty form.
  2. User fills in some data.
  3. User clicks Save.
  4. Validate data submitted by the user.
  5. Display the form with errors.
  6. User fills with correct data.
  7. User clicks Save again.
  8. Save form values in the database.
  9. User logs out from system.
  10. User logs in and resume partially filled form.
  11. User fills in rest data.
  12. User clicks Save&Submit.
  13. Validate data submitted by the user.
  14. Display the form with errors.
  15. User fills with correct data.
  16. User clicks Save&Submit again.
  17. Process the completed form.

class Post(models.Model):
    submitted = models.ForeignKey(User, on_delete=models.CASCADE)
    post_name = models.CharField(max_length=255)
    post_decription = models.TextField(max_length=500)
    post_start = models.DateTimeField()
    post_end = models.DateTimeField()
    post_duration = models.DurationField(default=timedelta(days=1))
    is_published = models.BooleanField(default=False)
    request_approval = models.BooleanField(default=False)
    list_date = models.DateTimeField(

class PostForm(forms.ModelForm):
    class Meta:
        model = Post
        exclude = ("submitted", 'post_duration', "list_date", "is_published", "request_approval")
        widgets = {
            'post_start': DatePickerInput(),
            'post_end': DatePickerInput(),