Code

Opened 6 months ago

Closed 6 months ago

#21327 closed Uncategorized (invalid)

D jango forms

Reported by: suvankar Owned by: nobody
Component: Forms Version: 1.5
Severity: Normal Keywords:
Cc: gkmngrgn@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

in a from i have display four field

first name
last name
promocode
email

when i click submit button this will return a another where another
from will open and fetch data from data base ]

i want to display data conditionaly when user put promocode in firstfrom
at first i want to check this promocode will start with 4(as example 44444)
then we redirect an page valid.html otherwise we redirect result.htmlhow to do this
please healp

my viewes.py

class Registerview(FormView,ListView):
template_name = "valid.html"
model = Customers
form_class = PromoModelForm

def get(self, request, *args, kwargs):
week = Customers.objects.all()
try:
p=Customers.objects.get(PROMOCODE=request.GETPROMOCODE?)
wer=Customers.objects.filter(PROMOCODE=request.GETPROMOCODE?)
if request.method == 'POST': # If the form has been submitted...
form = PromoModelForm(request.POST, request.FILES, instance=wer) # A form bound to the POST data
if form.is_valid(): # All val
x = {'form': form, }
raise Http404
except Customers.DoesNotExist:
raise Http404
else:
form = PromoModelForm(instance=p) # An unbound form
x = RequestContext(request,{
'week':week,
'form':form
})
return render_to_response('valid.html',x, context_instance = RequestContext(request))

and my urls.py is
url(r'register/?$', Registerview.as_view()),

Attachments (0)

Change History (2)

comment:1 Changed 6 months ago by suvankar

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 months ago by timo

  • Resolution set to invalid
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.