1

I plan on having several different apps inside my django project, each for a new technology I want to play around with. As I work on each on, I want to have the root URL path redirect to the project I'm working on.

Directory Structure:

backyard/
    my_project/
        views.py
    backyard/
        urls.py

backyard/backyard/urls.py:

from django.conf.urls import patterns, include, url
from django.shortcuts import redirect

urlpatterns = patterns('',

    url(r'^$', redirect('my_app/')),
    url(r'^my_project/$', 'my_project.views.homepage'),

)

backyard/my_project/views.py

def homepage(request):
    return render_to_response('my_project/index.html', {'data':data})

When I access the page at http:machine-name:8000/ I get an error saying The included urlconf backyard.urls doesn't have any patterns in it I most definitely have URLs in my urls.py, what is the issue?

smilebomb
  • 5,123
  • 8
  • 49
  • 81

1 Answers1

6

A URLconf needs to map regexes to views -- the redirect function doesn't return a view; rather, it returns an HttpResponse. You can look at this question for an example of how to define a redirect directly in the URLconf.

Community
  • 1
  • 1
Ismail Badawi
  • 36,054
  • 7
  • 85
  • 97