Hi.

Because indentation is broken it's hard to say exact problem location but
in your view some code path doesn't return anything and thus you see error
about returning None.

ke 10. heinäk. 2019 klo 21.05 Desh Deepak <deshdeepak...@gmail.com>
kirjoitti:

> Hi, I want to insert some data in MysqlDatabase from the template (HTML
> file).
> but, it shows error like this...
>
> The view Naturalgreen.views.index didn't return an HttpResponse object. It 
> returned None instead.
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/
> Django Version: 2.0
> Exception Type: ValueError
> Exception Value:
>
>
> Python Version: 3.7.3
> Django Version: 2.0
>
>
> (views.py)
> from django.shortcuts import render
> from django.http import HttpResponse
> from Naturalgreen.models import signin
>
>
> # Create your views here.
>
> def index(request):
> if request.method == 'POST':
> if request.POST.get('username') and request.POST.get('password'):
> POST = naturalgreen_signin()
> POST.username = request.POST.get('username')
> POST.password = request.POST.get('password')
> post.save()
> return HttpResponseRedirect(request, "index.html")
> else:
> return HttpResponse(request, 'home.html')
>
>
> (models.py)
>
> from django.db import models
>
> # Create your models here.
> class signin(models.Model):
> username = models.CharField(max_length=200, blank=False)
> password = models.CharField(max_length=150, blank=False)
>
>
> class Meta:
> db_table ="naturalgree_signin"
>
>
> (index.html)
> {% load static %}
> <!DOCTYPE html>
> <html lang="en">
> <head>
> <meta charset="utf-8">
> <title>Natural Green</title>
>
> </head>
>
> <body>
> <div>
> <h2>Please Enter your Login Details !</h2>
> <form method="POST" action="{% url 'home' %}" name="">
> {% csrf_token %}
> Username: <input type="text" name="username">
> Password: <input type="text" name="password">
> <button type="submit" value="naturalgreen_signin">Login</button>
> </form>
> </div>
>
> </body>
>
> </html>
>
>
>
> thanks:
> Desh Deepak
> +917011101001
> deshdeepak...@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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJ0m4xjVuP91YmjZ423UZfgiRoPtg3GvgsRgZR_KMc2vOgFXBQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJ0m4xjVuP91YmjZ423UZfgiRoPtg3GvgsRgZR_KMc2vOgFXBQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91odRt0T0Vc_izSbRHV3J%2BshVquKb4-__6bfvjaMSeUuyHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to