Opened 19 years ago

Closed 19 years ago

#34 closed defect (fixed)

Tutorial Import and Attribute errors while using MySQL.

Reported by: deelan Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm following the tutorial using Windows2k, MySQL 4.1 and Python 2.4.1. I've passed thru the installation phase, directory structure creation and database table creation withou problems, but i'm getting strange errors when i try to exec command described in "Playing with the API".

a little note, i guess that the "export" command in the tutorial must be replaced with a "set" on windows:

  set DJANGO_SETTINGS_MODULE=myproject.settings.main

Here's the first traceback i have:

>>> from django.models.polls import polls, choices
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Data\Dev\myproject\apps\polls\models\polls.py", line 1, in ?
    from django.core import meta
  File "C:\Python\Lib\site-packages\django-1.0.0-py2.4.egg\django\core\meta.py",
 line 2, in ?
    from django.core import db
  File "C:\Python\Lib\site-packages\django-1.0.0-py2.4.egg\django\core\db\__init
__.py", line 18, in ?
    dbmod = __import__('django.core.db.backends.%s' % DATABASE_ENGINE, '', '', [
''])
  File "C:\Python\Lib\site-packages\django-1.0.0-py2.4.egg\django\core\db\backen
ds\postgresql.py", line 8, in ?
    import psycopg as Database
ImportError: No module named psycopg
>>> ^Z

the system seems to ignore the settings specified in the main.py (although they was correctly used in the table creation pahse).

hacking the Django global_settings.py file and set DATABASE_ENGINE key to "mysql" makes me skipt that error, but i've got another one:

>>> from django.models.polls import polls, choices
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python\Lib\site-packages\django-1.0.0-py2.4.egg\django\models\__in
_.py", line 8, in ?
    for mod in meta.get_installed_models():
  File "C:\Python\Lib\site-packages\django-1.0.0-py2.4.egg\django\core\meta.p
 line 76, in get_installed_models
    for a in settings.INSTALLED_APPS:
AttributeError: 'module' object has no attribute 'INSTALLED_APPS'

Now i'm stuck. ;(

Change History (3)

comment:1 by JZ, 19 years ago

It looks like settings/main.py is ignored. Set up django/conf/global_settings.py and those problems gone.

comment:2 by JZ, 19 years ago

Setting set set DJANGO_SETTINGS_MODULE=myproject.settings.main first is crucial. Without it django cannot find settings/main.py

comment:3 by JZ, 19 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top