PythonAnywhere Django 404 Page Not Found for Homepage
Question: I know there is a similar post like this one. I've reviewed it and it is quite
different from what I'm experiencing at the moment on
[Pythonanywhere.com](http://www.pythonanywhere.com)

I'm trying to deploy my rango tutorial project that I completed through
tangowithdjango.com onto Pythonanywhere.com. When I try to open the site (url
is ragzputin.pythonanywhere.com), I get this page:

![enter image description here](http://i.stack.imgur.com/c6EQV.png)

Here's my urls.py file for my project:

    
    
    from django.conf.urls.defaults import *
    from django.conf import settings
    
    # Uncomment the next two lines to enable the admin:
    from django.contrib import admin
    admin.autodiscover()
    urlpatterns = patterns('',
    
        url(r'^rango/', include('rango.urls')),
        url(r'^admin/', include(admin.site.urls)),
    )
    
    if settings.DEBUG:
    urlpatterns += patterns(
        'django.views.static',
        (r'media/(?P<path>.*)',
        'serve',
         {'document_root': settings.MEDIA_ROOT}), )
    

If you guys need some extra information, here's my app urls.py (app name is
rango):

    
    
    from django.conf.urls import patterns, url
    from rango import views
    
    urlpatterns = patterns('',
        url(r'^$', views.index, name="index"),
        url(r'^about/$', views.about, name="about"),
        url(r'^add_category/$', views.add_category, name="add_category"),
        url(r'^category/(?P<category_name_url>\w+)/add_page/$', views.add_page,   name="add_page"),
        url(r'^category/(?P<category_name_url>\w+)/$', views.category, name="category"),
        url(r'^register/$', views.register, name="register"),
        url(r'^login/$', views.user_login, name="login"),
        url(r'^restricted/$', views.restricted, name="restricted"),
        url(r'^logout/$', views.user_logout, name="logout"),
        url(r'^profile/$', views.profile, name="profile"),
        url(r'^goto/$', views.track_url, name="track_url"),
        url(r'^like_category/$', views.like_category, name="like_category"),
        url(r'^suggest_category/$', views.suggest_category, name="suggest_category"),
        url(r'^auto_add_page/$', views.auto_add_page, name="auto_add_page"),
    )
    

As you can see from the 404 page above, the server is not able to get to the
main page which starts with '^rango/'. Any suggestions?


Answer: You should add url for home page into the project's urls.py:

    
    
    urlpatterns = patterns('',
        url(r'^$', 'rango.views.index', name="index"),
        url(r'^rango/', include('rango.urls')),
        url(r'^admin/', include(admin.site.urls)),
    )
    

And don't forget to remove the same (first) url from `rango/urls.py`.

The other option is to add redirect from `/` to `/rango/`. If you choose this
option then project's urls.py should be:

    
    
    from django.views.generic.base import RedirectView
    
    urlpatterns = patterns('',
        url(r'^$', RedirectView.as_view(url='/rango/')),
        url(r'^rango/', include('rango.urls')),
        url(r'^admin/', include(admin.site.urls)),
    )
    

Of course in this case `rango/urls.py` should be untouched.

