Re: Converting from AutoField to BigAutoField

2021-05-18 Thread Pankaj Jangid
Mike Dewhirst writes: > On 18/05/2021 3:18 pm, Mike Dewhirst wrote: >> On 18/05/2021 3:14 pm, Pankaj Jangid wrote: >>> I have an application from 3.1.x and in 3.2 we have to explicitly state >>> this to make it compatible i.e. without any warning: >>> >>> DEFAULT_AUTO_FIELD = 'django.db.models.Au

Re: Converting from AutoField to BigAutoField

2021-05-17 Thread Mike Dewhirst
On 18/05/2021 3:18 pm, Mike Dewhirst wrote: On 18/05/2021 3:14 pm, Pankaj Jangid wrote: I have an application from 3.1.x and in 3.2 we have to explicitly state this to make it compatible i.e. without any warning: DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' Now suppose I want to change th

Re: Converting from AutoField to BigAutoField

2021-05-17 Thread Mike Dewhirst
On 18/05/2021 3:14 pm, Pankaj Jangid wrote: I have an application from 3.1.x and in 3.2 we have to explicitly state this to make it compatible i.e. without any warning: DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' Now suppose I want to change this to BigAutoField. What all changes I’ll hav

Converting from AutoField to BigAutoField

2021-05-17 Thread Pankaj Jangid
I have an application from 3.1.x and in 3.2 we have to explicitly state this to make it compatible i.e. without any warning: DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' Now suppose I want to change this to BigAutoField. What all changes I’ll have to make in the application. Or do I just nee

Re: The database backend does not accept 0 as a value for AutoField.

2020-04-29 Thread Mayur Bagul
null=True and blank=True to the field? >> On 4/26/20 6:38 PM, Mayur Bagul wrote: >> >> Hey thanks for your response i did so because initially at the time of >> migration it was asking for default value and i just putted false in rush. >> that filed user from User mod

Re: The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Divash Singh
lue for each specific field > > Sent from Mail for Windows 10 > > From: Mayur Bagul > Sent: Sunday, 26 April 2020 18:39 > To: Django users > Subject: Re: The database backend does not accept 0 as a value for AutoField. > > Hey thanks for your response i did so beca

Re: The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Jorge Gimeno
st putted false in rush. > that filed user from User model returns username as string autofield so > what shall i put as default their? > i tried to put None for default value but while migrating it giving same > error :-- > > line 192, in validate_autopk_value > raise V

Re: The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Antje Kazimiers
username as string > autofield so what shall i put as default their? > i tried to put None for default value but while migrating it giving > same error :--  > > | >  line 192,invalidate_autopk_value >     raiseValueError('The database backend does not accept 0 as a 

RE: Re: The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Divash Singh
backend does not accept 0 as a value for AutoField. Hey thanks for your response i did so because initially at the time of migration it was asking for default value and i just putted false in rush. that filed user from User model returns username as string autofield so what shall i put as default

RE: Re: The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Divash Singh
Also, Please make sure that any foreign key fields are not default nulls Sent from Mail for Windows 10 From: Mayur BagulSent: Sunday, 26 April 2020 18:39To: Django usersSubject: Re: The database backend does not accept 0 as a value for AutoField. Hey thanks for your response i did so because

Re: The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Mayur Bagul
Hey thanks for your response i did so because initially at the time of migration it was asking for default value and i just putted false in rush. that filed user from User model returns username as string autofield so what shall i put as default their? i tried to put None for default value but

RE: The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Divash Singh
Think you shouldn’t use false as a default for fields which are not bool Sent from Mail for Windows 10 From: Antje Kazimiers Sent: Sunday, 26 April 2020 17:40 To: django-users@googlegroups.com Subject: Re: The database backend does not accept 0 as a value for AutoField. setting default=False is

Re: The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Antje Kazimiers
setting default=False is odd for any field other than a BooleanField. I would take that out for the OneToOneField at least and see how things go. Antje On 4/26/20 4:19 PM, Mayur Bagul wrote: > Hello guys, > > im stucked with this error mentioned in subject. > below link redirect details about que

The database backend does not accept 0 as a value for AutoField.

2020-04-26 Thread Mayur Bagul
Hello guys, im stucked with this error mentioned in subject. below link redirect details about question. https://stackoverflow.com/q/61427882/11351226 let me know how to get rid of this problem. Thanking You. -- You received this message because you are subscribed to the Google Groups "Djan

Re: ValueError: The database backend does not accept 0 as a value for AutoField.

2020-04-06 Thread Simon Charette
>> "/home/lenovo/.local/lib/python3.7/site-packages/django/db/models/sql/compiler.py" >>> , line 1335, in as_sql >>> for obj in self.query.objs >>> File >>> "/home/lenovo/.local/lib/python3.7/site-packages/django/db/models/sql/compiler.

Re: ValueError: The database backend does not accept 0 as a value for AutoField.

2020-04-06 Thread Hamza Mirchi
ery.objs >> File >> "/home/lenovo/.local/lib/python3.7/site-packages/django/db/models/sql/compiler.py" >> , line 1334, in >> [self.prepare_value(field, self.pre_save_val(field, obj)) for field >> in fields] >> File >> "/home/lenovo/.local/lib/python3.7/s

Re: ValueError: The database backend does not accept 0 as a value for AutoField.

2020-04-06 Thread Simon Charette
ields] > File > "/home/lenovo/.local/lib/python3.7/site-packages/django/db/models/sql/compiler.py" > , line 1275, in prepare_value > value = field.get_db_prep_save(value, connection=self.connection) > File > "/home/lenovo/.local/lib/python3.7/site-packages/d

Re: AutoField & auto-incrementing

2020-02-12 Thread Bruckner de Villiers
Useful, thanks Mike. Bruckner de Villiers 083 625 1086 On 2020/02/12, 23:18, "Mike Dewhirst" wrote: On 12/02/2020 6:54 pm, Mike Dewhirst wrote: > def save(self, *args, **kwargs): > self._pre_save()# stuff to be computed pre-save > super().save(*args, **kwargs) >

Re: AutoField & auto-incrementing

2020-02-12 Thread Mike Dewhirst
On 12/02/2020 6:54 pm, Mike Dewhirst wrote: def save(self, *args, **kwargs):     self._pre_save()    # stuff to be computed pre-save     super().save(*args, **kwargs)     self._post_save()   # stuff to be done after the save Also of occasional value ... def save(self, *args, **kwargs):     wha

Re: AutoField & auto-incrementing

2020-02-12 Thread J. Guadalupe Chavez
ket 8576 correctly, it seems to be a DB restriction and > > I imagine that there are good reasons for this. However, then I don’t > > understand the purpose of the AutoField given the restrictions and > > that the Django documentation is somewhat ambiguous/vague. > > > &

Re: AutoField & auto-incrementing

2020-02-12 Thread Bruckner de Villiers
8576 correctly, it seems to be a DB restriction and > > I imagine that there are good reasons for this. However, then I don’t > > understand the purpose of the AutoField given the restrictions and > > that the Django documentation is somewhat a

Re: AutoField & auto-incrementing

2020-02-11 Thread Mike Dewhirst
and > I imagine that there are good reasons for this. However, then I don’t > understand the purpose of the AutoField given the restrictions and > that the Django documentation is somewhat ambiguous/vague. > > The options seem to be: > > * Y

Re: AutoField & auto-incrementing

2020-02-11 Thread Bruckner de Villiers
e: > > Jason, > > Thank you. I have changed the title of this mail. If I have read the > 10 year old ticket 8576 correctly, it seems to be a DB restriction and > I imagine that there are good reasons for this. However, then I don’t > understa

Re: AutoField & auto-incrementing

2020-02-11 Thread Bruckner de Villiers
Jason, I cracked the uuid option – what an ugly ticket no.!!! - 0273051c-af54-4baf-91b9-651701d9020c Bruckner de Villiers 083 625 1086 From: Bruckner de Villiers Date: Tuesday, 11 February 2020 at 10:06 To: Subject: AutoField & auto-incrementing Jason, Thank you. I have cha

Re: AutoField & auto-incrementing

2020-02-11 Thread Mike Dewhirst
purpose of the AutoField given the restrictions and that the Django documentation is somewhat ambiguous/vague. The options seem to be: * Your uuid suggestion (which I have never worked with, but will explore) * a function in the model that does the incrementing before committing – (anyone

AutoField & auto-incrementing

2020-02-11 Thread Bruckner de Villiers
Jason, Thank you.  I have changed the title of this mail.  If I have read the 10 year old ticket 8576 correctly, it seems to be a DB restriction and I imagine that there are good reasons for this.  However, then I don’t understand the purpose of the AutoField given the restrictions and that

Re: AutoField

2019-05-27 Thread ramadhan ngallen
an Ngallen On 27 May 2019, 07:30 +0300, Saeed Pooladzadeh , wrote: > > But I have just one AutoField()!!! > در دوشنبه 27 مهٔ 2019، ساعت 5:40:19 (UTC+4:30)، Yoo نوشته: > > Probably because you have two AutoFields. You can’t have two in the same > > model. Set this to eid=mo

Re: AutoField

2019-05-26 Thread Saeed Pooladzadeh
But I have just one AutoField()!!! در دوشنبه 27 مهٔ 2019، ساعت 5:40:19 (UTC+4:30)، Yoo نوشته: > > Probably because you have two AutoFields. You can’t have two in the same > model. Set this to eid=models.AutoField(primary_key=True) > > This is because Django models automatica

Re: AutoField

2019-05-26 Thread Andrew C.
Probably because you have two AutoFields. You can’t have two in the same model. Set this to eid=models.AutoField(primary_key=True) This is because Django models automatically makes an id autofield primary key if nothing else is set as pk. On Sun, May 26, 2019 at 9:05 PM Bob Gailer wrote: >

Re: AutoField

2019-05-26 Thread Bob Gailer
On May 26, 2019 8:16 PM, "Saeed Pooladzadeh" wrote: > > > Hi > > When I add this line in my model: > > eid=models.AutoField() > > I see error in my migration!! > > What is the problem? > > I don't know what your problem is but our problem is that we have no idea what error you got. Please copy and

AutoField

2019-05-26 Thread Saeed Pooladzadeh
Hi When I add this line in my model: eid=models.AutoField() I see error in my migration!! What is the problem? -- 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

How can I display an AutoField in a ModelForm?

2018-09-12 Thread Joel Mathew
Question: How can I display an AutoField in a ModelForm. I have a need where a Form is generated and displayed. Based on the input, I need to read the AutoField's value and search for it in my database. My form: class CheckinPatientMetaForm(ModelForm): class Meta:

How to add AutoField to/switch out primary key for an existing table?

2016-11-29 Thread Hanne Moa
A model was designed with a wrong assumption of uniqueness and given a natural key. We now need to switch to a surrogate primary key. Upgrading Django is currently not an option. The production database may not be dropped/restored for this, it is in use by several unrelated projects (remember the t

Re: Desired: Field behavior like AutoField + unique_with

2015-01-14 Thread Matt Cooper
> > > widget.save() > > > > > > That should do the trick. Another option could be using table > > > triggers to automate > > > that within a database table trigger(s). > > > > > > On Mon, 12 Jan 2015 21:26:54 -0800 (PST) > > >

Re: Desired: Field behavior like AutoField + unique_with

2015-01-13 Thread Jani Tiainen
> > that within a database table trigger(s). > > > > On Mon, 12 Jan 2015 21:26:54 -0800 (PST) > > Matt Cooper > wrote: > > > > > I'm building a multi-tenant application with a data model that > > simplifies > > > to: > > &g

Re: Desired: Field behavior like AutoField + unique_with

2015-01-13 Thread Matt Cooper
> I'm building a multi-tenant application with a data model that > simplifies > > to: > > > > class Tenant(models.Model): > > name = models.CharField(max_length=50) > > > > class Widget(models.Model): > > owner = models.ForeignKey(Ten

Re: Desired: Field behavior like AutoField + unique_with

2015-01-13 Thread Jani Tiainen
dget(models.Model): > owner = models.ForeignKey(Tenant) > sequence_id = > > > I want Widget.sequence_id to work like an AutoField (that is, automatically > give me something unique and generally incrementing by 1) but scoped to a > single Widget.owner. So for instance

Desired: Field behavior like AutoField + unique_with

2015-01-13 Thread Matt Cooper
I'm building a multi-tenant application with a data model that simplifies to: class Tenant(models.Model): name = models.CharField(max_length=50) class Widget(models.Model): owner = models.ForeignKey(Tenant) sequence_id = I want Widget.sequence_id to work like an AutoField

Subclassing a model with a custom AutoField

2013-10-01 Thread jeroenp
Hi, I'm trying to save space in database rows in tables that have bigint-sized numbers of rows. One of the things I'm trying to do is using a smallint for the `id` on one of the models that is pointed to from those big tables: I have a model A with a custom AutoField for its primar

Re: Django Not Populating AutoField

2011-08-19 Thread Landy Chapman
On Aug 19, 2:05 pm, Lee wrote: > Landy - thanks for that idea. Am I correct in understanding that > setting a field to AutoField has no effect on save_model, and simply > causes dbsync to add the sequence/nextval to the Postgres table? I am not sure; On a droid phone so I can'

Re: Django Not Populating AutoField

2011-08-19 Thread Lee
Landy - thanks for that idea. Am I correct in understanding that setting a field to AutoField has no effect on save_model, and simply causes dbsync to add the sequence/nextval to the Postgres table? If so that is my problem, because I want to have one database schema that works across different

Re: Django Not Populating AutoField

2011-08-19 Thread Landy Chapman
Did you create the table using django? Can you post the table definition in postgresql? If you still have an empty database, you could try dropping the id column and do a django dbsync otherwise you may have to create a sequence and apply it to the id field. Something along the lines of: creat

Re: Django Not Populating AutoField

2011-08-19 Thread Lee
<> Did so -- no effect. I even disabled my overridden save_model so I'm back to out-of-the-box Admin setup -- no effect. This is with Postgres and the psycopg2 driver. Is no one else seeing this problem? On Aug 18, 5:32 pm, Shawn Milochik wrote: > As defined your id field doesn't differ from Dja

Re: Django Not Populating AutoField

2011-08-18 Thread Shawn Milochik
As defined your id field doesn't differ from Django's default. Just get rid of your custom id field. -- 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 g

Django Not Populating AutoField

2011-08-18 Thread Lee Hughes
obj, form, change): if change: obj.updated_by = request.user.username else: obj.created_by = request.user.username obj.save() Any ideas on how to restore the AutoField functionality? Thanks- -- Lee -- You received this message because you are subscribed to the Google Group

How to display an AutoField primary key on Admin change list and edit form?

2011-08-18 Thread Lee Hughes
My existing database schema has a primary key field named "id" in every table. I want to have Django Admin automatically populate this field and display it in read-only mode in both the change list and edit form. Because the field name is "id", I understand that this will automatically be included

Re: AutoField field that increments with regards to a foreign key?

2010-10-22 Thread derek
Have a look at this thread: http://groups.google.com/group/django-users/browse_thread/thread/deda522d2545325e/bbaa8edbeda204e3?lnk=gst&q=production+number#bbaa8edbeda204e3 The author has a similar problem i.e. he says: "There is a high risk of concurrency so just finding the previous max and the

Re: AutoField field that increments with regards to a foreign key?

2010-10-21 Thread orokusaki
Correction: I meant for the third ticket to have pk: 3. On Oct 21, 3:18 pm, Yo-Yo Ma wrote: > Example: > > Company has many Tickets > Tickets have a PK, as well as a "number". > Each Ticket's "number" should be the highest prior "number" for a > Ticket with the same Company > > Ticket: pk: 1, num

AutoField field that increments with regards to a foreign key?

2010-10-21 Thread Yo-Yo Ma
Example: Company has many Tickets Tickets have a PK, as well as a "number". Each Ticket's "number" should be the highest prior "number" for a Ticket with the same Company Ticket: pk: 1, number: 1, company: XYZ Ticket: pk: 2, number: 1, company: Acme Ticket: pk: 1, number: 2, company: XYZ unique_

Re: Are AutoField primary keys re-used after deleting an object from the db?

2010-10-15 Thread Dirk
t an object's id is unique over > > all objects, even deleted ones. > > The behavior of AutoField key allocation is entirely dependent on the > database you are using. You'll need to spend some quality time with > the documentation for your chosen database to determine

Re: Are AutoField primary keys re-used after deleting an object from the db?

2010-10-09 Thread Russell Keith-Magee
> My application relies on the fact that an object's id is unique over > all objects, even deleted ones. The behavior of AutoField key allocation is entirely dependent on the database you are using. You'll need to spend some quality time with the documentation for your chosen datab

Re: Are AutoField primary keys re-used after deleting an object from the db?

2010-10-09 Thread Dirk
ably used by Django for the AutoField. It seems to me that the serial sequence generator is not well suited for re-using deleted elements, but I'm not sure. It would be great if a Django or general database expert could calrify this. Best Regards, Dirk On Oct 10, 3:39 am, George Silva wrote

Re: Are AutoField primary keys re-used after deleting an object from the db?

2010-10-09 Thread George Silva
I'm pretty sure that OID is not reused. It's database behavior to control this and my guess is that Django does not use old object ids. Futhermore there is a simple test that you can do: Create a new object, delete it. Create a new object and check it's id. George On Sat, Oct 9, 2010 at 9:51 PM

Are AutoField primary keys re-used after deleting an object from the db?

2010-10-09 Thread Dirk
If I use id = models.AutoField(primary_key=True) can I be sure that if an object is removed from the db by calling its .delete() method, the respective id will not be used for any subsequent .save() on a new object? My application relies on the fact that an object's id is unique over all objects

editable AutoField

2009-12-12 Thread Baurzhan Ismagulov
Hello, I'd like to have a numeric field that is shown in the admin and in the model form, the value entered by the user is saved, if no value is entered, the next sequence number is assigned by the database. Is there an easy way to do that? Or should I override the model's save method and use a cu

Maximum AutoField Value

2009-10-31 Thread A. Rossi
What is the maximal value for an AutoField? When that value is reached, does it "wrap" around to 0, or does something else occur? Is it database-backend dependent? I can't find it in the documentation, nor on this mailing list. Thank you. --~--~-~--~~~-

AutoField

2009-05-15 Thread Alessandro Ronchi
I want an autofield that shows the content in admin. If I put an autofield it's hidden, if I put an IntegerField it doesn't have a new automatic default value. Is there a solution? -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.co

Re: filling in AutoField

2008-07-02 Thread Rajesh Dhawan
hin django that does it. I'd rather not have sql statements > with hardcoded values (sequence name) included in my python code (unless I > absolutely have to). The idea behind an AutoField is that the database assigns that field the next value from a sequence upon INSERT. You don't have

filling in AutoField

2008-07-02 Thread Grzegorz Dostatni
I'm writing a django application (postgresql db) that needs to deal with input both from GUI (webserver) and commandline (parsing text input). I've got a model defined where I explicitly define the id field using: id = models.AutoField(primary_key = True) When I'm creating a new entry, is th

ModelForm + FormPreview + form.save() call in done() never update objects if PK is AutoField

2008-04-24 Thread sector119
Hi ALL! If I use ModelForm + FormPreview + form.save() call in done() it never update objects if PK is AutoField, but always create them, why it can be so? FormPreview doesn't store PK value enywhere (ex.: to use in form.instance.pk to determine that it is an update not create) ? I red

Re: Any way to get AutoField from inspectdb?

2008-03-08 Thread Malcolm Tredinnick
On Sat, 2008-03-08 at 19:18 -0600, Michael Hipp wrote: > I have a legacy database that happens to be PostgreSQL. It has this primary > key field: > > CREATE TABLE foo ( > id integer PRIMARY KEY, > > When I do 'inspectdb' it gives me a model with this in it: > > class Foo(mo

Any way to get AutoField from inspectdb?

2008-03-08 Thread Michael Hipp
I have a legacy database that happens to be PostgreSQL. It has this primary key field: CREATE TABLE foo ( id integer PRIMARY KEY, When I do 'inspectdb' it gives me a model with this in it: class Foo(models.Model): id = models.IntegerField(primary_key=True) But what

Re: Initial Value for AutoField

2008-02-14 Thread Malcolm Tredinnick
On Thu, 2008-02-14 at 15:49 +0530, Sairam Krishnamurthy wrote: > Hi, > > I need to specify an initial value for for an AutoField. Is there a > way of doing it? You will need to manually tell the database to update its internal counter. AutoField values are managed by the database

Initial Value for AutoField

2008-02-14 Thread Sairam Krishnamurthy
Hi, I need to specify an initial value for for an AutoField. Is there a way of doing it? Or can somebody refer me how to find the fields of classes like AutoField? Thanks, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

AutoField that is not a pk?

2006-06-13 Thread Ville Säävuori
Is there some reason why I cannot have an AutoField(primary_key=False) in my model? (In fact, documentation hints that I could, but manage.py gives an assertion error from it.) My pk is a charfield but I would also need an automatically incrementing integer in the same class. Any ideas