hi i have one form inside the form

<form name="lightform" id="lightform" action="../sendmail"
method="POST" onSubmit="javascript:self.close();">
{% for name in eventname %}
<div class="basicModals"  style="text-align:left;margin-top:20px;">
<div class="eventname"><b><a href="#" class="basics" id="a_
{{forloop.counter}}">{{ name.title }}</a></b></div>
</div>
<div class="eventaddress">{{ name.address }}</div>
<div class="eventdesc">{{ name.summary }}</div>
<div id="div_a_{{forloop.counter}}" class="basicModalContent"
style='display:none'><div>
<div  style="color:red">{{ name.title }}</div>
                                <div><img src="{{ name.get_thumbnail_url }}" 
style="width:
25%;height:25%"/></div>
                                </div>
                                <div>
                                        <div>{{ name.summary }}</div>
                                        <div>{{ name.start_date }} to {{ 
name.end_date }}</div>
                                        <div>{{ name.start_time }} to {{ 
name.end_time }}</div>
                                        <div>{{ name.venue }}</div>
                                        <div>{{ name.contact }}</div>
                                        <div>{{ name.description }}</div>
                                </div>
                                <div>
                                        <div>{{ forms.name }} Friend's 
Name</div>
                                        <div>{{ forms.email }} Friend's 
Email</div>
                                        <div style="height:5px;float:left">{{ 
forms.comment}}</div>
                                        <input type="reset" value="Cancel"/>
                                        <a href="../sendmail" 
onClick="javascript:self.close();">Submit</
a>
                                         <input type="submit" name="submit" 
class="submit-post"
value="Send" />
                                        <!--input type="submit" 
value="Submit"/-->
                                </div>
                        </div>
                {% endfor %}
</form>

forms.py
---------
class MailForm(forms.Form):
    #topic = forms.ChoiceField(choices=TOPIC_CHOICES)
    name  = forms.CharField(label=_("Name"), max_length=50)
    email = forms.EmailField(label=_("Email address"))
    comment = forms.CharField(label=_("Comment"),
widget=forms.Textarea)

eventview.py
------------
def event(request):
        difference1 = datetime.timedelta(days=-3)
        today=datetime.date.today()
        print "Today date : ", today
        l=range(1,5)
        forms = MailForm(request.POST)# Creating MAIL FORM interface in side
event template
        print "Mail Form : ", forms
        eventobj=events.objects.all().filter
(start_date__lte=today,end_date__gte=today)
        eventname=events.objects.all().filter
(start_date__lte=today,end_date__gte=today)
        #eventobj=events.objects.all().filter(start_date__gte=today-
datetime.timedelta(days=3), end_date__lte=today+datetime.timedelta
(days=10), highlighted='true',visibility='true')
        paginator = Paginator(eventobj, 2)
        try:
            page = int(request.GET.get('page','1'))
            print "page : ", page
        except ValueError:
            page = 1
        try:
            eventobj = paginator.page(page)
            print " Event object : ", eventobj
        except(EmptyPage, InvalidPage):
                eventobj = paginator.page(paginator.num_pages)
        return render_to_response("event.html",
{'eventobj':eventobj,'l':l,'eventname':eventname,'today':today.strftime
("%B %d %Y %A"),'forms':forms})

#View for send mail#
-------------------
def mail(request):
    if request.method == 'POST': # If the form has been submitted...
        form = MailForm(request.POST) # A form bound to the POST data
        if form.is_valid():
                print "Form valid"
                comment = form.cleaned_data['comment']
                email = ['i...@example.com']
                from django.core.mail import send_mail
                send_mail(comment, email)
                print "Send mail : ", send_mail(comment, email)
                return HttpResponseRedirect('/pro/Thanks/')
    else:
        print "Invalid form"
        form = MailForm() # An unbound form
    return render_to_response('contact.html', {'form': form})

urls.py
------

    (r'^foodies/events/$', 'foodies.foodapp.eventview.event'),
    (r'^foodies/sendmail/$','foodies.foodapp.eventview.mail'),

i am displaying eventdetails in light box where i have one submit and
name and email field. if some one click on submit then mail should
send page should closed. but when i am clicking on submit button form
is closing but it shows me "Invalid Form" which i wrote in else part
of mail view. i think some thing wrong in get or post.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to