Re: Working with forms

2021-06-15 Thread Williams Andy Inc
for now reason its now showing up thanks.   i guess i needed to do hard
refresh with f5 although i was using {% now "U" %}

On Tue, Jun 15, 2021 at 10:10 AM Williams Andy Inc 
wrote:

> class LoginForm(forms.Form):
> username = forms.CharField(
> label="Email or Username",
> widget=forms.TextInput(
> attrs={
> "class": "fas fa-user",
> "placeholder": "f007 Username or Email",
> }
> ),
> ) the class is not showing up but the placeholder shows up without the
> f007
>
> On Tue, Jun 15, 2021 at 10:04 AM Williams Andy Inc 
> wrote:
>
>> Thanks am already trying that,   and using that works for
>> adding placeholder, but then it doesn't add a class,  if it could add i
>> class i could use the font awesome unicode which would have been the
>> easiest solution.
>>
>> On Tue, Jun 15, 2021 at 9:53 AM Lalit Suthar 
>> wrote:
>>
>>> you can try if it can be done with widgets I am not sure
>>> https://docs.djangoproject.com/en/2.2/ref/forms/widgets/
>>>
>>> On Tue, 15 Jun 2021 at 11:24, Williams Andy Inc 
>>> wrote:
>>>
 I would like to know is there any easier way rather than overriding
 super, how do i add icons into the html input eg to have a key icon on the
 password field

 without installing any third party app also.

 is the best solution to render form in html and pass field values to
 django? or is there anyway to manipulate django and insert a text between
 input


 django has this
 >>> id="id_email">


 i want to have this
 >>> id="id_email" >

 --
 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/946421cf-4abf-45cd-b40c-f3639203b43bn%40googlegroups.com
 
 .

>>> --
>>> 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/CAGp2JVHRMgxFF9km7%3D5eQP8wDi3ePuOveyN3vkjJj1hRL0BVJA%40mail.gmail.com
>>> 
>>> .
>>>
>>

-- 
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/CAPCthNJozPG4hNQqN3T-%2B8ALF2rU8k-BVwW%3D54x%3DrFnX4h6kMQ%40mail.gmail.com.


Re: Working with forms

2021-06-15 Thread Williams Andy Inc
class LoginForm(forms.Form):
username = forms.CharField(
label="Email or Username",
widget=forms.TextInput(
attrs={
"class": "fas fa-user",
"placeholder": "f007 Username or Email",
}
),
) the class is not showing up but the placeholder shows up without the
f007

On Tue, Jun 15, 2021 at 10:04 AM Williams Andy Inc 
wrote:

> Thanks am already trying that,   and using that works for
> adding placeholder, but then it doesn't add a class,  if it could add i
> class i could use the font awesome unicode which would have been the
> easiest solution.
>
> On Tue, Jun 15, 2021 at 9:53 AM Lalit Suthar 
> wrote:
>
>> you can try if it can be done with widgets I am not sure
>> https://docs.djangoproject.com/en/2.2/ref/forms/widgets/
>>
>> On Tue, 15 Jun 2021 at 11:24, Williams Andy Inc 
>> wrote:
>>
>>> I would like to know is there any easier way rather than overriding
>>> super, how do i add icons into the html input eg to have a key icon on the
>>> password field
>>>
>>> without installing any third party app also.
>>>
>>> is the best solution to render form in html and pass field values to
>>> django? or is there anyway to manipulate django and insert a text between
>>> input
>>>
>>>
>>> django has this
>>> >> id="id_email">
>>>
>>>
>>> i want to have this
>>> >> id="id_email" >
>>>
>>> --
>>> 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/946421cf-4abf-45cd-b40c-f3639203b43bn%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> 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/CAGp2JVHRMgxFF9km7%3D5eQP8wDi3ePuOveyN3vkjJj1hRL0BVJA%40mail.gmail.com
>> 
>> .
>>
>

-- 
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/CAPCthN%2BOcUujz0BV2RbgC5a%3DDc4YY%3D4H3HOPpW%3DcpOshNvLYuA%40mail.gmail.com.


Re: Working with forms

2021-06-15 Thread Williams Andy Inc
Thanks am already trying that,   and using that works for
adding placeholder, but then it doesn't add a class,  if it could add i
class i could use the font awesome unicode which would have been the
easiest solution.

On Tue, Jun 15, 2021 at 9:53 AM Lalit Suthar 
wrote:

> you can try if it can be done with widgets I am not sure
> https://docs.djangoproject.com/en/2.2/ref/forms/widgets/
>
> On Tue, 15 Jun 2021 at 11:24, Williams Andy Inc 
> wrote:
>
>> I would like to know is there any easier way rather than overriding
>> super, how do i add icons into the html input eg to have a key icon on the
>> password field
>>
>> without installing any third party app also.
>>
>> is the best solution to render form in html and pass field values to
>> django? or is there anyway to manipulate django and insert a text between
>> input
>>
>>
>> django has this
>> 
>>
>>
>> i want to have this
>> > >
>>
>> --
>> 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/946421cf-4abf-45cd-b40c-f3639203b43bn%40googlegroups.com
>> 
>> .
>>
> --
> 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/CAGp2JVHRMgxFF9km7%3D5eQP8wDi3ePuOveyN3vkjJj1hRL0BVJA%40mail.gmail.com
> 
> .
>

-- 
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/CAPCthN%2BZdCPAv48%3DkW%3DV3xRSgo6h_ku-K5xW0%3Dg45-pZwn6kGg%40mail.gmail.com.


Re: Working with forms

2021-06-15 Thread Lalit Suthar
you can try if it can be done with widgets I am not sure
https://docs.djangoproject.com/en/2.2/ref/forms/widgets/

On Tue, 15 Jun 2021 at 11:24, Williams Andy Inc 
wrote:

> I would like to know is there any easier way rather than overriding super,
> how do i add icons into the html input eg to have a key icon on the
> password field
>
> without installing any third party app also.
>
> is the best solution to render form in html and pass field values to
> django? or is there anyway to manipulate django and insert a text between
> input
>
>
> django has this
> 
>
>
> i want to have this
>  >
>
> --
> 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/946421cf-4abf-45cd-b40c-f3639203b43bn%40googlegroups.com
> 
> .
>

-- 
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/CAGp2JVHRMgxFF9km7%3D5eQP8wDi3ePuOveyN3vkjJj1hRL0BVJA%40mail.gmail.com.


Working with forms

2021-06-14 Thread Williams Andy Inc
I would like to know is there any easier way rather than overriding super, 
how do i add icons into the html input eg to have a key icon on the 
password field 

without installing any third party app also.

is the best solution to render form in html and pass field values to 
django? or is there anyway to manipulate django and insert a text between 
input


django has this



i want to have this
>

-- 
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/946421cf-4abf-45cd-b40c-f3639203b43bn%40googlegroups.com.


Re: Working with forms

2020-04-06 Thread waqar khan
hey
I am waqar,
 i have created user form but not working
please solve my problems

admin:
username:-admin
password:-admin

user:
username:-waqar
password:-Test@123



On Mon, Apr 6, 2020 at 10:55 AM Ifeanyi Chielo 
wrote:

> Thanks to you all, I finally resolved the matter. I discovered it was just
> of a mix up of ModelForm and ordinary Django forms, though I enjoyed the
> teething challenges as a new django user
> Dr. Chielo C. Ifeanyi
> Chief Programmer,
> Head Webometrics Section
> ICT Unit, UNN
> 08032366433, 08154804230
> ifeanyi.chi...@unn.edu.ng
> http://www.unn.edu.ng/users/ifeanyichielo 
>
>
>
> On Mon, Apr 6, 2020 at 12:04 AM Maro Okegbero Samuel <
> marookegb...@gmail.com> wrote:
>
>> Port your code back to the initial state it was when you asked the
>> question and on the template change
>>  *{{form}}* to *{{form.as_p}}*
>>
>>
>>> --
>> 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/063525f8-c177-47d6-b849-52240522ae4f%40googlegroups.com
>> 
>> .
>>
> --
> 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/CAOcS8H2%2BtMxewMDAm6s%3DAQB6L%2BYCMTUaPHpyrr5A20u4z1vP2w%40mail.gmail.com
> 
> .
>

-- 
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/CAJO58e7%3Dz%2Bmr7EY7Ef%2BTqfF7UeDGD%3Do_rwwTqRa_bSWZHNHGtw%40mail.gmail.com.
<>


Re: Working with forms

2020-04-05 Thread Ifeanyi Chielo
Thanks to you all, I finally resolved the matter. I discovered it was just
of a mix up of ModelForm and ordinary Django forms, though I enjoyed the
teething challenges as a new django user
Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo 



On Mon, Apr 6, 2020 at 12:04 AM Maro Okegbero Samuel 
wrote:

> Port your code back to the initial state it was when you asked the
> question and on the template change
>  *{{form}}* to *{{form.as_p}}*
>
>
>> --
> 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/063525f8-c177-47d6-b849-52240522ae4f%40googlegroups.com
> 
> .
>

-- 
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/CAOcS8H2%2BtMxewMDAm6s%3DAQB6L%2BYCMTUaPHpyrr5A20u4z1vP2w%40mail.gmail.com.


Re: Working with forms

2020-04-05 Thread Maro Okegbero Samuel
Port your code back to the initial state it was when you asked the question 
and on the template change
 *{{form}}* to *{{form.as_p}}*


>

-- 
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/063525f8-c177-47d6-b849-52240522ae4f%40googlegroups.com.


Re: Working with forms

2020-04-05 Thread Alejandro Avendano
Hi Chielo, 

Actually, save() is a method of the class forms.ModelForm. But your form 
class is extending from forms.Form instead.
Please, modify your form.py as follow:


class NameForm (forms.ModelForm)

class Meta:

model = Namerec

fields = ['your_name’,] 


On Sunday, April 5, 2020 at 5:32:32 PM UTC-4, Ifeanyi Chielo wrote:
>
> Please I am still left with the AttributeError, The form is now publishing 
> fully and very well but it cannot save to the MySQL table. below is the 
> error details and the recent code of view.py
> AttributeError at /namev/
>
> 'NameForm' object has no attribute 'save'
>
> Request Method: POST
> Request URL: http://localhost:8000/namev/
> Django Version: 2.1.5
> Exception Type: AttributeError
> Exception Value: 
>
> 'NameForm' object has no attribute 'save'
>
> Exception Location: C:\Users\IFEANYI CHIELO\divinecrownapp\pages\views.py 
> in Namev_view, line 17
> Python Executable: C:\Users\IFEANYI 
> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
> Python Version: 3.7.2
> Python Path: 
>
> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>  'C:\\Users\\IFEANYI 
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>
> Server time: Sun, 5 Apr 2020 19:46:34 +
> CODE FOR VIEW.PY
> ef Namev_view (request):
> if request.method == 'POST':
> form = NameForm(request.POST)
> if form.is_valid():
> form.save()
> return HttpResponseRedirect('/namev/')
> else:
> form = NameForm()
> return render(request, 'namev.html', {'form': form})
>
> Dr. Chielo C. Ifeanyi
> Chief Programmer,
> Head Webometrics Section
> ICT Unit, UNN
> 08032366433, 08154804230
> ifeany...@unn.edu.ng 
> http://www.unn.edu.ng/users/ifeanyichielo 
>
>
>
> On Sat, Apr 4, 2020 at 3:21 PM Luqman Shofuleji  > wrote:
>
>> Okay, now the new error is that is not seeing that 'form' for the get 
>> request,
>> you need to also add  form = NameForm () before the if statement "if 
>> request.method == 'POST' " to handle the page get request.
>>
>>
>>
>> On Sat, Apr 4, 2020, 12:33 PM Ifeanyi Chielo > > wrote:
>>
>>> Thanks a lot, 
>>> I did as you said and I encountered the error message below:
>>> UnboundLocalError at /namev/ 
>>>
>>> local variable 'form' referenced before assignment
>>>
>>> Request Method: GET 
>>> Request URL: http://localhost:8000/namev/ 
>>> Django Version: 2.1.5 
>>> Exception Type: UnboundLocalError 
>>> Exception Value: 
>>>
>>> local variable 'form' referenced before assignment
>>>
>>> Exception Location: C:\Users\IFEANYI 
>>> CHIELO\divinecrownapp\pages\views.py in Namev_view, line 42 
>>> Python Executable: C:\Users\IFEANYI 
>>> CHIELO\AppData\Local\Programs\Python\Python37\python.exe 
>>> Python Version: 3.7.2 
>>> Python Path: 
>>>
>>> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>>>  'C:\\Users\\IFEANYI '
>>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>>  'C:\\Users\\IFEANYI 
>>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>>  'C:\\Users\\IFEANYI 
>>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>>  'C:\\Users\\IFEANYI '
>>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>>
>>> Server time: Sat, 4 Apr 2020 11:27:07 +
>>> Dr. Chielo C. Ifeanyi
>>> Chief Programmer,
>>> Head Webometrics Section
>>> ICT Unit, UNN
>>> 08032366433, 08154804230
>>> ifeany...@unn.edu.ng 
>>> http://www.unn.edu.ng/users/ifeanyichielo 
>>>
>>>
>>>
>>> On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji >> > wrote:
>>>
 In def Namev_view under views.py, include form in the return parameter 
 and see if that resolves the issue

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



 On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo >>> > wrote:

> Hello,I developed a form with a single field, but this form displays 
> only the submit button at the browser as shown in the image below. Please 
> how can I correct this and also  save the field to the MySQL table.  My 
> code is also shown below
>
> [image: django form.png]
>
> View.py 
>
> from django.http import HttpResponseRedirect
>
> from django.shortcuts import render
>
> from .models import Namerec
>
> from .forms import NameForm
>
> from django.views.generic import TemplateView
>
>  
>
> def HomePageView (request, *args, **kwargs):
>
>  return render(request,"home.html", {})
>
> def 

Re: Working with forms

2020-04-05 Thread Ifeanyi Chielo
Please I am still left with the AttributeError, The form is now publishing
fully and very well but it cannot save to the MySQL table. below is the
error details and the recent code of view.py
AttributeError at /namev/

'NameForm' object has no attribute 'save'

Request Method: POST
Request URL: http://localhost:8000/namev/
Django Version: 2.1.5
Exception Type: AttributeError
Exception Value:

'NameForm' object has no attribute 'save'

Exception Location: C:\Users\IFEANYI CHIELO\divinecrownapp\pages\views.py
in Namev_view, line 17
Python Executable: C:\Users\IFEANYI
CHIELO\AppData\Local\Programs\Python\Python37\python.exe
Python Version: 3.7.2
Python Path:

['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
 'C:\\Users\\IFEANYI '
 'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
 'C:\\Users\\IFEANYI '
 'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']

Server time: Sun, 5 Apr 2020 19:46:34 +
CODE FOR VIEW.PY
ef Namev_view (request):
if request.method == 'POST':
form = NameForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/namev/')
else:
form = NameForm()
return render(request, 'namev.html', {'form': form})

Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo 



On Sat, Apr 4, 2020 at 3:21 PM Luqman Shofuleji 
wrote:

> Okay, now the new error is that is not seeing that 'form' for the get
> request,
> you need to also add  form = NameForm () before the if statement "if
> request.method == 'POST' " to handle the page get request.
>
>
>
> On Sat, Apr 4, 2020, 12:33 PM Ifeanyi Chielo 
> wrote:
>
>> Thanks a lot,
>> I did as you said and I encountered the error message below:
>> UnboundLocalError at /namev/
>>
>> local variable 'form' referenced before assignment
>>
>> Request Method: GET
>> Request URL: http://localhost:8000/namev/
>> Django Version: 2.1.5
>> Exception Type: UnboundLocalError
>> Exception Value:
>>
>> local variable 'form' referenced before assignment
>>
>> Exception Location: C:\Users\IFEANYI
>> CHIELO\divinecrownapp\pages\views.py in Namev_view, line 42
>> Python Executable: C:\Users\IFEANYI
>> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>> Python Version: 3.7.2
>> Python Path:
>>
>> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>
>> Server time: Sat, 4 Apr 2020 11:27:07 +
>> Dr. Chielo C. Ifeanyi
>> Chief Programmer,
>> Head Webometrics Section
>> ICT Unit, UNN
>> 08032366433, 08154804230
>> ifeanyi.chi...@unn.edu.ng
>> http://www.unn.edu.ng/users/ifeanyichielo 
>>
>>
>>
>> On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji 
>> wrote:
>>
>>> In def Namev_view under views.py, include form in the return parameter
>>> and see if that resolves the issue
>>>
>>> return render(request, 'namev.html', {'form':form})
>>>
>>>
>>>
>>> On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
>>> wrote:
>>>
 Hello,I developed a form with a single field, but this form displays
 only the submit button at the browser as shown in the image below. Please
 how can I correct this and also  save the field to the MySQL table.  My
 code is also shown below

 [image: django form.png]

 View.py

 from django.http import HttpResponseRedirect

 from django.shortcuts import render

 from .models import Namerec

 from .forms import NameForm

 from django.views.generic import TemplateView



 def HomePageView (request, *args, **kwargs):

  return render(request,"home.html", {})

 def Namev_view (request):

 if request.method == 'POST':

 form = NameForm (request.POST)

 if NameForm.is_valid():

 NameForm.save()

 context = {

 'form': form

 }

 return render(request, 'namev.html', {})

 form.py

 from .models import Namerec

 from django import forms

 class NameForm(forms.Form):

 your_name = forms.CharField(label='Your name', 

Re: Working with forms

2020-04-05 Thread Ifeanyi Chielo
Thanks
Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo 



On Sun, Apr 5, 2020 at 6:35 PM Joshua Kayode 
wrote:

> Ask questions here for immediate and detailed response djangoafrica.com
> and join the WhatsApp group, a community of professional django developers
>
> Group1
> https://chat.whatsapp.com/IgJcwnZR9sr1Jatc5jnSx9
>
> Group2:
> https://chat.whatsapp.com/DfOLbncTDkIKAvcm5lLm2Y
>
> Django africa is a community of django developers
>
> Excellence for all
>
> On Sun, Apr 5, 2020, 3:22 PM Ifeanyi Chielo 
> wrote:
>
>> I tried using the form. save() but it gave the same error message as
>> with NameForm.save()
>> Dr. Chielo C. Ifeanyi
>> Chief Programmer,
>> Head Webometrics Section
>> ICT Unit, UNN
>> 08032366433, 08154804230
>> ifeanyi.chi...@unn.edu.ng
>> http://www.unn.edu.ng/users/ifeanyichielo 
>>
>>
>>
>> On Sun, Apr 5, 2020 at 3:06 PM KONE GOMPOU LOUA ALASSANE <
>> gompou.k...@uvci.edu.ci> wrote:
>>
>>> Use form. save() because you asigned NameForm to form like
>>>
>>> Le dim. 5 avr. 2020 à 14:04, Ifeanyi Chielo 
>>> a écrit :
>>>
 I added the NameForm.Save() attribute and I had an AttributeError
 message thus:
 AttributeError at /namev/

 type object 'NameForm' has no attribute 'save'

 Request Method: POST
 Request URL: http://localhost:8000/namev/
 Django Version: 2.1.5
 Exception Type: AttributeError
 Exception Value:

 type object 'NameForm' has no attribute 'save'

 Exception Location: C:\Users\IFEANYI
 CHIELO\divinecrownapp\pages\views.py in Namev_view, line 16
 Python Executable: C:\Users\IFEANYI
 CHIELO\AppData\Local\Programs\Python\Python37\python.exe
 Python Version: 3.7.2
 Python Path:

 ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
  'C:\\Users\\IFEANYI '
  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
  'C:\\Users\\IFEANYI 
 CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
  'C:\\Users\\IFEANYI 
 CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
  'C:\\Users\\IFEANYI '
  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']

 Server time: Sun, 5 Apr 2020 13:59:01 +
 Dr. Chielo C. Ifeanyi
 Chief Programmer,
 Head Webometrics Section
 ICT Unit, UNN
 08032366433, 08154804230
 ifeanyi.chi...@unn.edu.ng
 http://www.unn.edu.ng/users/ifeanyichielo 



 On Sun, Apr 5, 2020 at 2:45 PM Alejandro Avendano <
 aavendan...@gmail.com> wrote:

> Hi in the first version, you had:
>  NameForm.is_valid():
>  NameForm.save()
>
> But on the second, version the "NameForm.save()" is missing. This is
> the line of code that save into you database. Maybe, should try putting it
> back...
>
> --
> 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/54d77f2f-58cf-455f-9b11-8857a5ffb32b%40googlegroups.com
> .
>
 --
 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/CAOcS8H0wvTPnK1bmk6Q8XcKZ5R3BMxt_nq-EqkvFwUL1rB0n9Q%40mail.gmail.com
 
 .

>>> --
>>> *La meilleure façon de prédire l’avenir est de le créer. *
>>>
>>>
>>> --
>>> 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/CANoHCsvTpDUzvjUksAq4EET011k1dRmTY4pUG_w8fFO26T9dng%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>> 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.
>> 

Re: Working with forms

2020-04-05 Thread Joshua Kayode
Ask questions here for immediate and detailed response djangoafrica.com and
join the WhatsApp group, a community of professional django developers

Group1
https://chat.whatsapp.com/IgJcwnZR9sr1Jatc5jnSx9

Group2:
https://chat.whatsapp.com/DfOLbncTDkIKAvcm5lLm2Y

Django africa is a community of django developers

Excellence for all

On Sun, Apr 5, 2020, 3:22 PM Ifeanyi Chielo 
wrote:

> I tried using the form. save() but it gave the same error message as with
> NameForm.save()
> Dr. Chielo C. Ifeanyi
> Chief Programmer,
> Head Webometrics Section
> ICT Unit, UNN
> 08032366433, 08154804230
> ifeanyi.chi...@unn.edu.ng
> http://www.unn.edu.ng/users/ifeanyichielo 
>
>
>
> On Sun, Apr 5, 2020 at 3:06 PM KONE GOMPOU LOUA ALASSANE <
> gompou.k...@uvci.edu.ci> wrote:
>
>> Use form. save() because you asigned NameForm to form like
>>
>> Le dim. 5 avr. 2020 à 14:04, Ifeanyi Chielo 
>> a écrit :
>>
>>> I added the NameForm.Save() attribute and I had an AttributeError
>>> message thus:
>>> AttributeError at /namev/
>>>
>>> type object 'NameForm' has no attribute 'save'
>>>
>>> Request Method: POST
>>> Request URL: http://localhost:8000/namev/
>>> Django Version: 2.1.5
>>> Exception Type: AttributeError
>>> Exception Value:
>>>
>>> type object 'NameForm' has no attribute 'save'
>>>
>>> Exception Location: C:\Users\IFEANYI
>>> CHIELO\divinecrownapp\pages\views.py in Namev_view, line 16
>>> Python Executable: C:\Users\IFEANYI
>>> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>>> Python Version: 3.7.2
>>> Python Path:
>>>
>>> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>>>  'C:\\Users\\IFEANYI '
>>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>>  'C:\\Users\\IFEANYI 
>>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>>  'C:\\Users\\IFEANYI 
>>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>>  'C:\\Users\\IFEANYI '
>>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>>
>>> Server time: Sun, 5 Apr 2020 13:59:01 +
>>> Dr. Chielo C. Ifeanyi
>>> Chief Programmer,
>>> Head Webometrics Section
>>> ICT Unit, UNN
>>> 08032366433, 08154804230
>>> ifeanyi.chi...@unn.edu.ng
>>> http://www.unn.edu.ng/users/ifeanyichielo 
>>>
>>>
>>>
>>> On Sun, Apr 5, 2020 at 2:45 PM Alejandro Avendano 
>>> wrote:
>>>
 Hi in the first version, you had:
  NameForm.is_valid():
  NameForm.save()

 But on the second, version the "NameForm.save()" is missing. This is
 the line of code that save into you database. Maybe, should try putting it
 back...

 --
 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/54d77f2f-58cf-455f-9b11-8857a5ffb32b%40googlegroups.com
 .

>>> --
>>> 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/CAOcS8H0wvTPnK1bmk6Q8XcKZ5R3BMxt_nq-EqkvFwUL1rB0n9Q%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>> *La meilleure façon de prédire l’avenir est de le créer. *
>>
>>
>> --
>> 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/CANoHCsvTpDUzvjUksAq4EET011k1dRmTY4pUG_w8fFO26T9dng%40mail.gmail.com
>> 
>> .
>>
> --
> 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/CAOcS8H0FBxYptR5ffgL-cAw08PvWBfEnchYXxAjnsfXhiuRuwQ%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To 

Re: Working with forms

2020-04-05 Thread Ifeanyi Chielo
I tried using the form. save() but it gave the same error message as with
NameForm.save()
Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo 



On Sun, Apr 5, 2020 at 3:06 PM KONE GOMPOU LOUA ALASSANE <
gompou.k...@uvci.edu.ci> wrote:

> Use form. save() because you asigned NameForm to form like
>
> Le dim. 5 avr. 2020 à 14:04, Ifeanyi Chielo  a
> écrit :
>
>> I added the NameForm.Save() attribute and I had an AttributeError message
>> thus:
>> AttributeError at /namev/
>>
>> type object 'NameForm' has no attribute 'save'
>>
>> Request Method: POST
>> Request URL: http://localhost:8000/namev/
>> Django Version: 2.1.5
>> Exception Type: AttributeError
>> Exception Value:
>>
>> type object 'NameForm' has no attribute 'save'
>>
>> Exception Location: C:\Users\IFEANYI
>> CHIELO\divinecrownapp\pages\views.py in Namev_view, line 16
>> Python Executable: C:\Users\IFEANYI
>> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>> Python Version: 3.7.2
>> Python Path:
>>
>> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>
>> Server time: Sun, 5 Apr 2020 13:59:01 +
>> Dr. Chielo C. Ifeanyi
>> Chief Programmer,
>> Head Webometrics Section
>> ICT Unit, UNN
>> 08032366433, 08154804230
>> ifeanyi.chi...@unn.edu.ng
>> http://www.unn.edu.ng/users/ifeanyichielo 
>>
>>
>>
>> On Sun, Apr 5, 2020 at 2:45 PM Alejandro Avendano 
>> wrote:
>>
>>> Hi in the first version, you had:
>>>  NameForm.is_valid():
>>>  NameForm.save()
>>>
>>> But on the second, version the "NameForm.save()" is missing. This is the
>>> line of code that save into you database. Maybe, should try putting it
>>> back...
>>>
>>> --
>>> 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/54d77f2f-58cf-455f-9b11-8857a5ffb32b%40googlegroups.com
>>> .
>>>
>> --
>> 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/CAOcS8H0wvTPnK1bmk6Q8XcKZ5R3BMxt_nq-EqkvFwUL1rB0n9Q%40mail.gmail.com
>> 
>> .
>>
> --
> *La meilleure façon de prédire l’avenir est de le créer. *
>
>
> --
> 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/CANoHCsvTpDUzvjUksAq4EET011k1dRmTY4pUG_w8fFO26T9dng%40mail.gmail.com
> 
> .
>

-- 
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/CAOcS8H0FBxYptR5ffgL-cAw08PvWBfEnchYXxAjnsfXhiuRuwQ%40mail.gmail.com.


Re: Working with forms

2020-04-05 Thread KONE GOMPOU LOUA ALASSANE
Use form. save() because you asigned NameForm to form like

Le dim. 5 avr. 2020 à 14:04, Ifeanyi Chielo  a
écrit :

> I added the NameForm.Save() attribute and I had an AttributeError message
> thus:
> AttributeError at /namev/
>
> type object 'NameForm' has no attribute 'save'
>
> Request Method: POST
> Request URL: http://localhost:8000/namev/
> Django Version: 2.1.5
> Exception Type: AttributeError
> Exception Value:
>
> type object 'NameForm' has no attribute 'save'
>
> Exception Location: C:\Users\IFEANYI CHIELO\divinecrownapp\pages\views.py
> in Namev_view, line 16
> Python Executable: C:\Users\IFEANYI
> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
> Python Version: 3.7.2
> Python Path:
>
> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>  'C:\\Users\\IFEANYI 
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>
> Server time: Sun, 5 Apr 2020 13:59:01 +
> Dr. Chielo C. Ifeanyi
> Chief Programmer,
> Head Webometrics Section
> ICT Unit, UNN
> 08032366433, 08154804230
> ifeanyi.chi...@unn.edu.ng
> http://www.unn.edu.ng/users/ifeanyichielo 
>
>
>
> On Sun, Apr 5, 2020 at 2:45 PM Alejandro Avendano 
> wrote:
>
>> Hi in the first version, you had:
>>  NameForm.is_valid():
>>  NameForm.save()
>>
>> But on the second, version the "NameForm.save()" is missing. This is the
>> line of code that save into you database. Maybe, should try putting it
>> back...
>>
>> --
>> 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/54d77f2f-58cf-455f-9b11-8857a5ffb32b%40googlegroups.com
>> .
>>
> --
> 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/CAOcS8H0wvTPnK1bmk6Q8XcKZ5R3BMxt_nq-EqkvFwUL1rB0n9Q%40mail.gmail.com
> 
> .
>
-- 
*La meilleure façon de prédire l’avenir est de le créer. *

-- 
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/CANoHCsvTpDUzvjUksAq4EET011k1dRmTY4pUG_w8fFO26T9dng%40mail.gmail.com.


Re: Working with forms

2020-04-05 Thread Ifeanyi Chielo
I added the NameForm.Save() attribute and I had an AttributeError message
thus:
AttributeError at /namev/

type object 'NameForm' has no attribute 'save'

Request Method: POST
Request URL: http://localhost:8000/namev/
Django Version: 2.1.5
Exception Type: AttributeError
Exception Value:

type object 'NameForm' has no attribute 'save'

Exception Location: C:\Users\IFEANYI CHIELO\divinecrownapp\pages\views.py
in Namev_view, line 16
Python Executable: C:\Users\IFEANYI
CHIELO\AppData\Local\Programs\Python\Python37\python.exe
Python Version: 3.7.2
Python Path:

['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
 'C:\\Users\\IFEANYI '
 'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
 'C:\\Users\\IFEANYI '
 'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']

Server time: Sun, 5 Apr 2020 13:59:01 +
Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo 



On Sun, Apr 5, 2020 at 2:45 PM Alejandro Avendano 
wrote:

> Hi in the first version, you had:
>  NameForm.is_valid():
>  NameForm.save()
>
> But on the second, version the "NameForm.save()" is missing. This is the
> line of code that save into you database. Maybe, should try putting it
> back...
>
> --
> 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/54d77f2f-58cf-455f-9b11-8857a5ffb32b%40googlegroups.com
> .
>

-- 
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/CAOcS8H0wvTPnK1bmk6Q8XcKZ5R3BMxt_nq-EqkvFwUL1rB0n9Q%40mail.gmail.com.


Re: Working with forms

2020-04-05 Thread Alejandro Avendano
Hi in the first version, you had:
 NameForm.is_valid():
 NameForm.save()

But on the second, version the "NameForm.save()" is missing. This is the line 
of code that save into you database. Maybe, should try putting it back...

-- 
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/54d77f2f-58cf-455f-9b11-8857a5ffb32b%40googlegroups.com.


Re: Working with forms

2020-04-04 Thread Ifeanyi Chielo
Thanks a lot, I believe I am close to the result. I did exactly what you
instructed and another error appeared thus:
ValueError at /namev/

The view pages.views.Namev_view didn't return an HttpResponse object.
It returned None instead.

Request Method: GET
Request URL: http://localhost:8000/namev/
Django Version: 2.1.5
Exception Type: ValueError
Exception Value:

The view pages.views.Namev_view didn't return an HttpResponse object.
It returned None instead.

Exception Location: C:\Users\IFEANYI
CHIELO\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py
in _get_response, line 137
Python Executable: C:\Users\IFEANYI
CHIELO\AppData\Local\Programs\Python\Python37\python.exe
Python Version: 3.7.2
Python Path:

['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
 'C:\\Users\\IFEANYI '
 'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
 'C:\\Users\\IFEANYI '
 'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']

Server time: Sat, 4 Apr 2020 15:27:13 +Meanwhile the current code for
the view is shown below:
from django.http import HttpResponseRedirect
from django.shortcuts import render
from .models import Namerec
from .forms import NameForm
from django.views.generic import TemplateView

def HomePageView (request, *args, **kwargs):
 return render(request,"home.html", {})
def Namev_view (request):
form = NameForm ()
# 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 NameForm.is_valid():
NameForm.save()
context = {
'form': form
}
return render(request, 'namev.html', {'form':form})

Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo 



On Sat, Apr 4, 2020 at 3:21 PM Luqman Shofuleji 
wrote:

> Okay, now the new error is that is not seeing that 'form' for the get
> request,
> you need to also add  form = NameForm () before the if statement "if
> request.method == 'POST' " to handle the page get request.
>
>
>
> On Sat, Apr 4, 2020, 12:33 PM Ifeanyi Chielo 
> wrote:
>
>> Thanks a lot,
>> I did as you said and I encountered the error message below:
>> UnboundLocalError at /namev/
>>
>> local variable 'form' referenced before assignment
>>
>> Request Method: GET
>> Request URL: http://localhost:8000/namev/
>> Django Version: 2.1.5
>> Exception Type: UnboundLocalError
>> Exception Value:
>>
>> local variable 'form' referenced before assignment
>>
>> Exception Location: C:\Users\IFEANYI
>> CHIELO\divinecrownapp\pages\views.py in Namev_view, line 42
>> Python Executable: C:\Users\IFEANYI
>> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>> Python Version: 3.7.2
>> Python Path:
>>
>> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>
>> Server time: Sat, 4 Apr 2020 11:27:07 +
>> Dr. Chielo C. Ifeanyi
>> Chief Programmer,
>> Head Webometrics Section
>> ICT Unit, UNN
>> 08032366433, 08154804230
>> ifeanyi.chi...@unn.edu.ng
>> http://www.unn.edu.ng/users/ifeanyichielo 
>>
>>
>>
>> On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji 
>> wrote:
>>
>>> In def Namev_view under views.py, include form in the return parameter
>>> and see if that resolves the issue
>>>
>>> return render(request, 'namev.html', {'form':form})
>>>
>>>
>>>
>>> On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
>>> wrote:
>>>
 Hello,I developed a form with a single field, but this form displays
 only the submit button at the browser as shown in the image below. Please
 how can I correct this and also  save the field to the MySQL table.  My
 code is also shown below

 [image: django form.png]

 View.py

 from django.http import HttpResponseRedirect

 from django.shortcuts import render

 from .models import Namerec

 from .forms import NameForm

 from django.views.generic import TemplateView



 def HomePageView (request, *args, **kwargs):

  return 

Re: Working with forms

2020-04-04 Thread Luqman Shofuleji
Okay, now the new error is that is not seeing that 'form' for the get
request,
you need to also add  form = NameForm () before the if statement "if
request.method == 'POST' " to handle the page get request.



On Sat, Apr 4, 2020, 12:33 PM Ifeanyi Chielo 
wrote:

> Thanks a lot,
> I did as you said and I encountered the error message below:
> UnboundLocalError at /namev/
>
> local variable 'form' referenced before assignment
>
> Request Method: GET
> Request URL: http://localhost:8000/namev/
> Django Version: 2.1.5
> Exception Type: UnboundLocalError
> Exception Value:
>
> local variable 'form' referenced before assignment
>
> Exception Location: C:\Users\IFEANYI CHIELO\divinecrownapp\pages\views.py
> in Namev_view, line 42
> Python Executable: C:\Users\IFEANYI
> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
> Python Version: 3.7.2
> Python Path:
>
> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>  'C:\\Users\\IFEANYI 
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>
> Server time: Sat, 4 Apr 2020 11:27:07 +
> Dr. Chielo C. Ifeanyi
> Chief Programmer,
> Head Webometrics Section
> ICT Unit, UNN
> 08032366433, 08154804230
> ifeanyi.chi...@unn.edu.ng
> http://www.unn.edu.ng/users/ifeanyichielo 
>
>
>
> On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji 
> wrote:
>
>> In def Namev_view under views.py, include form in the return parameter
>> and see if that resolves the issue
>>
>> return render(request, 'namev.html', {'form':form})
>>
>>
>>
>> On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
>> wrote:
>>
>>> Hello,I developed a form with a single field, but this form displays
>>> only the submit button at the browser as shown in the image below. Please
>>> how can I correct this and also  save the field to the MySQL table.  My
>>> code is also shown below
>>>
>>> [image: django form.png]
>>>
>>> View.py
>>>
>>> from django.http import HttpResponseRedirect
>>>
>>> from django.shortcuts import render
>>>
>>> from .models import Namerec
>>>
>>> from .forms import NameForm
>>>
>>> from django.views.generic import TemplateView
>>>
>>>
>>>
>>> def HomePageView (request, *args, **kwargs):
>>>
>>>  return render(request,"home.html", {})
>>>
>>> def Namev_view (request):
>>>
>>> if request.method == 'POST':
>>>
>>> form = NameForm (request.POST)
>>>
>>> if NameForm.is_valid():
>>>
>>> NameForm.save()
>>>
>>> context = {
>>>
>>> 'form': form
>>>
>>> }
>>>
>>> return render(request, 'namev.html', {})
>>>
>>> form.py
>>>
>>> from .models import Namerec
>>>
>>> from django import forms
>>>
>>> class NameForm(forms.Form):
>>>
>>> your_name = forms.CharField(label='Your name', max_length=100)
>>>
>>> template (namev.htlm)
>>>
>>> 
>>>
>>> {% csrf_token %}
>>>
>>> {{ form  }}
>>>
>>> 
>>>
>>> 
>>>
>>>
>>>
>>>
>>>
>>> Model.py
>>>
>>> from django.db import models
>>>
>>> class Namerec(models.Model):
>>>
>>> your_name = models.CharField(max_length=30)
>>>
>>>
>>>
>>> --
>>> 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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> 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/CAHyB84rUTDyiba%2B%2Bvk%3DJFuRN7CPBPTpso2JvyBc28Q4gG-faYg%40mail.gmail.com
>> 
>> .
>>
> --
> 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/CAOcS8H1YiVcABEXBEa5-qEu4V4NBeGfY3PkFa%3DYCf9OEdUAO-Q%40mail.gmail.com
> 

Re: Working with forms

2020-04-04 Thread Ifeanyi Chielo
Screen shorts of codes available above

Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo 



On Sat, Apr 4, 2020 at 12:35 PM KONE GOMPOU LOUA ALASSANE <
gompou.k...@uvci.edu.ci> wrote:

> Send screen short
>
> Le sam. 4 avr. 2020 à 11:33, Ifeanyi Chielo  a
> écrit :
>
>> Thanks a lot,
>> I did as you said and I encountered the error message below:
>> UnboundLocalError at /namev/
>>
>> local variable 'form' referenced before assignment
>>
>> Request Method: GET
>> Request URL: http://localhost:8000/namev/
>> Django Version: 2.1.5
>> Exception Type: UnboundLocalError
>> Exception Value:
>>
>> local variable 'form' referenced before assignment
>>
>> Exception Location: C:\Users\IFEANYI
>> CHIELO\divinecrownapp\pages\views.py in Namev_view, line 42
>> Python Executable: C:\Users\IFEANYI
>> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>> Python Version: 3.7.2
>> Python Path:
>>
>> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>
>> Server time: Sat, 4 Apr 2020 11:27:07 +
>> Dr. Chielo C. Ifeanyi
>> Chief Programmer,
>> Head Webometrics Section
>> ICT Unit, UNN
>> 08032366433, 08154804230
>> ifeanyi.chi...@unn.edu.ng
>> http://www.unn.edu.ng/users/ifeanyichielo 
>>
>>
>>
>> On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji 
>> wrote:
>>
>>> In def Namev_view under views.py, include form in the return parameter
>>> and see if that resolves the issue
>>>
>>> return render(request, 'namev.html', {'form':form})
>>>
>>>
>>>
>>> On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
>>> wrote:
>>>
 Hello,I developed a form with a single field, but this form displays
 only the submit button at the browser as shown in the image below. Please
 how can I correct this and also  save the field to the MySQL table.  My
 code is also shown below

 [image: django form.png]

 View.py

 from django.http import HttpResponseRedirect

 from django.shortcuts import render

 from .models import Namerec

 from .forms import NameForm

 from django.views.generic import TemplateView



 def HomePageView (request, *args, **kwargs):

  return render(request,"home.html", {})

 def Namev_view (request):

 if request.method == 'POST':

 form = NameForm (request.POST)

 if NameForm.is_valid():

 NameForm.save()

 context = {

 'form': form

 }

 return render(request, 'namev.html', {})

 form.py

 from .models import Namerec

 from django import forms

 class NameForm(forms.Form):

 your_name = forms.CharField(label='Your name', max_length=100)

 template (namev.htlm)

 

 {% csrf_token %}

 {{ form  }}

 

 





 Model.py

 from django.db import models

 class Namerec(models.Model):

 your_name = models.CharField(max_length=30)



 --
 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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
 
 .

>>> --
>>> 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/CAHyB84rUTDyiba%2B%2Bvk%3DJFuRN7CPBPTpso2JvyBc28Q4gG-faYg%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and 

Re: Working with forms

2020-04-04 Thread KONE GOMPOU LOUA ALASSANE
But i thing that this problem is due to bad indentation

Le sam. 4 avr. 2020 à 11:34, KONE GOMPOU LOUA ALASSANE <
gompou.k...@uvci.edu.ci> a écrit :

> Send screen short
>
> Le sam. 4 avr. 2020 à 11:33, Ifeanyi Chielo  a
> écrit :
>
>> Thanks a lot,
>> I did as you said and I encountered the error message below:
>> UnboundLocalError at /namev/
>>
>> local variable 'form' referenced before assignment
>>
>> Request Method: GET
>> Request URL: http://localhost:8000/namev/
>> Django Version: 2.1.5
>> Exception Type: UnboundLocalError
>> Exception Value:
>>
>> local variable 'form' referenced before assignment
>>
>> Exception Location: C:\Users\IFEANYI
>> CHIELO\divinecrownapp\pages\views.py in Namev_view, line 42
>> Python Executable: C:\Users\IFEANYI
>> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>> Python Version: 3.7.2
>> Python Path:
>>
>> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>  'C:\\Users\\IFEANYI 
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>  'C:\\Users\\IFEANYI '
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>
>> Server time: Sat, 4 Apr 2020 11:27:07 +
>> Dr. Chielo C. Ifeanyi
>> Chief Programmer,
>> Head Webometrics Section
>> ICT Unit, UNN
>> 08032366433, 08154804230
>> ifeanyi.chi...@unn.edu.ng
>> http://www.unn.edu.ng/users/ifeanyichielo 
>>
>>
>>
>> On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji 
>> wrote:
>>
>>> In def Namev_view under views.py, include form in the return parameter
>>> and see if that resolves the issue
>>>
>>> return render(request, 'namev.html', {'form':form})
>>>
>>>
>>>
>>> On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
>>> wrote:
>>>
 Hello,I developed a form with a single field, but this form displays
 only the submit button at the browser as shown in the image below. Please
 how can I correct this and also  save the field to the MySQL table.  My
 code is also shown below

 [image: django form.png]

 View.py

 from django.http import HttpResponseRedirect

 from django.shortcuts import render

 from .models import Namerec

 from .forms import NameForm

 from django.views.generic import TemplateView



 def HomePageView (request, *args, **kwargs):

  return render(request,"home.html", {})

 def Namev_view (request):

 if request.method == 'POST':

 form = NameForm (request.POST)

 if NameForm.is_valid():

 NameForm.save()

 context = {

 'form': form

 }

 return render(request, 'namev.html', {})

 form.py

 from .models import Namerec

 from django import forms

 class NameForm(forms.Form):

 your_name = forms.CharField(label='Your name', max_length=100)

 template (namev.htlm)

 

 {% csrf_token %}

 {{ form  }}

 

 





 Model.py

 from django.db import models

 class Namerec(models.Model):

 your_name = models.CharField(max_length=30)



 --
 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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
 
 .

>>> --
>>> 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/CAHyB84rUTDyiba%2B%2Bvk%3DJFuRN7CPBPTpso2JvyBc28Q4gG-faYg%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>> 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
>> 

Re: Working with forms

2020-04-04 Thread KONE GOMPOU LOUA ALASSANE
Send screen short

Le sam. 4 avr. 2020 à 11:33, Ifeanyi Chielo  a
écrit :

> Thanks a lot,
> I did as you said and I encountered the error message below:
> UnboundLocalError at /namev/
>
> local variable 'form' referenced before assignment
>
> Request Method: GET
> Request URL: http://localhost:8000/namev/
> Django Version: 2.1.5
> Exception Type: UnboundLocalError
> Exception Value:
>
> local variable 'form' referenced before assignment
>
> Exception Location: C:\Users\IFEANYI CHIELO\divinecrownapp\pages\views.py
> in Namev_view, line 42
> Python Executable: C:\Users\IFEANYI
> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
> Python Version: 3.7.2
> Python Path:
>
> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>  'C:\\Users\\IFEANYI 
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>
> Server time: Sat, 4 Apr 2020 11:27:07 +
> Dr. Chielo C. Ifeanyi
> Chief Programmer,
> Head Webometrics Section
> ICT Unit, UNN
> 08032366433, 08154804230
> ifeanyi.chi...@unn.edu.ng
> http://www.unn.edu.ng/users/ifeanyichielo 
>
>
>
> On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji 
> wrote:
>
>> In def Namev_view under views.py, include form in the return parameter
>> and see if that resolves the issue
>>
>> return render(request, 'namev.html', {'form':form})
>>
>>
>>
>> On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
>> wrote:
>>
>>> Hello,I developed a form with a single field, but this form displays
>>> only the submit button at the browser as shown in the image below. Please
>>> how can I correct this and also  save the field to the MySQL table.  My
>>> code is also shown below
>>>
>>> [image: django form.png]
>>>
>>> View.py
>>>
>>> from django.http import HttpResponseRedirect
>>>
>>> from django.shortcuts import render
>>>
>>> from .models import Namerec
>>>
>>> from .forms import NameForm
>>>
>>> from django.views.generic import TemplateView
>>>
>>>
>>>
>>> def HomePageView (request, *args, **kwargs):
>>>
>>>  return render(request,"home.html", {})
>>>
>>> def Namev_view (request):
>>>
>>> if request.method == 'POST':
>>>
>>> form = NameForm (request.POST)
>>>
>>> if NameForm.is_valid():
>>>
>>> NameForm.save()
>>>
>>> context = {
>>>
>>> 'form': form
>>>
>>> }
>>>
>>> return render(request, 'namev.html', {})
>>>
>>> form.py
>>>
>>> from .models import Namerec
>>>
>>> from django import forms
>>>
>>> class NameForm(forms.Form):
>>>
>>> your_name = forms.CharField(label='Your name', max_length=100)
>>>
>>> template (namev.htlm)
>>>
>>> 
>>>
>>> {% csrf_token %}
>>>
>>> {{ form  }}
>>>
>>> 
>>>
>>> 
>>>
>>>
>>>
>>>
>>>
>>> Model.py
>>>
>>> from django.db import models
>>>
>>> class Namerec(models.Model):
>>>
>>> your_name = models.CharField(max_length=30)
>>>
>>>
>>>
>>> --
>>> 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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> 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/CAHyB84rUTDyiba%2B%2Bvk%3DJFuRN7CPBPTpso2JvyBc28Q4gG-faYg%40mail.gmail.com
>> 
>> .
>>
> --
> 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/CAOcS8H1YiVcABEXBEa5-qEu4V4NBeGfY3PkFa%3DYCf9OEdUAO-Q%40mail.gmail.com
> 
> .
>
-- 
*La meilleure façon de prédire l’avenir est de le créer. *

-- 
You received this 

Re: Working with forms

2020-04-04 Thread Ifeanyi Chielo
Thanks a lot,
I did as you said and I encountered the error message below:
UnboundLocalError at /namev/

local variable 'form' referenced before assignment

Request Method: GET
Request URL: http://localhost:8000/namev/
Django Version: 2.1.5
Exception Type: UnboundLocalError
Exception Value:

local variable 'form' referenced before assignment

Exception Location: C:\Users\IFEANYI CHIELO\divinecrownapp\pages\views.py
in Namev_view, line 42
Python Executable: C:\Users\IFEANYI
CHIELO\AppData\Local\Programs\Python\Python37\python.exe
Python Version: 3.7.2
Python Path:

['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
 'C:\\Users\\IFEANYI '
 'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
 'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
 'C:\\Users\\IFEANYI '
 'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']

Server time: Sat, 4 Apr 2020 11:27:07 +
Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo 



On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji 
wrote:

> In def Namev_view under views.py, include form in the return parameter
> and see if that resolves the issue
>
> return render(request, 'namev.html', {'form':form})
>
>
>
> On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
> wrote:
>
>> Hello,I developed a form with a single field, but this form displays only
>> the submit button at the browser as shown in the image below. Please how
>> can I correct this and also  save the field to the MySQL table.  My code is
>> also shown below
>>
>> [image: django form.png]
>>
>> View.py
>>
>> from django.http import HttpResponseRedirect
>>
>> from django.shortcuts import render
>>
>> from .models import Namerec
>>
>> from .forms import NameForm
>>
>> from django.views.generic import TemplateView
>>
>>
>>
>> def HomePageView (request, *args, **kwargs):
>>
>>  return render(request,"home.html", {})
>>
>> def Namev_view (request):
>>
>> if request.method == 'POST':
>>
>> form = NameForm (request.POST)
>>
>> if NameForm.is_valid():
>>
>> NameForm.save()
>>
>> context = {
>>
>> 'form': form
>>
>> }
>>
>> return render(request, 'namev.html', {})
>>
>> form.py
>>
>> from .models import Namerec
>>
>> from django import forms
>>
>> class NameForm(forms.Form):
>>
>> your_name = forms.CharField(label='Your name', max_length=100)
>>
>> template (namev.htlm)
>>
>> 
>>
>> {% csrf_token %}
>>
>> {{ form  }}
>>
>> 
>>
>> 
>>
>>
>>
>>
>>
>> Model.py
>>
>> from django.db import models
>>
>> class Namerec(models.Model):
>>
>> your_name = models.CharField(max_length=30)
>>
>>
>>
>> --
>> 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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
>> 
>> .
>>
> --
> 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/CAHyB84rUTDyiba%2B%2Bvk%3DJFuRN7CPBPTpso2JvyBc28Q4gG-faYg%40mail.gmail.com
> 
> .
>

-- 
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/CAOcS8H1YiVcABEXBEa5-qEu4V4NBeGfY3PkFa%3DYCf9OEdUAO-Q%40mail.gmail.com.


Re: Working with forms

2020-04-04 Thread Luqman Shofuleji
In def Namev_view under views.py, include form in the return parameter and
see if that resolves the issue

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



On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
wrote:

> Hello,I developed a form with a single field, but this form displays only
> the submit button at the browser as shown in the image below. Please how
> can I correct this and also  save the field to the MySQL table.  My code is
> also shown below
>
> [image: django form.png]
>
> View.py
>
> from django.http import HttpResponseRedirect
>
> from django.shortcuts import render
>
> from .models import Namerec
>
> from .forms import NameForm
>
> from django.views.generic import TemplateView
>
>
>
> def HomePageView (request, *args, **kwargs):
>
>  return render(request,"home.html", {})
>
> def Namev_view (request):
>
> if request.method == 'POST':
>
> form = NameForm (request.POST)
>
> if NameForm.is_valid():
>
> NameForm.save()
>
> context = {
>
> 'form': form
>
> }
>
> return render(request, 'namev.html', {})
>
> form.py
>
> from .models import Namerec
>
> from django import forms
>
> class NameForm(forms.Form):
>
> your_name = forms.CharField(label='Your name', max_length=100)
>
> template (namev.htlm)
>
> 
>
> {% csrf_token %}
>
> {{ form  }}
>
> 
>
> 
>
>
>
>
>
> Model.py
>
> from django.db import models
>
> class Namerec(models.Model):
>
> your_name = models.CharField(max_length=30)
>
>
>
> --
> 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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
> 
> .
>

-- 
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/CAHyB84rUTDyiba%2B%2Bvk%3DJFuRN7CPBPTpso2JvyBc28Q4gG-faYg%40mail.gmail.com.


Re: Working with forms

2020-04-04 Thread Ifeanyi Chielo
Yes the app name is already included in the settings.py

Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo <http://www.unn.edu.ng>



On Sat, Apr 4, 2020 at 6:35 AM Bruckner de Villiers <
bruckner.devilli...@gmail.com> wrote:

> Please share code for home.html & urls.py.  Also have you included the app
> name in the settings.py?
>
> Thanks,
>
>
>
> Bruckner de Villiers
>
> 083 625 1086
>
>
>
> *From: * on behalf of Ifeanyi Chielo <
> ifeanyi.chi...@unn.edu.ng>
> *Reply to: *
> *Date: *Saturday, 04 April 2020 at 02:51
> *To: *Django users 
> *Subject: *Re: Working with forms
>
>
>
> Thanks Victor,
>
> I did it and it does not make any cnange
>
>
> On Saturday, April 4, 2020 at 1:41:19 AM UTC+1, victor awakan wrote:
>
> In the form template tag, shouldn’t it be {{ form.as_p}} tag?
>
>
>
> On Sat 4. Apr 2020 at 3.35, Ifeanyi Chielo  wrote:
>
> Hello,I developed a form with a single field, but this form displays only
> the submit button at the browser as shown in the image below. Please how
> can I correct this and also  save the field to the MySQL table.  My code is
> also shown below
>
>
>
> View.py
>
> from django.http import HttpResponseRedirect
>
> from django.shortcuts import render
>
> from .models import Namerec
>
> from .forms import NameForm
>
> from django.views.generic import TemplateView
>
>
>
> def HomePageView (request, *args, **kwargs):
>
>  return render(request,"home.html", {})
>
> def Namev_view (request):
>
> if request.method == 'POST':
>
> form = NameForm (request.POST)
>
> if NameForm.is_valid():
>
> NameForm.save()
>
> context = {
>
> 'form': form
>
> }
>
> return render(request, 'namev.html', {})
>
> form.py
>
> from .models import Namerec
>
> from django import forms
>
> class NameForm(forms.Form):
>
> your_name = forms.CharField(label='Your name', max_length=100)
>
> template (namev.htlm)
>
> 
>
> {% csrf_token %}
>
> {{ form  }}
>
> 
>
> 
>
>
>
>
>
> Model.py
>
> from django.db import models
>
> class Namerec(models.Model):
>
> your_name = models.CharField(max_length=30)
>
>
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> --
> 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/9825aec7-7e87-4d4a-80f9-634cb9e4dd59%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9825aec7-7e87-4d4a-80f9-634cb9e4dd59%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> --
> 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/E47A5C26-9855-4ED7-86AD-3F427A2E88B7%40gmail.com
> <https://groups.google.com/d/msgid/django-users/E47A5C26-9855-4ED7-86AD-3F427A2E88B7%40gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAOcS8H1Zj33iOTxb4KQkJsVqcTZo68W0wtzjJQ4we9nz5axx9A%40mail.gmail.com.


Re: Working with forms

2020-04-04 Thread Ifeanyi Chielo
Hello,
Here are the codes:

View

from django.http import HttpResponseRedirect

from django.shortcuts import render

from .models import Namerec

from .forms import NameForm

from django.views.generic import TemplateView



def HomePageView (request, *args, **kwargs):

 return render(request,"home.html", {})



project url

from django.contrib import admin

from django.urls import path, include



urlpatterns = [

path('admin/', admin.site.urls),

path('', include('pages.urls')),

]





App url

urlpatterns = [

path('', HomePageView, name = 'home'),

path('namev/', Namev_view),

#path('', HomePageView),

#path('namev/', Nameview_view),



]

 Note, I have not written any code at home.html template and it is
rendering well

Dr. Chielo C. Ifeanyi
Chief Programmer,
Head Webometrics Section
ICT Unit, UNN
08032366433, 08154804230
ifeanyi.chi...@unn.edu.ng
http://www.unn.edu.ng/users/ifeanyichielo <http://www.unn.edu.ng>



On Sat, Apr 4, 2020 at 6:35 AM Bruckner de Villiers <
bruckner.devilli...@gmail.com> wrote:

> Please share code for home.html & urls.py.  Also have you included the app
> name in the settings.py?
>
> Thanks,
>
>
>
> Bruckner de Villiers
>
> 083 625 1086
>
>
>
> *From: * on behalf of Ifeanyi Chielo <
> ifeanyi.chi...@unn.edu.ng>
> *Reply to: *
> *Date: *Saturday, 04 April 2020 at 02:51
> *To: *Django users 
> *Subject: *Re: Working with forms
>
>
>
> Thanks Victor,
>
> I did it and it does not make any cnange
>
>
> On Saturday, April 4, 2020 at 1:41:19 AM UTC+1, victor awakan wrote:
>
> In the form template tag, shouldn’t it be {{ form.as_p}} tag?
>
>
>
> On Sat 4. Apr 2020 at 3.35, Ifeanyi Chielo  wrote:
>
> Hello,I developed a form with a single field, but this form displays only
> the submit button at the browser as shown in the image below. Please how
> can I correct this and also  save the field to the MySQL table.  My code is
> also shown below
>
>
>
> View.py
>
> from django.http import HttpResponseRedirect
>
> from django.shortcuts import render
>
> from .models import Namerec
>
> from .forms import NameForm
>
> from django.views.generic import TemplateView
>
>
>
> def HomePageView (request, *args, **kwargs):
>
>  return render(request,"home.html", {})
>
> def Namev_view (request):
>
> if request.method == 'POST':
>
> form = NameForm (request.POST)
>
> if NameForm.is_valid():
>
> NameForm.save()
>
> context = {
>
> 'form': form
>
> }
>
> return render(request, 'namev.html', {})
>
> form.py
>
> from .models import Namerec
>
> from django import forms
>
> class NameForm(forms.Form):
>
> your_name = forms.CharField(label='Your name', max_length=100)
>
> template (namev.htlm)
>
> 
>
> {% csrf_token %}
>
> {{ form  }}
>
> 
>
> 
>
>
>
>
>
> Model.py
>
> from django.db import models
>
> class Namerec(models.Model):
>
> your_name = models.CharField(max_length=30)
>
>
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> --
> 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/9825aec7-7e87-4d4a-80f9-634cb9e4dd59%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9825aec7-7e87-4d4a-80f9-634cb9e4dd59%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> --
> 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/E47A5C26-9855-4ED7-86AD-3F427A2E88B7%40gmail.com
> <https://groups.google.com/d/msgid/django-users/E47A5C26-9855-4ED7-86AD-3F427A2E88B7%40gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAOcS8H3QEdWtT%3DRn4P%2B9LFA%3DjTPQHgCi3V_BYwbOsc6DHcD%2BRQ%40mail.gmail.com.


Re: Working with forms

2020-04-03 Thread Bruckner de Villiers
Please share code for home.html & urls.py.  Also have you included the app name 
in the settings.py?

Thanks,

 

Bruckner de Villiers

083 625 1086

 

From:  on behalf of Ifeanyi Chielo 

Reply to: 
Date: Saturday, 04 April 2020 at 02:51
To: Django users 
Subject: Re: Working with forms

 

Thanks Victor, 

I did it and it does not make any cnange


On Saturday, April 4, 2020 at 1:41:19 AM UTC+1, victor awakan wrote:

In the form template tag, shouldn’t it be {{ form.as_p}} tag?

 

On Sat 4. Apr 2020 at 3.35, Ifeanyi Chielo  wrote:

Hello,I developed a form with a single field, but this form displays only the 
submit button at the browser as shown in the image below. Please how can I 
correct this and also  save the field to the MySQL table.  My code is also 
shown below

 

View.py 

from django.http import HttpResponseRedirect

from django.shortcuts import render

from .models import Namerec

from .forms import NameForm

from django.views.generic import TemplateView

 

def HomePageView (request, *args, **kwargs):

 return render(request,"home.html", {})

def Namev_view (request):

if request.method == 'POST':

form = NameForm (request.POST)

if NameForm.is_valid():

NameForm.save()

context = {

'form': form

}

return render(request, 'namev.html', {})

form.py

from .models import Namerec

from django import forms

class NameForm(forms.Form):

your_name = forms.CharField(label='Your name', max_length=100)

template (namev.htlm)



{% csrf_token %}

{{ form  }}





 


 

Model.py 

from django.db import models

class Namerec(models.Model):

your_name = models.CharField(max_length=30)

   

 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com.

-- 
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/9825aec7-7e87-4d4a-80f9-634cb9e4dd59%40googlegroups.com.


-- 
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/E47A5C26-9855-4ED7-86AD-3F427A2E88B7%40gmail.com.


Re: Working with forms

2020-04-03 Thread Ifeanyi Chielo
Thanks Victor, 
I did it and it does not make any cnange

On Saturday, April 4, 2020 at 1:41:19 AM UTC+1, victor awakan wrote:
>
> In the form template tag, shouldn’t it be {{ form.as_p}} tag?
>
> On Sat 4. Apr 2020 at 3.35, Ifeanyi Chielo  > wrote:
>
>> Hello,I developed a form with a single field, but this form displays only 
>> the submit button at the browser as shown in the image below. Please how 
>> can I correct this and also  save the field to the MySQL table.  My code is 
>> also shown below
>>
>> [image: django form.png]
>>
>> View.py 
>>
>> from django.http import HttpResponseRedirect
>>
>> from django.shortcuts import render
>>
>> from .models import Namerec
>>
>> from .forms import NameForm
>>
>> from django.views.generic import TemplateView
>>
>>  
>>
>> def HomePageView (request, *args, **kwargs):
>>
>>  return render(request,"home.html", {})
>>
>> def Namev_view (request):
>>
>> if request.method == 'POST':
>>
>> form = NameForm (request.POST)
>>
>> if NameForm.is_valid():
>>
>> NameForm.save()
>>
>> context = {
>>
>> 'form': form
>>
>> }
>>
>> return render(request, 'namev.html', {})
>>
>> form.py
>>
>> from .models import Namerec
>>
>> from django import forms
>>
>> class NameForm(forms.Form):
>>
>> your_name = forms.CharField(label='Your name', max_length=100)
>>
>> template (namev.htlm)
>>
>> 
>>
>> {% csrf_token %}
>>
>> {{ form  }}
>>
>> 
>>
>> 
>>
>>  
>>
>>  
>>
>> Model.py 
>>
>> from django.db import models
>>
>> class Namerec(models.Model):
>>
>> your_name = models.CharField(max_length=30)
>>
>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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/9825aec7-7e87-4d4a-80f9-634cb9e4dd59%40googlegroups.com.


Re: Working with forms

2020-04-03 Thread victor awakan
In the form template tag, shouldn’t it be {{ form.as_p}} tag?

On Sat 4. Apr 2020 at 3.35, Ifeanyi Chielo 
wrote:

> Hello,I developed a form with a single field, but this form displays only
> the submit button at the browser as shown in the image below. Please how
> can I correct this and also  save the field to the MySQL table.  My code is
> also shown below
>
> [image: django form.png]
>
> View.py
>
> from django.http import HttpResponseRedirect
>
> from django.shortcuts import render
>
> from .models import Namerec
>
> from .forms import NameForm
>
> from django.views.generic import TemplateView
>
>
>
> def HomePageView (request, *args, **kwargs):
>
>  return render(request,"home.html", {})
>
> def Namev_view (request):
>
> if request.method == 'POST':
>
> form = NameForm (request.POST)
>
> if NameForm.is_valid():
>
> NameForm.save()
>
> context = {
>
> 'form': form
>
> }
>
> return render(request, 'namev.html', {})
>
> form.py
>
> from .models import Namerec
>
> from django import forms
>
> class NameForm(forms.Form):
>
> your_name = forms.CharField(label='Your name', max_length=100)
>
> template (namev.htlm)
>
> 
>
> {% csrf_token %}
>
> {{ form  }}
>
> 
>
> 
>
>
>
>
>
> Model.py
>
> from django.db import models
>
> class Namerec(models.Model):
>
> your_name = models.CharField(max_length=30)
>
>
>
> --
> 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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com
> 
> .
>

-- 
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/CAAipwd8nHw9WeLmhG2Eo7o5NztkJZ7xWSLa8d%3D-1_yiVjw6CrQ%40mail.gmail.com.


Working with forms

2020-04-03 Thread Ifeanyi Chielo
Hello,I developed a form with a single field, but this form displays only 
the submit button at the browser as shown in the image below. Please how 
can I correct this and also  save the field to the MySQL table.  My code is 
also shown below

[image: django form.png]

View.py 

from django.http import HttpResponseRedirect

from django.shortcuts import render

from .models import Namerec

from .forms import NameForm

from django.views.generic import TemplateView

 

def HomePageView (request, *args, **kwargs):

 return render(request,"home.html", {})

def Namev_view (request):

if request.method == 'POST':

form = NameForm (request.POST)

if NameForm.is_valid():

NameForm.save()

context = {

'form': form

}

return render(request, 'namev.html', {})

form.py

from .models import Namerec

from django import forms

class NameForm(forms.Form):

your_name = forms.CharField(label='Your name', max_length=100)

template (namev.htlm)



{% csrf_token %}

{{ form  }}





 

 

Model.py 

from django.db import models

class Namerec(models.Model):

your_name = models.CharField(max_length=30)

   

-- 
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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups.com.


Re: working with forms , problem !!!

2011-12-12 Thread Alagappan
Adding the csrf context processor would fix it. Refer to
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/ for more details.
As suggested, you can add your own render_to_response() wrapper, if you are
likely to use it often.


-- 
*Regards,*
*Alagappan Ramu
(http://alagappan.co.in)
*

-- 
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.



Re: Working with Forms and Session Variables

2009-02-11 Thread Daniel Roseman

On Feb 11, 4:11 pm, gbd  wrote:
> Another point (sorry I should have said this in my original post)
>
> My form is bound
> i.e. in my view
> form = RecipeForm(request.POST)
> I don't believe that I can use initial in this case?
>
> please let me know if I've misunderstood
>
> thanks again!
>
> On Feb 11, 11:06 am, gbd  wrote:
>
> > Thanks!
>
> > A follow up question -
>
> > Would i exclude that field in my class description?
> > i.e.
>
> > class RecipeForm(forms.ModelForm):
> >         class Meta:
> >                 model = Recipes
> >                 exclude = ('user',)
>

The standard Django idiom for a form view is like this:

if request.method='POST':
form = MyForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('whatever')
else:
form = MyForm(initial=initial_data)
return render_to_response(template, {'form':form})

So the form is only bound the second time through, when you return
with a POST. The first time through, when you initially render the
form for the user to fill in, you don't have a POST, and the form
isn't bound. It's there - the second-to-last line in my example - that
you should pass the initial dictionary.

And in response to your other question, no you shouldn't exclude that
from the form, or this method won't work.

There is an alternative method, though. If you don't want the user
field to appear at all, exclude the field, don't bother with initial,
and set the user on save. So in line 4 above, you would do this:
instance = form.save(commit=False)
instance.user = request.user
instance.save()

--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Working with Forms and Session Variables

2009-02-11 Thread gbd

Thanks for all your help it's much appreciated. I will work with both
methods and see if i can get them to work!

Thanks again

On Feb 11, 12:13 pm, Daniel Roseman 
wrote:
> On Feb 11, 4:11 pm, gbd  wrote:
>
>
>
> > Another point (sorry I should have said this in my original post)
>
> > My form is bound
> > i.e. in my view
> > form = RecipeForm(request.POST)
> > I don't believe that I can use initial in this case?
>
> > please let me know if I've misunderstood
>
> > thanks again!
>
> > On Feb 11, 11:06 am, gbd  wrote:
>
> > > Thanks!
>
> > > A follow up question -
>
> > > Would i exclude that field in my class description?
> > > i.e.
>
> > > class RecipeForm(forms.ModelForm):
> > >         class Meta:
> > >                 model = Recipes
> > >                 exclude = ('user',)
>
> The standard Django idiom for a form view is like this:
>
> if request.method='POST':
>     form = MyForm(request.POST)
>     if form.is_valid():
>         form.save()
>         return HttpResponseRedirect('whatever')
> else:
>     form = MyForm(initial=initial_data)
> return render_to_response(template, {'form':form})
>
> So the form is only bound the second time through, when you return
> with a POST. The first time through, when you initially render the
> form for the user to fill in, you don't have a POST, and the form
> isn't bound. It's there - the second-to-last line in my example - that
> you should pass the initial dictionary.
>
> And in response to your other question, no you shouldn't exclude that
> from the form, or this method won't work.
>
> There is an alternative method, though. If you don't want the user
> field to appear at all, exclude the field, don't bother with initial,
> and set the user on save. So in line 4 above, you would do this:
>         instance = form.save(commit=False)
>         instance.user = request.user
>         instance.save()
>
> --
> DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Working with Forms and Session Variables

2009-02-11 Thread gbd

Another point (sorry I should have said this in my original post)

My form is bound
i.e. in my view
form = RecipeForm(request.POST)
I don't believe that I can use initial in this case?

please let me know if I've misunderstood

thanks again!



On Feb 11, 11:06 am, gbd  wrote:
> Thanks!
>
> A follow up question -
>
> Would i exclude that field in my class description?
> i.e.
>
> class RecipeForm(forms.ModelForm):
>         class Meta:
>                 model = Recipes
>                 exclude = ('user',)
>
> On Feb 11, 10:54 am, Daniel Roseman 
> wrote:
>
> > On Feb 11, 3:20 pm, gbd  wrote:
>
> > > Hello,
>
> > > I am presently working on my first Django project and seemed to be a
> > > little stuck concerning session variables and forms.
>
> > > This is how my app is laid out:
> > > - user logs in and is directed to a "you have successfully logged in"
> > > page
> > > - user is then redirected to what i am hoping to be an account page
> > > where they can submit information using a form
> > > - this form is a ModelForm (which I believe makes a difference)
> > > - since the user has already logged in I would like the user field on
> > > this form to be defaulted
>
> > > This is where I am having trouble, where do I set this default and how
> > > would I do this?
>
> > > I've tried to figure it out on my own but i've gotten nowhere
>
> > > Thanks!
>
> > In the view, when you instantiate the form, you can pass a dictionary
> > of initial values, which you can populate from the session:
>
> > initial_data = {'user_id': request.user.id }
> > form = MyModelForm(initial=initial_data)
>
> > --
> > DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Working with Forms and Session Variables

2009-02-11 Thread gbd

Thanks!

A follow up question -

Would i exclude that field in my class description?
i.e.

class RecipeForm(forms.ModelForm):
class Meta:
model = Recipes
exclude = ('user',)

On Feb 11, 10:54 am, Daniel Roseman 
wrote:
> On Feb 11, 3:20 pm, gbd  wrote:
>
>
>
> > Hello,
>
> > I am presently working on my first Django project and seemed to be a
> > little stuck concerning session variables and forms.
>
> > This is how my app is laid out:
> > - user logs in and is directed to a "you have successfully logged in"
> > page
> > - user is then redirected to what i am hoping to be an account page
> > where they can submit information using a form
> > - this form is a ModelForm (which I believe makes a difference)
> > - since the user has already logged in I would like the user field on
> > this form to be defaulted
>
> > This is where I am having trouble, where do I set this default and how
> > would I do this?
>
> > I've tried to figure it out on my own but i've gotten nowhere
>
> > Thanks!
>
> In the view, when you instantiate the form, you can pass a dictionary
> of initial values, which you can populate from the session:
>
> initial_data = {'user_id': request.user.id }
> form = MyModelForm(initial=initial_data)
>
> --
> DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Working with Forms and Session Variables

2009-02-11 Thread Daniel Roseman

On Feb 11, 3:20 pm, gbd  wrote:
> Hello,
>
> I am presently working on my first Django project and seemed to be a
> little stuck concerning session variables and forms.
>
> This is how my app is laid out:
> - user logs in and is directed to a "you have successfully logged in"
> page
> - user is then redirected to what i am hoping to be an account page
> where they can submit information using a form
> - this form is a ModelForm (which I believe makes a difference)
> - since the user has already logged in I would like the user field on
> this form to be defaulted
>
> This is where I am having trouble, where do I set this default and how
> would I do this?
>
> I've tried to figure it out on my own but i've gotten nowhere
>
> Thanks!

In the view, when you instantiate the form, you can pass a dictionary
of initial values, which you can populate from the session:

initial_data = {'user_id': request.user.id }
form = MyModelForm(initial=initial_data)

--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Working with Forms and Session Variables

2009-02-11 Thread gbd

Hello,

I am presently working on my first Django project and seemed to be a
little stuck concerning session variables and forms.

This is how my app is laid out:
- user logs in and is directed to a "you have successfully logged in"
page
- user is then redirected to what i am hoping to be an account page
where they can submit information using a form
- this form is a ModelForm (which I believe makes a difference)
- since the user has already logged in I would like the user field on
this form to be defaulted

This is where I am having trouble, where do I set this default and how
would I do this?

I've tried to figure it out on my own but i've gotten nowhere

Thanks!




--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---