#2591: manage.py inspectdb causes exception on postgresql_psycopg2 backend
-----------------------------------+----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Status: new | Component: django-admin.py
inspectdb
Version: | Resolution:
Keywords: | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-----------------------------------+----------------------------------------
Changes (by anonymous):
* cc: [EMAIL PROTECTED] (added)
Comment:
$ django-admin.py startproject mysite
$ python manage.py syncdb
$ python manage.py inspectdb
{{{
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or
field names.
#
# Also note: You'll have to insert the output of 'django-admin.py
sqlinitialdata [appname]'
# into your database.
from django.db import models
class AuthMessage(models.Model):
id = models.IntegerField(primary_key=True)
user = models.ForeignKey(AuthUser)
message = models.TextField()
class Meta:
db_table = 'auth_message'
class AuthGroupPermissions(models.Model):
id = models.IntegerField(primary_key=True)
group = models.ForeignKey(AuthGroup)
permission = models.ForeignKey(AuthPermission)
class Meta:
db_table = 'auth_group_permissions'
class AuthUserGroups(models.Model):
id = models.IntegerField(primary_key=True)
user = models.ForeignKey(AuthUser)
group = models.ForeignKey(AuthGroup)
class Meta:
db_table = 'auth_user_groups'
class AuthGroup(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(unique=True, maxlength=80)
class Meta:
db_table = 'auth_group'
class AuthUser(models.Model):
id = models.IntegerField(primary_key=True)
username = models.CharField(unique=True, maxlength=30)
first_name = models.CharField(maxlength=30)
last_name = models.CharField(maxlength=30)
email = models.CharField(maxlength=75)
password = models.CharField(maxlength=128)
is_staff = models.BooleanField()
is_active = models.BooleanField()
is_superuser = models.BooleanField()
last_login = models.DateTimeField()
date_joined = models.DateTimeField()
class Meta:
db_table = 'auth_user'
class AuthUserUserPermissions(models.Model):
id = models.IntegerField(primary_key=True)
user = models.ForeignKey(AuthUser)
permission = models.ForeignKey(AuthPermission)
class Meta:
db_table = 'auth_user_user_permissions'
class DjangoContentType(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(maxlength=100)
app_label = models.CharField(maxlength=100)
model = models.CharField(maxlength=100)
class Meta:
db_table = 'django_content_type'
class DjangoSession(models.Model):
session_key = models.CharField(primary_key=True, maxlength=40)
session_data = models.TextField()
expire_date = models.DateTimeField()
class Meta:
db_table = 'django_session'
class DjangoSite(models.Model):
id = models.IntegerField(primary_key=True)
domain = models.CharField(maxlength=100)
name = models.CharField(maxlength=50)
class Meta:
db_table = 'django_site'
class AuthPermission(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(maxlength=50)
content_type = models.ForeignKey(DjangoContentType)
codename = models.CharField(maxlength=100)
class Meta:
db_table = 'auth_permission'
}}}
Just for clarity this is what inspectdb said, SQL definitions are below
{{{
class Mytable(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(maxlength=255)
class Meta:
db_table = 'mytable'
class Antothertable(models.Model):
id = models.IntegerField(primary_key=True)
mytable = models.ForeignKey(Mytable)
datafield = models.CharField(maxlength=255)
class Meta:
db_table = 'antothertable'
}}}
new SQL Definitions inside a django database:
{{{
django=# create table mytable(
django(# id serial primary key not null,
django(# name varchar(255));
NOTICE: CREATE TABLE will create implicit sequence "mytable_id_seq" for
serial column "mytable.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"mytable_pkey" for table "mytable"
CREATE TABLE
django=# create table antothertable(
django(# id serial primary key not null,
django(# mytable_id int references mytable(id),
django(# datafield varchar(255));
NOTICE: CREATE TABLE will create implicit sequence "antothertable_id_seq"
for serial column "antothertable.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"antothertable_pkey" for table "antothertable"
CREATE TABLE
}}}
works for me.
!MacBook Pro (Intel to be clear)
{{{
svn info:
Revision: 4415
}}}
{{{
$ python --version
Python 2.5
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/2591#comment:3>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---