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

  • Home
  • SEARCH
  • 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 4552670
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:49:41+00:00 2026-05-21T16:49:41+00:00

In Django, is it not possible to have multiple views imports from the urls.py?

  • 0

In Django, is it not possible to have multiple views imports from the urls.py?

For example, I have the following code in urls.py:

from mysite.books import views
from mysite.contact import views

urlpatterns = patterns('',
    (r'^contact/$', views.contact),
    (r'^search/$', views.search),
)

However, the server displays an error unless I disable one of the couples. So my questions are threefold:

1) Is it not possible to have multiple import views statements?
2) How to get around this?
3) What is best practice for where to put all your views.py? One file? Multiple files? etc.

Thank you.

  • 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-05-21T16:49:42+00:00Added an answer on May 21, 2026 at 4:49 pm

    1) Yes it is.

    2)

    from mysite.books import views as books_views
    from mysite.contact import views as contact_views
    
    urlpatterns = patterns('',
        (r'^contact/$', contact_views.contact),
        (r'^search/$', books_views.search),
    )
    

    3) Per Django docs, “This code can live anywhere you want, as long as it’s on your Python path.”. I keep all the app views in app/views.py

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in Django: import locale locale.setlocale( locale.LC_ALL, '' ) def
I have the following multi-table inheritance situation: from django.db import Models class Partner(models.Model): #
This is using the web app framework, not Django. The following template code is
django-userena does not have a views.py file. It uses instead html files, i would
I currently have multiple Django sites running from one Apache server through WSGI and
I'm new to Django, and I'm not sure what I want is possible: I
I create a new Django app (not project) called Bussinesses, then add following class
I would like to use the logout function from Django but not sure how
I am doing geolocation, and Django does not have a PointField. So, I am
Aside from not deploying a Django project to the web site root directory, is

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.