Perhaps someone can see the problem with my very simple model.
(Summary of this email in: http://pastebin.com/m7fba5e2c)

I just started using Django yesterday, I created a very simple model,
and a corresponding application called "stats" and database called
"gmon", with only three very small tables.

Django generates the sql to create the tables in my model, but then
complains that it cannot find the tables to generate some, but not
all, of the relationships.

The error manage.py generates can be found at the bottom of this
email.

In detail:


** Setup:


mysql  Ver 14.7 Distrib 4.1.18, for apple-darwin8.3.1 (i686) using
readline 4.3
Django trunk: Updated to revision 6678.

Verified setup by running through polling tutorial.  No errors.


** Steps to reproduce:


drop database gmon, create database gmon, grant all to me

cd into an empty directory

> django-admin.py startproject central
> cd central

[create settings.py as below]

> python manage.py startapp stats

[create model.py as below]

> python manage.py syncdb
> python manage.py validate

[Zero errors so far]

> python manage.py sql stats

[generates error as below - bottom of this message]



** The Settings



# Django settings for central project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '[EMAIL PROTECTED]'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'gmon'             # Or path to database file if using
sqlite3.
DATABASE_USER = 'rbodo'             # Not used with sqlite3.
DATABASE_PASSWORD = 'not_telling'         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not
used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be avilable on all operating systems.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Los Angeles'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com";, "http://example.com/media/";
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '[EMAIL PROTECTED])^rr4ks*&y_s2s7e5'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.doc.XViewMiddleware',
)

ROOT_URLCONF = 'central.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'central.stats'
)


** The Model:


from django.db import models

class Account(models.Model):
    name = models.CharField(max_length=200)

class Box(models.Model):
    account = models.ForeignKey(Account)
    mac = models.CharField(max_length=50)
    choice = models.CharField(max_length=200)

class Domain(models.Model):
    box = models.ForeignKey(Box)
    name = models.CharField(max_length=255)


** The output of: $>python manage.py sql stats


BEGIN;
CREATE TABLE `stats_box` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `account_id` integer NOT NULL,
    `mac` varchar(50) NOT NULL,
    `choice` varchar(200) NOT NULL
)
;
CREATE TABLE `stats_account` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(200) NOT NULL
)
;
ALTER TABLE `stats_box` ADD CONSTRAINT account_id_refs_id_2a3348e1
FOREIGN KEY (`account_id`) REFERENCES `stats_account` (`id`);
CREATE TABLE `stats_domain` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `box_id` integer NOT NULL,
    `name` varchar(255) NOT NULL
)
;
-- The following references should be added but depend on non-existent
tables:
-- ALTER TABLE `stats_domain` ADD CONSTRAINT box_id_refs_id_1fa191fd
FOREIGN KEY (`box_id`) REFERENCES `stats_box` (`id`);
COMMIT;



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to