-2

I've created a method that received a request with parameters as well as 2 additional parameters in the url the url looks like this:

url(r'^courseid=(?P<course_id>\d+)/user_id=(?P<user_id>\d+)/$', views.user_data_on_course, name='userDataOnCourse'),

the function looks like this

def user_data_on_course(request, course_id, user_id):
   if request.method == 'POST':
       <Extract the data and save to DB>
   else if request.method == 'GET':
       <Return the data>

when I add the else if request.method == 'GET': I get error 500 on every method that is being called, and the DEBUG info is Exception Value: invalid syntax (views.py, line 308) which is the line of the else if

what am I doing wrong?

liv a
  • 3,232
  • 6
  • 35
  • 76

2 Answers2

2

In python use elif instead of else if

Here the doc : https://docs.python.org/2/tutorial/controlflow.html

UnX
  • 421
  • 3
  • 6
0

The python if statement structure is:

if a:
    b
elif c:
    d
else:
    e
JackGibbs
  • 230
  • 2
  • 9