Opened 10 years ago

Closed 10 years ago

#34 closed defect (fixed)

Tutorial Import and Attribute errors while using MySQL.

Reported by: deelan Owned by: adrian
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: UI/UX:

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 Changed 10 years ago by JZ

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

comment:2 Changed 10 years ago by JZ

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

comment:3 Changed 10 years ago by JZ

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top