Do you need one-time previews ("are you sure you want to save this?") or
real drafts that can be viewed more than once? If you just need an
intermediate preview step for the user who's submitting the data, you can do
it without saving any data on the backend --
write a "preview" view that validates the POSTed data without committing
and then
renders a template with a form that includes that data by default, and which
will POST to the real save view.
I like to put the data in hidden fields, and render a representation of the
previewed data separately. That way the "save for real" form can just look
like a button to the user, and you can have a separate form for modifying
the data and going through the preview cycle again.
I haven't done anything custom in the django admin, but I assume this
technique can work there too.
Hope this helps,
egj
On Thu, Oct 22, 2009 at 8:12 AM, Aaron <[email protected]> wrote:
>
> I've thought about using a "published" boolean but I'm not sure how
> that would help.
>
> These models are displayed on a live site, and it will be existing
> models I'll be editing and previewing. While a model is in "draft
> mode" I still want the old unchanged version of the model displayed on
> the live site. I'm not sure how I'm going to store either the original
> or the draft versions of the model, or how I'm going to replace the
> original with the draft after I commit its changes.
>
> On Oct 21, 5:38 pm, akonsu <[email protected]> wrote:
> > hello,
> >
> > anything is possible. you just need to decide how you are going to
> > store your changes before the model gets "really" saved so that the
> > preview functionality works. where would preview get the values from?
> > i propose a "published" boolean field in the model.
> >
> > konstantin
> >
> > On Oct 21, 3:41 pm, Aaron <[email protected]> wrote:
> >
> > > I'm wanting to set up model previews in the admin. I've been following
> > > this guide:
> >
> > >http://latherrinserepeat.org/2008/7/28/stupid-simple-django-admin-pre.
> ..
> >
> > > However, that guide seems to only apply to models that have already
> > > been saved (how is it different from "View on site"?). I wish to be
> > > able to make changes to my model, click on "Preview", and see what my
> > > model page will look like *before* saving it in the admin. Is this
> > > possible?
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---