0

I've made a basic application with the Django framework and PythonAnywhere is not liking my code for some reason.

When I ran the autoconfiguration for manual setup, I got an error that Django rest framework was required and the setup exited prematurely. The error was:

ModuleNotFoundError: No module named 'rest_framework'

I got into the venv and finished setup, though there were a few issues here and there. I manually installed djangorestframework from Github so that anything would show up, but I am still getting an unknown error that I have traced back to the routers.py file. The content of the error can be found on:

nebrethar.pythonanywhere.com

A sample of my routers.py file is as follows:

    def get_routes(self, viewset):

        known_actions = list(flatten([route.mapping.values() for 
        route in self.routes if isinstance(route, Route)]))
        extra_actions = *****viewset.get_extra_actions()*****

        not_allowed = [
            action.__name__ for action in extra_actions
            if action.__name__ in known_actions
        ]

I have starred out the section that causes the error. Most of the fixes I've run into have been installing packages but I've been stumped.

  • Are you sure that 'rest_framework' is in your INSTALLED_APPS – Goran Apr 07 '18 at 18:32
  • You need to show more code than that. Apparently `viewset` is a function object, rather than whatever it is supposed to be; you should show the code (presumably in urls.py) where you actually define the viewset, rather than code from routers.py which is built in to DRF itself. – Daniel Roseman Apr 07 '18 at 18:42

0 Answers0