Contact Form

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from django import newforms as forms
from django.newforms import widgets
from live.utils.custom_widgets import TinyMCE
from live.about.models import Feedback

class ContactForm(forms.Form):
    from_email = forms.EmailField(label='email',initial='my_email@address.com')
    subject = forms.CharField(max_length=100)
    message = forms.CharField(widget=TinyMCE())
    subject_prefix = forms.CharField(widget=widgets.HiddenInput,initial='feedback')

    def save(self,commit = True,user=None):
        feedback = Feedback(**self.clean_data) 
        feedback.user = user
        if commit:
            feedback.save()
        return feedback

def contact(request,template="about/contact.html",redirect_to="/"):
    form = None
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            feedback = form.save(user=request.user)
            return HttpResponseRedirect("/")
    else:
        form = ContactForm()
    r = render_to_response(template, {'contact_form':form})

    return r

More like this

  1. TinyMCE Widget by semente 3 years, 8 months ago
  2. FieldsetForm by Ciantic 6 years, 1 month ago
  3. HTML5 filter for XXS by ronnie 2 years ago
  4. Cleanup dirty HTML from a WYSIWYG editor by denis 3 years, 11 months ago
  5. Replace Paragraph Tags for Flash by blackbrrr 4 years, 9 months ago

Comments

(Forgotten your password?)