Search code examples
pythondjangopython-3.xpythonanywhere

ViewDoesNotExist when view is there on Django 1.9.1


Hello I beginner in python and even more in django framework.

I started reading djangobook.com and have setup a server on pythonanywhere. I made my first view which was something like hello_world and it worked. On the next step I made another view that will show the current date and time, but I split both views in different files called hello_world.py and current_datetime.py and they are in package called my_views. But when I uploaded the files both of them are throwing ViewDoesNotExist exception and for 2 hours I cannot find any solution.

Here is my django project and you can see the files in it -> https://github.com/SuperSane95/supersane_djangoapp

I really don't know what is causing the problem and I need your help, people.


Solution

  • The issue is that you haven't pointed your url routes to the methods, just the library they are in:

    Make your url patterns like this:

    urlpatterns = patterns('',
                       url(r'^hello/$', hello_world.hello),
                       url(r'^time/$', current_datetime.current_datetime),
                       )
    

    That said this is really outdated and may not properly work on Django, I'd suggest using the most recent Django tutorial and starting again.