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 225017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:22:19+00:00 2026-05-11T19:22:19+00:00

In the process of learning Django and Python. I can’t make sense of this.

  • 0

In the process of learning Django and Python. I can’t make sense of this.

(Example Notes:’helloworld’ is the name of my project. It has 1 app called ‘app’.)

from helloworld.views import *          # <<-- this works
from helloworld import views            # <<-- this doesn't work
from helloworld.app import views        # <<-- but this works.  why?

It seems like line #2 and #3 are practically the same. Why does like #2 not work?

Edit — Added the source of the two files.
You might recognize this code from the Django Book project (http://www.djangobook.com/en/2.0)

helloworld/views.py

from django.shortcuts import render_to_response
from django.http import HttpResponse, Http404
import datetime

def hello(request):
    return HttpResponse("Hello world")


def current_datetime(request):
    current_date = datetime.datetime.now()
    return render_to_response('current_datetime.html', locals())


def offset_datetime(request, offset):
    try:
        offset = int(offset)
    except ValueError:
        raise Http404()

    next_time = datetime.datetime.now() + datetime.timedelta(hours=offset)
    return render_to_response('offset_datetime.html', locals())

def display_meta(request):
    values = request.META.items()
    values.sort()
    path = request.path
    return render_to_response('metavalues.html', locals())

helloworld/app/views.py

from django.shortcuts import render_to_response

def search_form(request):
    return render_to_response('search_form.html')

def search(request):
    if 'q' in request.GET:
        message = 'You searched for: %r' % request.GET['q']
    else:
        message = 'You searched for nothing.'

    return render_to_response('search_results.html', locals())
  • 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-11T19:22:20+00:00Added an answer on May 11, 2026 at 7:22 pm

    Python imports can import two different kinds of things: modules and objects.

    import x
    

    Imports an entire module named x.

    import x.y
    

    Imports a module named y and it’s container x. You refer to x.y.

    When you created it, however, you created this directory structure

    x
        __init__.py
        y.py
    

    When you add to the import statement, you identify specific objects to pull from the module and move into the global namespace

    import x # the module as a whole
    x.a # Must pick items out of the module
    x.b
    
    from x import a, b # two things lifted out of the module
    a # items are global
    b
    

    If helloworld is a package (a directory, with an __init__.py file), it typically doesn’t contain any objects.

    from x import y # isn't sensible
    import x.y # importing a whole module.
    

    Sometimes, you will have objects defined in the __init__.py file.

    Generally, use “from module import x” to pick specific objects out of a module.

    Use import module to import an entire module.

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

Sidebar

Related Questions

I was wondering is learning Python and Django a hard/time consuming process for someone
I'm in the process of learning Prolog. I have this recursive predicate: add(0,Y,Y). add(succ(X),Y,succ(Z))
Im in the process of learning asp.net 3.5, currently on webparts and co. Ive
I'm in the process of learning Erlang. As an exercise I picked up the
I am in the process of learning JavaFX and I am looking for a
I'm in the process of learning WPF coming from WinForms development. I have a
I'm in the process of learning F# and am enjoying it so far. Almost
I'm very early in the iPhone development learning process. I'm trying to get my
My primary language right now is D, and I'm in the process of learning
I am learning Django, using the django book, which is great. However, it 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.