Forums

Django Rest framework

Hi ! I am trying to run a simple django restframework api but it keep saying that rest_framework is not installed, although it is, I double checked it. Can anyone can help me in this regard? That would mean alot.

My guess is that it's not installed for the version of Python you're actually using? more info here: https://help.pythonanywhere.com/pages/InstallingNewModules

It is of same version I double checked it

Which version of python did you use for your webapp, what command did you use to do the install, and is it installed within a virtualenv?

I have python 3.6 and I use this tutorial to install the virtual enviorment https://help.pythonanywhere.com/pages/FollowingTheDjangoTutorial

a bit far fetched, but did you reload your webapp after setting the virtualenv config for your webapp?

ofcourse I did that

okay- to further debug, perhaps you could give the error traceback and also give the chunk of import code that is causing this error? also- could it be a versioning problem- eg your package doesn't support python3.6? in particular, is this DRF? or perhaps you had mistakenly installed some other rest framework? (please provide a link to the repo/documentation, and also detail what steps you took to install it)

http://www.django-rest-framework.org/#quickstart This is the tutorial I followed. This is the error traceback OperationalError at /check/ no such table: django_session

Request Method: GET Request URL: http://uzair501.pythonanywhere.com/check/ Django Version: 2.0.1 Python Executable: /usr/local/bin/uwsgi Python Version: 3.6.0 Python Path: ['/var/www', '.', '', '/var/www', '/home/uzair501/.virtualenvs/django17/lib/python36.zip', '/home/uzair501/.virtualenvs/django17/lib/python3.6', '/home/uzair501/.virtualenvs/django17/lib/python3.6/lib-dynload', '/usr/lib/python3.6', '/home/uzair501/.virtualenvs/django17/lib/python3.6/site-packages', '/home/uzair501/mysite']

And the code is

from rest_framework.renderers import JSONRenderer from rest_framework.response import Response from rest_framework.views import APIView

class UserCountView(APIView): """ A view that returns the count of active users in JSON. """ renderer_classes = (JSONRenderer, )

def get(self, request, format=None):

Create payload and capture API tokens. Only needed for interest_over_time(), interest_by_region() & related_queries()

    hours = request.GET.get('hours', '')

    user_count =hours
    content = {'user_count': user_count}
    return Response(content)

You need to run syncdb