RE: [EXTERNAL]Re: #Beginnerlevel Form sending get instead of post request

2021-04-23 Thread Chaitanya Sakoji
Thank Agoua. It worked after update.

From: django-users@googlegroups.com  On Behalf 
Of Agoua David
Sent: 23 April 2021 13:08
To: django-users@googlegroups.com
Subject: Re: [EXTERNAL]Re: #Beginnerlevel Form sending get instead of post 
request

I think it's because tour submit button IS not in the form

Le ven. 23 avr. 2021 à 01:58, Chaitanya Sakoji 
mailto:chaitanya.sak...@cerence.com>> a écrit :
Thanks Kasper for your reply.

-Original Message-
From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> On Behalf 
Of Kasper Laudrup
Sent: 23 April 2021 01:17
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: [EXTERNAL]Re: #Beginnerlevel Form sending get instead of post request

On 22/04/2021 17.14, chaitanya sakoji wrote:
> Previously this code was sending post request. Suddenly after
> restarting server, it started sending get.

I *think* I might understand what you mean.

The code you posted doesn't send anything. It handles POST request sent from 
your browser. If you load a page with your browser normally, it will send a GET 
request.

My guess is, that you've sent a POST request to the page (which works
fine) and then you load the same page in your browser sending a GET request.

Could that explain it.

Just to be clear. Your code will not start changing behavior without you doing 
anything (self modifying code is indeed a thing, but that's not relevant here 
at all).

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/x6_U7_hCeOY/unsubscribe<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Ftopic%2Fdjango-users%2Fx6_U7_hCeOY%2Funsubscribe=04%7C01%7Cchaitanya.sakoji%40cerence.com%7C534d4629fe78428155bd08d9062ae018%7C363f8ad71be34f058a6b4955756fe2f6%7C0%7C0%7C637547603607671772%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=%2FNxvwyCruFYS0Dyqop8ihjdBNGuN3pgA8Fq3K0ZW0%2Fo%3D=0>.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4c96bea3-db71-ca42-7158-9e1f3a9bc6ea%40stacktrace.dk<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdjango-users%2F4c96bea3-db71-ca42-7158-9e1f3a9bc6ea%2540stacktrace.dk=04%7C01%7Cchaitanya.sakoji%40cerence.com%7C534d4629fe78428155bd08d9062ae018%7C363f8ad71be34f058a6b4955756fe2f6%7C0%7C0%7C637547603607681772%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=lDKm5DQLK7ATUFnAYDb7u57GMUvFhwaUKxm0rgqW3cg%3D=0>.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/BN6PR08MB23882B77FEB28076EDA82B1A97459%40BN6PR08MB2388.namprd08.prod.outlook.com<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdjango-users%2FBN6PR08MB23882B77FEB28076EDA82B1A97459%2540BN6PR08MB2388.namprd08.prod.outlook.com=04%7C01%7Cchaitanya.sakoji%40cerence.com%7C534d4629fe78428155bd08d9062ae018%7C363f8ad71be34f058a6b4955756fe2f6%7C0%7C0%7C637547603607691761%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=kLPPQRmKFynREQyY6VicvcsA4q%2FIxZdbR%2B%2BxL8FX7bI%3D=0>.
--
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/x6_U7_hCeOY/unsubscribe<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Ftopic%2Fdjango-users%2Fx6_U7_hCeOY%2Funsubscribe=04%7C01%7Cchaitanya.sakoji%40cerence.com%7C534d4629fe78428155bd08d9062ae018%7C363f8ad71be34f058a6b4955756fe2f6%7C0%7C0%7C637547603607701763%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=HtDfz7i0q66OR4rM5tkiN%2BXJMrLvWJmNJ2h3uBMCdMQ%3D=0>.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAByCr6goGGGW14MU7qmVeZo81pEULzaJVhhQbxH2%2B9%2Br6hWmAg%40mail.gmail.com<https

RE: [EXTERNAL]Re: #Beginnerlevel Form sending get instead of post request

2021-04-22 Thread Chaitanya Sakoji
Thanks Kasper for your reply.

-Original Message-
From: django-users@googlegroups.com  On Behalf 
Of Kasper Laudrup
Sent: 23 April 2021 01:17
To: django-users@googlegroups.com
Subject: [EXTERNAL]Re: #Beginnerlevel Form sending get instead of post request

On 22/04/2021 17.14, chaitanya sakoji wrote:
> Previously this code was sending post request. Suddenly after 
> restarting server, it started sending get.

I *think* I might understand what you mean.

The code you posted doesn't send anything. It handles POST request sent from 
your browser. If you load a page with your browser normally, it will send a GET 
request.

My guess is, that you've sent a POST request to the page (which works
fine) and then you load the same page in your browser sending a GET request.

Could that explain it.

Just to be clear. Your code will not start changing behavior without you doing 
anything (self modifying code is indeed a thing, but that's not relevant here 
at all).

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/x6_U7_hCeOY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4c96bea3-db71-ca42-7158-9e1f3a9bc6ea%40stacktrace.dk.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/BN6PR08MB23882B77FEB28076EDA82B1A97459%40BN6PR08MB2388.namprd08.prod.outlook.com.


#Beginnerlevel Form sending get instead of post request

2021-04-22 Thread chaitanya sakoji


Previously this code was sending post request. Suddenly after restarting 
server, it started sending get. If I take some working post code for form 
from internet and then go on trying and erasing then my code starts sending 
post request. But again after some time when I put my original code, this 
will start sending get request instead of post request.
user_registration_form.html

{% csrf_token %}
{{ form }}



 forms.py
from django.forms import ModelForm
from django import forms
from .models import StudentData


class StudentRegister(ModelForm):

class Meta:
model = StudentData
fields = "__all__"
widgets = {'password': forms.PasswordInput(),
'rpassword': forms.PasswordInput()}

def clean(self):
cleaned_data = super().clean()
password, rpassword = cleaned_data.get('password'), 
cleaned_data.get('rpassword')
if password != rpassword:
error_msg = "Both passwords must match"
self.add_error('rpassword', error_msg)


views.py
from django.shortcuts import render
from .forms import StudentRegister
from django.contrib import messages


def login_register(request):
return render(request, 'users/login_register.html')


def guest_register(request):
return render(request, 'users/guest_register.html')


def student_data(request):
if request.method == 'POST':
print('post')
form = StudentRegister(request.POST)
if form.is_valid():
print('valid form')
form.save()
messages.success(request, f"You are registered successfully, 
{form.cleaned_data.get('name')}")
return render(request, "Registration done")
else:
print('get')
form = StudentRegister()
return render(request, 'users/user_registration_form.html', {'form': form})

model.py
from django.db import models
from django.core.validators import MaxLengthValidator


class StudentData(models.Model):
name = models.CharField(max_length=100)
room_no = models.CharField(max_length=4)
email = models.EmailField()
mobile = models.CharField(max_length=10)
password = models.CharField(max_length=20)
rpassword = models.CharField(max_length=20)

def __str__(self):
return f'{self.name} data'

Thanks,
Chaitanya

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/88869687-aba7-48f3-99d1-08bfe5643821n%40googlegroups.com.