Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 语法错误,调试在URL.py中显示错误?_Python_Django_Url_Views_Django Urls - Fatal编程技术网

Python 语法错误,调试在URL.py中显示错误?

Python 语法错误,调试在URL.py中显示错误?,python,django,url,views,django-urls,Python,Django,Url,Views,Django Urls,所以,我很困惑,在我的应用程序中一切都很好,我做了一些更改,然后在我的应用程序中恢复。但是,这导致我的登录页面出现错误: SyntaxError at /login/ invalid syntax (views.py, line 41) Request Method: GET Request URL: http://X.X.X.X:8000/login/ Django Version: 1.8 Exception Type: SyntaxError Exception Value:

所以,我很困惑,在我的应用程序中一切都很好,我做了一些更改,然后在我的应用程序中恢复。但是,这导致我的登录页面出现错误:

SyntaxError at /login/
invalid syntax (views.py, line 41)
Request Method: GET
Request URL:    http://X.X.X.X:8000/login/
Django Version: 1.8
Exception Type: SyntaxError
Exception Value:    
invalid syntax (views.py, line 41)
Exception Location: /path/to-app/project-name/app (same name as project)/urls.py in <module>, line 22
我尝试了多次视图导入,都导致了相同的语法错误:

从。导入视图 从MonolithEmployee导入* 导入视图 导入MonolithEmployee.views

所有这些都会导致语法错误

这可能是其他地方的问题吗

这是它似乎引用的视图:

# user login
@login_required
def login_user(request):
    if request.user.is_authenticated():
        pass
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)
        if user is not None:
            if user.is_active:
                login(request, user)
                return redirect("login_success")
        else:
            form = LoginForm()
            context = {'form': form}
            return render_to_response('login.html', context, context_instance=RequestContext(request))
    else:
        ''' user is not submitting the form, show the login form '''
        form = LoginForm()
        context = {'form': form}
        return render_to_response('login.html', context,     context_instance=RequestContext(request))

def login_success(request):
    """
    Redirects users based on the group they are in 
    """
    if request.user.groups.filter(name="BAML").exists():
        return redirect("")
    else:
        return redirect("index")

def logout_user(request):
    logout(request)
    return HttpResponseRedirect('/login/')

def index(request):
    context = {}
    return render_to_response('index.html', context, RequestContext(request))

def index_BAML(request):
    context = {}
    return render_to_response('.html', context, RequestContext(request
这是您的代码:

def index_BAML(request):
    context = {}
    return render_to_response('index_BAML.html', context, RequestContext(request
你刚才留下了最后的比喻:

def index_BAML(request):
    context = {}
    return render_to_response('index_BAML.html', context, RequestContext(request))

views.py中的40-42行是什么?@AaronLayfield您的41行不完整…我不确定您是否要粘贴到这里,还是粘贴到了创建bug的那一行。根据Serjiks的回复,这实际上是代码中的最后一行,我犯了一个愚蠢的错误,但错误的信息量并没有达到应有的程度。然而,我犯了愚蠢的错误。
def index_BAML(request):
    context = {}
    return render_to_response('index_BAML.html', context, RequestContext(request))