Thanks Stephen. Unfortunately I've moved the print statement, but it
doesn't seem like this file is being hit at all. page_processors only work
with custom page classes right? or could this be applied to the generic
Page class as well?
On Wednesday, April 22, 2015 at 2:12:11 PM UTC-7, Stephen McDonald wrote:
>
> That print statement in the code you posted looks particularly nefarious -
> not only is it not printing at the time you probably want it to (when the
> processor is actually running), it's actually most likely causing the
> `@processor_for` decorator to not be applied to your `event_form` function.
> AFAIK the decorator needs to be directly before the function statement for
> it to be applied.
>
> That's probably the source of your problems. With that resolved you can
> display the form any way you like, ranging from simply writing out the form
> object in your template (eg: {{ form }}) or using a template tag as you
> described - there's even a Mezzanine tag built in that's used a lot for
> that: http://mezzanine.jupo.org/docs/utilities.html#fields-for
>
>
> On Thu, Apr 23, 2015 at 2:48 AM, Sep Dadsetan <[email protected]
> <javascript:>> wrote:
>
>> My goal is to include a form on specific page that is not a Form page.
>> Thanks to the documentation, I've learned that page_processors seem to be
>> the way to go, but I'm trying to wrap my head around how page_processors.py
>> is implemented and I think I'm missing something obvious. Any help would be
>> appreciated.
>>
>> Here's what I have:
>>
>> My app is site and page_processors.py is placed inside it like so:
>>
>> site/
>> page_processors.py
>>
>>
>> page_processors.py:
>> from django import forms
>> from django.http import HttpResponseRedirect
>> from mezzanine.pages.page_processors import processor_for
>> from mezzanine_events.models import Event
>>
>> class EventForm(forms.Form):
>> name = forms.CharField()
>> email = forms.EmailField()
>>
>> @processor_for("about/events/test-event-3")
>> print "processor"
>> def event_form(request, page):
>> form = EventForm()
>> if request.method == "POST":
>> form = EventForm(request.POST)
>> if form.is_valid():
>> # Form processing goes here.
>> redirect = request.path + "?submitted=true"
>> return HttpResponseRedirect(redirect)
>> return {"form": form}
>>
>>
>> Now what? I assume that I can use a template tag for "form", but I
>> haven't been successful in any iteration of that.
>>
>> Thanks in advance!
>> Sep
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Mezzanine Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Stephen McDonald
> http://jupo.org
>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.