Django python syntax error in views.py -


i had issue web application in django :

syntaxerror @ / invalid syntax (views.py, line 98) request method: request url:    http://craft.irisa.fr/ django version: 1.6.5 exception type: syntaxerror exception value:     invalid syntax (views.py, line 98) exception location: /usr/lib/python3.2/importlib/_bootstrap.py in get_code, line 413 python executable:  /root/craft/trunk/sources/env/bin/python python version: 3.2.3 

a part of code of views.py file :

def login_view(request): """ logs user application """  # redirect if user connected if request.user.is_authenticated():     return httpresponseredirect('/')  if request.method == 'post':     # values sent form     login_form = authenticationform(data=request.post)      # log user in if form valid     if login_form.is_valid():         login(request, login_form.get_user())  #line 98 here :          messages.add_message(request, messages.info, u'welcome '+ request.user.username +'!')          next = request.post.get('next','/')         return httpresponseredirect(next) else:     next = request.get.get('next','/')     # create form     login_form = authenticationform()  # display page return render(request, 'taskhandler/login.html', locals()) 

as can see there no syntax error in line , code works, tested it.

but new thing did : have changed django sgbd sqlite3 postgresql.

those troubles appeared when did these modifications understand why python raises such error ! tried add data in database manage.py shell , had no problem !

thanks !

erwann

edit : full error trace back

environment:

request method: request url: http://craft.irisa.fr/  django version: 1.6.5 python version: 3.2.3 installed applications: ('django.contrib.admin',  'django.contrib.auth',  'django.contrib.contenttypes',  'django.contrib.sessions',  'django.contrib.messages',  'django.contrib.staticfiles',  'taskhandler',  'widget_tweaks',  'south') installed middleware: ('django.contrib.sessions.middleware.sessionmiddleware',  'django.middleware.common.commonmiddleware',  'django.middleware.csrf.csrfviewmiddleware',  'django.contrib.auth.middleware.authenticationmiddleware',  'django.contrib.messages.middleware.messagemiddleware',  'django.middleware.clickjacking.xframeoptionsmiddleware')  traceback: file "/root/craft/trunk/sources/env/lib/python3.2/site-packages/django/core/handlers/base.py" in get_response   99.                 resolver_match = resolver.resolve(request.path_info) file "/root/craft/trunk/sources/env/lib/python3.2/site-packages/django/core/urlresolvers.py" in resolve   339.                     sub_match = pattern.resolve(new_path) file "/root/craft/trunk/sources/env/lib/python3.2/site-packages/django/core/urlresolvers.py" in resolve   339.                     sub_match = pattern.resolve(new_path) file "/root/craft/trunk/sources/env/lib/python3.2/site-packages/django/core/urlresolvers.py" in resolve   223.             return resolvermatch(self.callback, args, kwargs, self.name) file "/root/craft/trunk/sources/env/lib/python3.2/site-packages/django/core/urlresolvers.py" in callback   230.         self._callback = get_callable(self._callback_str) file "/root/craft/trunk/sources/env/lib/python3.2/site-packages/django/utils/functional.py" in wrapper   32.         result = func(*args) file "/root/craft/trunk/sources/env/lib/python3.2/site-packages/django/core/urlresolvers.py" in get_callable   97.             mod = import_module(mod_name) file "/usr/lib/python3.2/importlib/__init__.py" in import_module   124.     return _bootstrap._gcd_import(name[level:], package, level) file "/usr/lib/python3.2/importlib/_bootstrap.py" in _gcd_import   821.                     loader.load_module(name) file "/usr/lib/python3.2/importlib/_bootstrap.py" in load_module   436.         return self._load_module(fullname) file "/usr/lib/python3.2/importlib/_bootstrap.py" in decorated   141.             return fxn(self, module, *args, **kwargs) file "/usr/lib/python3.2/importlib/_bootstrap.py" in _load_module   330.         code_object = self.get_code(name) file "/usr/lib/python3.2/importlib/_bootstrap.py" in get_code   413.                                 dont_inherit=true)  exception type: syntaxerror @ / exception value: invalid syntax (views.py, line 98) 

the problem comes python version,

in python 3.2, 'u' encoding character before string cannot used !


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -