def post( self, request): # if this is a POST request we need to process the form data # create a form instance and populate it with data from the request: form = HomeForm(request.POST) # check whether it's valid: if form.is_valid(): # process the data in form.cleaned_data as required first_name = form.cleaned_data['first_name'] last_name = form.cleaned_data['last_name'] email = form.cleaned_data['email'] phone_number = form.cleaned_data['phone_number'] address_of_property = form.cleaned_data['address_of_property'] # insert data into database newLead.objects.create( first_name=first_name, last_name=last_name, email=email, phone_number=phone_number, address_of_property=address_of_property ) # redirect to a new URL: # create a "thank you" page return HttpResponseRedirect('/account')
def post(self, request): text = 'None' form = HomeForm(request.POST) if form.is_valid(): text = form.cleaned_data['post'] form = HomeForm() # return redirect('home') context = {'form': form, 'text': text} return render(request, self.template_name, context)
def registerProfile(request): if request.method == 'POST': form = HomeForm(request.POST) if form.is_valid(): form.save() return redirect('/account') else: form = HomeForm() args = {'form': form} return render(request, 'accounts/reg_form.html', args)
def get(self, request): form = HomeForm() return render(request, self.template_name, {'form': form})
def get(self, request): form = HomeForm() context = {'form': form} return render(request, self.template_name, context)
def register(request): if request.method == 'POST': user_form = RegistrationForm(request.POST, request.FILES) profile_form = HomeForm(request.POST, request.FILES or None) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() user.refresh_from_db() # This will load the Profile created by the Signal profile_form = HomeForm(request.POST, instance=user.userprofile) # Reload the profile form with the profile instance profile_form.full_clean() # Manually clean the form this time. It is implicitly called by "is_valid()" method profile_form.save() # Gracefully save the form current_site = get_current_site(request) subject = 'Activate Your MySite Account' message = render_to_string('accounts/account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode(), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) return redirect(reverse_lazy('account_activation_sent')) else: user_form = RegistrationForm() profile_form = HomeForm() return render(request, 'accounts/reg_form.html', { 'user_form': user_form, 'profile_form': profile_form })
def post(self, request): # the input is received from the user using POST method form = HomeForm(request.POST) if form.is_valid(): text = form.cleaned_data['my_time'] date_text = form.cleaned_data['my_date'] # the time stamp is then appended to the api link and parsed to get the data of that time # this is for the card showing no. of people response = requests.get( 'http://127.0.0.1/csv-to-api/?source=http://127.0.0.1/dataset.csv&ds=2019-06-' + date_text + '%20' + text) a = response.json() for i in a: xx = i t = a[xx] gg = t['y'] #------------------------------------------------- #this is for the current chart counter = 1 # limiter = text.split(':')[0] limiter = 11 arr = [] cc = int(limiter) while (counter < 13): cc = cc + 1 req = requests.get( 'http://127.0.0.1/csv-to-api/?source=http://127.0.0.1/dataset.csv&ds=2019-06-' + date_text + '%20' + str(cc) + ':00:00') n = req.json() for f in n: x1 = f val = n[x1] val2 = val['y'] arr.append(val2) counter = counter + 1 #to find the busiest time of the day busy_time_indx = max(arr) busy_time = int(busy_time_indx) + 1 #------------------------------------------------- # predict.csv is from dates 2019-05-01 to 2019-07-05 #for prediction chart new = '0' + str(int(date_text) + 1) p_counter = 1 # limiter = text.split(':')[0] p_limit = 11 arr2 = [] int_l = int(p_limit) while (p_counter < 13): int_l = int_l + 1 p_req = requests.get( 'http://127.0.0.1/csv-to-api/?source=http://127.0.0.1/predict.csv&ds=2019-06-' + str(new) + '%20' + str(int_l) + ':00:00') p_req.text j = p_req.json() for f in j: x1 = f p_val = j[x1] p_val2 = p_val['yhat'] arr2.append(p_val2) p_counter = p_counter + 1 args = { 'form': form, 'text': text, 'y': t['y'], 'arr': arr, 'arr2': arr2, 'busy_time': busy_time } return render(request, self.tempname, args)
def get(self, request): # This creates a form from forms.py for submitting user input of time form = HomeForm() # a dictionary is created to use form and search variables in the html using jinja template language return render(request, self.tempname, {'form': form})