user1940321
user1940321

Reputation:

'module' object has no attribute 'main_page'

After running the command ./manage.py runserver I'm getting the following error. I know it's for sure got something to do with the Urls.py (r'^$',views.main_page), but can't seem to figure out what needs changes... Any advice?

Urls.py

from django.conf.urls import patterns, include, url
from django.contrib import admin
from content import views

admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'crosstalk.views.home', name='home'),
# url(r'^crosstalk/', include('crosstalk.foo.urls')),

# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^$',views.main_page),
(r'^admin/', include(admin.site.urls)),
(r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'templates/js'}),
(r"^(\d+)/$", "post"),
)

models.py

from django.db import models
from datetime   import datetime

class Cover(models.Model):  
title = models.CharField(max_length=200)
slug = models.SlugField(unique=True)
text = models.TextField()
posts = models.ManyToManyField('Post')
def __unicode__(self):
    return self.title

class Post(models.Model):  
title = models.CharField(max_length=200)
slug = models.SlugField(unique=True)
date = models.DateTimeField(default=datetime.now)
text = models.TextField()

def __unicode__(self):
    return self.title

Upvotes: 2

Views: 305

Answers (2)

jonmorgan
jonmorgan

Reputation: 2610

You haven't defined main_page in views.py. Do that, including the appropriate handling, and it should work.

It should look something like this:

def main_page(request):
    # view stuff goes here
    return something

Upvotes: 1

Rohan
Rohan

Reputation: 53366

Check you have main_page in your views.py. Better way would be to put it in quotes as

(r'^$','content.views.main_page')

assuming that content is your app name.

Upvotes: 0

Related Questions