Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango adding a feedback form on every page
    primarykey
    data
    text
    <p>I have a form view for user feedback:</p> <p><strong>urls.py:</strong></p> <pre><code>url( r'^feedback/$', 'tool.views.Feedback', name='feedback' ), url( r'^thanks/$', direct_to_template, { 'template': 'tool_feedback_thanks.html' }, name='feedback_thanks' ), </code></pre> <p><strong>forms.py:</strong></p> <pre><code>class FeedbackForm(forms.Form): yes_no = forms.ChoiceField( choices=YES_NO_CHOICE, initial=1, widget=forms.RadioSelect(attrs={'class': 'can_reveal_input'}), label="Are you happy with Our service?" ) comments = forms.CharField( widget=forms.Textarea(attrs={ 'class': 'hidden', 'placeholder': 'Leave us your comments...' }), required=False, label="" ) </code></pre> <p><strong>views.py:</strong></p> <pre><code>def Feedback(request, template_name='tool_feedback.html'): title = u'Leave us some feedback' form = FeedbackForm(request.POST or None) if form.is_valid(): yes_no = form.cleaned_data['yes_no'] comments = form.cleaned_data['comments'] sender = "A Unirac website user" recipients = ['person@example.com'] send_mail(yes_no, comments, sender, recipients) return HttpResponseRedirect( reverse('feedback_thanks') ) return render_to_response(template_name, { 'title': title, 'form': form, }, RequestContext(request)) </code></pre> <p>This works a treat, but now the client is asking that this form be included on every single page. I guess the form can be submitted via js to the appropriate url, but what is the best way to include the unbound form on every page?</p> <p>Any help would be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload