Yeah, that's actually what I was doing before, but as far as I can tell formtools prevents that possibility. Do you know of some way to create the desired 'preview page' behavior while using CreateView?
On Thursday, March 9, 2017 at 4:30:26 AM UTC-7, ludovic coues wrote:
-- On Thursday, March 9, 2017 at 4:30:26 AM UTC-7, ludovic coues wrote:
If you want to create a Job object and save it to database, I highly
recommend the CreateView
https://docs.djangoproject.com/en/1.10/ref/class-based- views/generic-editing/#django. views.generic.edit.CreateView
2017-03-09 2:17 GMT+01:00 jthewriter <miller...@gmail.com>:
> Probably a simple question but having trouble implementing a form preview
> page using django-formtools. I've configured everything per the docs. I'm
> stuck on what to add to the done() method to save the data to db.
>
>
> forms.py
>
> class JobForm(ModelForm):
> class Meta:
> model = Job
> fields = ('title', 'category', 'company', 'website',
> 'description',)
>
> class JobFormPreview(FormPreview):
> def done(self, request, cleaned_data):
> # add what here to save form data as object?
> return HttpResponseRedirect('/success')
>
>
> urls.py
>
> ...
> url(r'^jobs/new/$',
> JobFormPreview(JobForm),
> name='job_form'),
> ...
>
>
> Using the default templates. The form and preview both render fine, but
> obviously data doesn't save on submit. Tried self.form.save() but get an
> error save() missing 1 required positional argument: 'self'.
>
>
> I appreciate any guidance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a2a45d4e- .d7cf-469b-9721-990488a3450f% 40googlegroups.com
> For more options, visit https://groups.google.com/d/optout .
--
Cordialement, Coues Ludovic
+336 148 743 42
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3f94a9bd-ad7a-467e-b897-f1410a6f8878%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment