Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8260561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:07:39+00:00 2026-06-08T03:07:39+00:00

I am new to django. setup is ubuntu server. Have created a project, database,

  • 0

I am new to django. setup is ubuntu server. Have created a project, database, edited the settings.py, views.py, urls.py files. Created a template folder and a main_page.html file. All this from django:visual quickpro book. I keep getting a name error when I run the development server. It says the name ‘main_page’ is not defined.

Here is the urls.py;

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

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
   (r'^$', main_page),
    # Examples:
    # url(r'^$', 'chapter2.views.home', name='home'),
    # url(r'^chapter2/', include('chapter2.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:
    # url(r'^admin/', include(admin.site.urls)),
)

Here is the views.py;

# Create your views here

from django.http import HttpResponse

from django.template import Context
from django.template.loader import get_template

def main_page(request):
  template = get_template('main_page.html')
  variables = Context({'head_title': 'First Application',
    'page_title': "Welcome to our first application',
    'page_body': "This is our first application, pretty good, eh?'})
       output = template.render(variables)
  return HttpResponse(output)

I figure there is a syntax error in the book, it was catered to much for windows or I just am missing something obvious. I have worked on it for hours, but don’t see the problem. I hope someone can help.

Thanks,
Bobby

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:07:40+00:00Added an answer on June 8, 2026 at 3:07 am

    At the top of your urls.py, add this:

    import app.views   # where "app" is the name of your app
    

    Then change your line in urls.py to be this:

    (r'^$', app.views.main_page),
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to both Django and Cappuccino. I have a Django site setup and
I'm new to django and trying to get user authentication working. I have setup
I create a new Django app (not project) called Bussinesses, then add following class
While I am studying the new django docs on class-based views, I notice this
I have a general question about the new Django 1.3 static file framework. I
I'm working on a new Django project, and the client wants to feature content
I'm new with Django and python. I have a problem. Is there a way,
I'm new to Django and setting up my first site. I have a Share
i'm trying to setup django on nginx + gunicorn on a centos6 server (firewall
I have a new project and can't get django_nose set up correctly. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.