1

So, I'm very confused, everything worked perfectly in my app, I made some changes that I then reverted in my app. However, this resulted in an error at my login page:

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

This is my url.py file:

from django.conf.urls import *
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from import views
import overtime.views
import schedule.views

urlpatterns = [ 
url(r'^admin/', include(admin.site.urls)),
url(r'^login/', views.login_user),
url(r'^index/', views.index),
url(r'^$', views.index, name='index'),
url(r'^login_success/$', views.login_success, name='login_success'), 
url(r'^overtime/',include('overtime.urls')),
url(r'^schedule/',include('schedule.urls')),       
url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page':     '/login'}),
]

I've tried many vairations of the view import, all resulting in the same syntax error:

from . import views from MonolithEmployee import * import views import MonolithEmployee.views

Every one of these results in a syntax error.

Is it possible this is a problem somewhere else?

This is the view it appears to be quoting:

# 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
3
  • What is on the 40-42 lines in views.py? Commented Dec 27, 2015 at 6:41
  • @AaronLayfield Your 41 line is incomplete....I'm not sure whether you've to paste here or that's the one creating bug.. Commented Dec 27, 2015 at 7:01
  • It was actually the last line in the code as per Serjiks reply, such a silly mistake on my part, but the error wasn't as informative as it could have been. Nevertheless, stupid mistake on my part. Commented Dec 27, 2015 at 7:26

1 Answer 1

1

This is your code:

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

You just left the last paratheses:

def index_BAML(request):
    context = {}
    return render_to_response('index_BAML.html', context, RequestContext(request))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.