ValueError: (Django1.11.1 python3.6.1 pycharm)

When I am trying to log in with the username and password set in the index.html, the error appeared as follow:

ValueError at /login_action/
The view sign.views.login_action didn't return an HttpResponse object. It                       returned None instead.
Request Method: POST
Request URL:    http://127.0.0.1:8000/login_action/
Django Version: 1.11.1
Exception Type: ValueError
Exception Value:    
The view sign.views.login_action didn't return an HttpResponse object. It returned None instead.
Exception Location: D:\python3.6.1\lib\site-      packages\django\core\handlers\base.py in _get_response, line 198
Python Executable:  D:\python3.6.1\python.exe
Python Version: 3.6.1
Python Path:    
['C:\\Users\\Administrator\\guest',
'D:\\python3.6.1\\python36.zip',
'D:\\python3.6.1\\DLLs',
'D:\\python3.6.1\\lib',
'D:\\python3.6.1',
'D:\\python3.6.1\\lib\\site-packages']
 Server time:   Mon, 12 Jun 2017 08:29:35 +0000

from the hint it said that the valut of HttpResponse object is none

urls.py as follow

from django.conf.urls import url
from django.contrib import admin
from sign import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^index/$',views.index),
url(r'^login_action/$',views.login_action),
]

views.py as follow

from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
return render(request,"index.html")
# 登录函数定义
def login_action(request):
 if request.method == 'post':
    username = request.POST.get('username','')
    password = request.POST.get('password','')
    if username == 'admin'and password == 'admin123':
        return HttpResponse( '恭喜您,登录成功!')
    else:
        return render(request,'index.html',{'error':'用户名或者登录密码错误!'}) 

index.html as follow

<html>
<head>
    <title>欢迎登陆点米年会发布会系统</title>
</head>
<body>
<h1>年会签名系统登陆<br>
    WELCOM TO DIAN MI</h1>
<form method="post" action="/login_action/">
<input name="username" type="text" placeholder="用户名"><br>
<input name="password" type="password" placeholder="登录密码"><br>
    <button id="btn"  type="submit"> 登陆</button>
{{error}}<br>
</form>
</body>
</html>

the screenshot of the traceback of the error

Try changing your test string to uppercase. As you can see in https://docs.djangoproject.com/en/1.11/ref/request-response/#django.http.HttpRequest.method the strings for request.method are not lower case.

python: ValueError: (Django1.11.1 python3.6.1 pycharm), Когда я пытаюсь войти в систему с именем пользователя и паролем, указанными в index.html, возникла ошибка:ValueError at  raise ValueError("cannot use LOCALE flag with a str pattern") ValueError: cannot use LOCALE flag with a str pattern. Process finished with exit code 1 However, when I run behave from the command prompt, it works. This happens under PyCharm 2017.3.3 (Professional Edition) Build #PY-173.4301.16, built on January 11, 2018

Capitalize the request.method, like,

if request.method == 'POST':

ValueError: (Django1.11.1 python3.6.1 pycharm) – 4 Ответа, ValueError: (Django1.11.1 python3.6.1 pycharm). 0. Когда я пытаюсь войти в систему с именем пользователя и паролем, указанными в index.html,  runing on windows10 python 3.6.1 django 1.11.1 . I follow the tutorial sted by steb .but i can't open the admin page and i find HTTP 302 code on my command line.

The check for "POST" on line request.method == 'post' needs to be Uppercase in views.py file.

behave test runner will not start from PyCharm – IDEs Support , LOCALE)) File "/***/project/venv/lib/python3.6/re.py", line 233, in compile raise ValueError("cannot use LOCALE flag with a str pattern") ValueError: cannot Build #PY-173.4301.16, built on January 11, 2018. Licensed to  I use community pycharm and the version of python is 3.6.1, django is 1.11.1. This warning has no affect on running, but I cannot use the IDE's auto complete. Another solution i found is putting @python_2_unicode_compatible decorator on any model.

  1. Better use uppercase letters for method name:

    if request.method == 'POST':

  2. Much better use class based views:

    class LoginAction(View): def post(self, request): your code

Configure a Python interpreter - Help, When you configure a project Python interpreter, you need to specify the path to the Python executable in your system. So, before configuring a project interpreter,​  How to fix python pip install ValueError: ("Expected ',' or end-of-list in", "Expected ',' or end-of-list in",line,"at",line ValueError: ("Expected ',' or en

Running behave features fails with "ValueError: cannot use LOCALE , PyCharm was able to run them in Python 3.5.2. I upgraded to Python LOCALE​)) File "/Users/dave/.pyenv/versions/3.6.0/lib/python3.6/re.py", line 233, in compile raise ValueError("cannot use LOCALE flag with a str pattern") ValueError:  python-3.7.0.amd64.exe Python 64-bit is a dynamic object-oriented programming language that can be used for many kinds of software development . It offers strong support for integration with other languages and tools, comes with extensive standard libraries, and can be learned in a few days.

python, mettendo un {posargs} o [] nel comando invocazione, è possibile eseguire tox -- --fulltrace. un ConftestImportFailure tende a puntare a un altro errore così,  I’m running the following script (from Murach’s Python Programming Ch01), using Python 3.6.1 on OS X Sierra. It runs fine when invoked from the Terminal, and when run inside IDLE, but fails when run within PyCharm Edu 2.0.4, with “ValueError: Currency formatting is not possible using the 'C' locale.”

Implement softmax function with numpy array My current function is , However I get the error: ValueError: operands could not be broadcast together with shapes ValueError: (Django1.11.1 python3.6.1 pycharm). XlsxWriter is a Python module for writing files in the Excel 2007+ XLSX file format. XlsxWriter can be used to write text, numbers, formulas and hyperlinks to multiple worksheets and it supports features such as formatting and many more, including: 100% compatible Excel XLSX files. Full formatting. Merged cells. Defined names. Charts. Autofilters.

Comments
  • Totally disagree on point #2 - class based views have their use cases, but they are in now way "better" than function-based views (just like a hammer is not "better" than a screwdriver).
  • Mapping http methods to appropriate class methods, raising 405 if method is not allowed, that's what View do. Don't see problem with class based view here. When I see pattern 'if request.method == 'XXXX'... I think it's much more readable to implement post method in class based view.
  • @KePe thanks a lot,it did come from the case problem indeed