Code

#20191 closed Uncategorized (invalid)

No Module Named App Name

Reported by: johnsonshara@… Owned by: nobody
Component: Python 2 Version: 1.5
Severity: Normal Keywords:
Cc: bmispelon@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have Created the Project and App using Python And Django.
This is My Model in my model.py


class Poll(models.Model):

question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')


Now When run import Poll though python shell , it gives no module name Poll.

Project Structure :
mysite [project name]

manage.py
mysite

files under mysite

polls [my app]

init
models
views
tests

Attachments (0)

Change History (1)

comment:1 Changed 16 months ago by bmispelon

  • Cc bmispelon@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Hi,

This site is for reporting bugs against django. For support, you should try the django-users mailing list or the #django channel on IRC: https://docs.djangoproject.com/en/1.5/faq/help/

As for your issue, you're not importing the right module.

In python, the module's name if the name of the file, so you shouldn't be importing Poll.

Rather, you should do from polls.models import Poll, as described in the tutorial: https://docs.djangoproject.com/en/1.5/intro/tutorial01/#playing-with-the-api

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.