Just set primary_key=True on your field:

jono = models.PositiveIntegerField(primary_key=True)

See the django documentation for details:
http://docs.djangoproject.com/en/dev/topics/db/models/#id1

Nuno

On Wed, Jul 14, 2010 at 6:38 PM, Jagdeep Singh Malhi
<singh.malh...@gmail.com> wrote:
> I try  this code to create database in using django.
>
> file :models.py
> class amount(models.Model):
>     jono = models.PositiveIntegerField(unique=True)
>     name = models.CharField(max_length=750)
>     receipt = models.CharField(max_length=200)
>     phno = models.CharField(max_length=25)
>     type = models.CharField(max_length=50)
>     rdate = models.DateField('date published')
>     site = models.CharField(max_length=200)
>
> after run
> #python manage.py sql tcc
> command i get
> BEGIN;
> CREATE TABLE `tcc_amount` (
>    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
>    `jono` integer UNSIGNED NOT NULL UNIQUE,
>    `name` varchar(750) NOT NULL,
>    `receipt` varchar(200) NOT NULL,
>    `phno` varchar(25) NOT NULL,
>    `type` varchar(50) NOT NULL,
>    `rdate` date NOT NULL,
>    `site` varchar(200) NOT NULL
> )
> ;
> COMMIT;
>
> But i want 'jono'  is also AUTO_INCREMENT with 'id'  or  only jono
> not include the 'id '.
> Which code is used to make 'jono ' to auto increment.??
> Pleases help ,if possible.
>
> thanks
>
> --
> 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=en.
>
>

-- 
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=en.

Reply via email to