On Thu, Nov 19, 2009 at 4:50 PM, Ken MacDonald <drken...@gmail.com> wrote:

> > 1) is it a bug that 'id' is generated as an 'integer' rather than
>> 'serial'
>> > type?
>>
>> I'd be curious as to how your DB got set up that way, since Django's
>> table-creation routines map AutoField to SERIAL:
>>
>>
>> http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql/creation.py#L10
>>
>
> Define a models.py as:
>
> from django.db import models
>
> # Create your models here.
> class Cardrange(models.Model):
>     minbin = models.DecimalField(max_digits=12, decimal_places=0)
>     maxbin = models.DecimalField(max_digits=12, decimal_places=0)
>
>     minpan = models.IntegerField()
>     maxpan = models.IntegerField()
>
> ... more fields and 'def __unicode__() ...
>
> then run  'manage.py sysncdb'
>
> Just dropped my table and re-created it, and the 'id' autogenerated field
> is an integer as shown by pgadmin III.
>
>
>
I cannot recreate this.  Cut-and-paste of your model into a new app, set:

DATABASE_ENGINE = 'postgresql_psycopg2'

in settings.py, add the app to INSTALLED_APPS, run syncdb, and  pgadmin III
report the autogenerated id field is 'id serial NOT NULL'.  manage.py sql on
the app reports:

BEGIN;
CREATE TABLE "ttt_cardrange" (
    "id" serial NOT NULL PRIMARY KEY,
    "minbin" numeric(12, 0) NOT NULL,
    "maxbin" numeric(12, 0) NOT NULL,
    "minpan" integer NOT NULL,
    "maxpan" integer NOT NULL
)
;
COMMIT;

In your case, what does manage.py sql for the app report?

Karen

--

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


Reply via email to