Re: About the auto-increase PK

2015-08-08 Thread ADEWALE ADISA
Am not 100% sure about this, but what about creating a normal Integer
field, then override the save method of the model to auto-increment the
value starting from 1000 ? So that any new record added, its value will be
1000+ total record +1
On Aug 8, 2015 11:11 AM, "Holland_zwz"  wrote:

> Hi all,
>  I want to add one auto-increase PK which start from one given value(such
> as start from 1000).
>
> I try to write the model as following:
>
> class MyModel(models.Model):
> mid = models.AutoField(verbose_name='My
> ID',primary_key=True,default='1000')
>
>
> But only one record can be add when i add records in admin web site.
>
> Any ways to support this? thanks
>
> Regards,
> Hollandz
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a66c5ec3-d0e8-41c8-98df-ef2c6f6c7126%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGzuy8-XVWS%2BiR%3DDidHC_PO8_HS_w1P%3Dpnff5Pgt-y4RVHVcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: About the auto-increase PK

2015-08-08 Thread Markus Holtermann
Hi Hollandz,

You can't do that from within Django automatically. You'd need to write 
your own database migration to update the database as the assignment of the 
primary key value is part of the database and not Django. Have a look 
at 
https://docs.djangoproject.com/en/1.8/ref/migration-operations/#django.db.migrations.operations.RunSQL

/Markus

On Saturday, August 8, 2015 at 8:10:35 PM UTC+10, Holland_zwz wrote:
>
> Hi all,
>  I want to add one auto-increase PK which start from one given value(such 
> as start from 1000).
>
> I try to write the model as following:
>
> class MyModel(models.Model):
> mid = models.AutoField(verbose_name='My 
> ID',primary_key=True,default='1000')
>
>
> But only one record can be add when i add records in admin web site.
>
> Any ways to support this? thanks
>
> Regards,
> Hollandz
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7e6ef24b-cff7-47a6-b6ac-a0d2c54be354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


About the auto-increase PK

2015-08-08 Thread Holland_zwz
Hi all,
 I want to add one auto-increase PK which start from one given value(such 
as start from 1000).

I try to write the model as following:

class MyModel(models.Model):
mid = models.AutoField(verbose_name='My 
ID',primary_key=True,default='1000')


But only one record can be add when i add records in admin web site.

Any ways to support this? thanks

Regards,
Hollandz


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a66c5ec3-d0e8-41c8-98df-ef2c6f6c7126%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.