Re: formset has_changed always return true.

2019-06-11 Thread Gil Obradors
Can you paste codes?  Forms.py and views.py

El dc., 12 de juny 2019, 1:24, Mei B  va escriure:

> Yes I am already instantiated the form and check has_changed after.
>
> On Tuesday, June 11, 2019 at 8:59:46 AM UTC-7, Gil Obradors wrote:
>>
>> Hi!
>> Have you instanced first de form?
>> Maybe this code from djano help you
>>
>> from django.http import HttpResponseRedirectfrom django.shortcuts import 
>> render
>> from .forms import NameForm
>> def get_name(request):
>> # if this is a POST request we need to process the form data
>> if request.method == 'POST':
>> # create a form instance and populate it with data from the request:
>> form = NameForm(request.POST)
>> # check whether it's valid:
>> if form.is_valid():
>> # process the data in form.cleaned_data as required
>> # ...
>> # redirect to a new URL:
>> return HttpResponseRedirect('/thanks/')
>>
>> # if a GET (or any other method) we'll create a blank form
>> else:
>> form = NameForm()
>>
>> return render(request, 'name.html', {'form': form})
>>
>>
>> Maybe you can check has_changed() after  form=
>> Nameofyourforminformspy(request.POST) ?
>> good luck
>>
>>
>> https://docs.djangoproject.com/en/2.2/topics/forms/
>> https://docs.djangoproject.com/en/2.2/topics/forms/formsets/
>>
>> Missatge de Mei B  del dia dt., 11 de juny 2019 a
>> les 4:33:
>>
>>>if request.method == "POST":
>>> formset = forms.Formset(data=request.POST, initial=initial)
>>> if not formset.has_changed(): #has_changed always returns
>>> true!
>>> msg = "No changes detected."
>>>
>>> if formset.has_changed() and formset.is_valid()
>>> do stuff...
>>> else:
>>> formset = forms.Formset(initial=initial)
>>> formset_get = formset
>>>
>>> What am i doing wrong?
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/23af35da-2f85-4512-9842-6b6811f3988b%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6c34158d-cbd0-4839-b35b-edbfea16a535%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK-JoTSAy9RQULpFUac-rXnMFgQKcMx9QvJPiTQuE%3D7%3DNr%2BzqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: formset has_changed always return true.

2019-06-11 Thread Mei B
Yes I am already instantiated the form and check has_changed after.

On Tuesday, June 11, 2019 at 8:59:46 AM UTC-7, Gil Obradors wrote:
>
> Hi!
> Have you instanced first de form?
> Maybe this code from djano help you
>
> from django.http import HttpResponseRedirectfrom django.shortcuts import 
> render
> from .forms import NameForm
> def get_name(request):
> # if this is a POST request we need to process the form data
> if request.method == 'POST':
> # create a form instance and populate it with data from the request:
> form = NameForm(request.POST)
> # check whether it's valid:
> if form.is_valid():
> # process the data in form.cleaned_data as required
> # ...
> # redirect to a new URL:
> return HttpResponseRedirect('/thanks/')
>
> # if a GET (or any other method) we'll create a blank form
> else:
> form = NameForm()
>
> return render(request, 'name.html', {'form': form})
>
>
> Maybe you can check has_changed() after  form= 
> Nameofyourforminformspy(request.POST) ?
> good luck
>
>
> https://docs.djangoproject.com/en/2.2/topics/forms/
> https://docs.djangoproject.com/en/2.2/topics/forms/formsets/
>
> Missatge de Mei B > del dia dt., 11 de 
> juny 2019 a les 4:33:
>
>>if request.method == "POST":
>> formset = forms.Formset(data=request.POST, initial=initial)
>> if not formset.has_changed(): #has_changed always returns 
>> true! 
>> msg = "No changes detected."
>>
>> if formset.has_changed() and formset.is_valid()
>> do stuff...
>> else:
>> formset = forms.Formset(initial=initial)
>> formset_get = formset
>>
>> What am i doing wrong?
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/23af35da-2f85-4512-9842-6b6811f3988b%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6c34158d-cbd0-4839-b35b-edbfea16a535%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: formset has_changed always return true.

2019-06-11 Thread Gil Obradors
Hi!
Have you instanced first de form?
Maybe this code from djano help you

from django.http import HttpResponseRedirectfrom django.shortcuts import render
from .forms import NameForm
def get_name(request):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = NameForm(request.POST)
# check whether it's valid:
if form.is_valid():
# process the data in form.cleaned_data as required
# ...
# redirect to a new URL:
return HttpResponseRedirect('/thanks/')

# if a GET (or any other method) we'll create a blank form
else:
form = NameForm()

return render(request, 'name.html', {'form': form})


Maybe you can check has_changed() after  form=
Nameofyourforminformspy(request.POST) ?
good luck


https://docs.djangoproject.com/en/2.2/topics/forms/
https://docs.djangoproject.com/en/2.2/topics/forms/formsets/

Missatge de Mei B  del dia dt., 11 de juny 2019 a
les 4:33:

>if request.method == "POST":
> formset = forms.Formset(data=request.POST, initial=initial)
> if not formset.has_changed(): #has_changed always returns
> true!
> msg = "No changes detected."
>
> if formset.has_changed() and formset.is_valid()
> do stuff...
> else:
> formset = forms.Formset(initial=initial)
> formset_get = formset
>
> What am i doing wrong?
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/23af35da-2f85-4512-9842-6b6811f3988b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK-JoTQpoiRmDHMxhGXLDN6ckK6XFNETRukWZGtVRaXEPn6T4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


formset has_changed always return true.

2019-06-10 Thread Mei B
   if request.method == "POST":
formset = forms.Formset(data=request.POST, initial=initial)
if not formset.has_changed(): #has_changed always returns true! 
msg = "No changes detected."

if formset.has_changed() and formset.is_valid()
do stuff...
else:
formset = forms.Formset(initial=initial)
formset_get = formset

What am i doing wrong?

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23af35da-2f85-4512-9842-6b6811f3988b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.