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: <django-users@googlegroups.com> on behalf of Ifeanyi Chielo 
<ifeanyi.chi...@unn.edu.ng>
Reply to: <django-users@googlegroups.com>
Date: Saturday, 04 April 2020 at 02:51
To: Django users <django-users@googlegroups.com>
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 <ifeany...@unn.edu.ng> 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)

<form action="/namev/" method="Post">

    {% csrf_token %}    

    {{ form  }}

    <input type="submit" value="Submit">

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

Reply via email to