I have a django 1.4 project with 2 apps: RemoteStorage and WeShouldServer (that one was autocreated on project create and contains urls, settings, etc)
when I try to go to my admin page, I get this error:
SyntaxError at /admin
invalid syntax (views.py, line 33)
and the last line of the stacktrace is:
from RemoteStorage.views import refer
I think it’s a general import error, because I’m importing 3 methods from RemoteStorage.views, and when I change the order I still get an import error on whatever the first import is.
My urls.py:
from django.conf.urls import patterns, include, url
from RemoteStorage.views import refer
from RemoteStorage.views import check_referrals
from RemoteStorage.views import save_item
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'WeShouldServer.views.home', name='home'),
# url(r'^WeShouldServer/', include('WeShouldServer.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'^save-item/', save_item),
url(r'^check-referrals/', check_referrals),
url(r'^refer', refer),
)
my settings.py contains my app:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
**'RemoteStorage',**
)
my views.py:
# Create your views here.
from RemoteStorage.models import Item, Tag, Category, User, Referral
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse
import json
def save_item(request):
try:
print request.GET
# print request.user
i = Item()
i.user = User.objects.get_or_create(email=request.GET['user_email'])[0]
# i.website = request.GET.get('website', "")
# i.comment = request.GET.get('comment', "")
# i.rating = request.GET.get('rating', "")
# i.phone_numger = request.GET.get('phone number', "")
# i.address = request.GET.get('address', "")
i.save()
print i
except Exception as e:
print e.message()
return HttpResponse()
def check_referrals(request):
try:
print request
user = User.objects.get_or_create(email = request.GET.get("user_email", "")[0]
# referrals = Referral.objects.filter(referred_to = user)
# return HttpResponse(content = json.dumps(referrals))
return HttpResponse()
except Exception as e:
print e.message()
def refer(request):
print request
user = User.objects.get_or_create(email = request.GET.get("user_email", "")[0]
refer_to = request.GET.get("email_list", "")
refer_to_list = refer_to.split(",")
for rt in refer_to_list:
r = Referral()
r.data = request.GET.get("item_data", "")
r.referred_by = user
r.referred_to = rt
r.save()
return HttpResponse()
I can’t figure out what’s wrong!
Check the line 32 (33 – 1)
It’s missing a right parens , and should be