Re: Admin foreign key widgets Dont quote Keys that the unicode of the Primary key (value=number) is a special character.

2023-02-13 Thread Dev Femi Badmus
lized that the widgets quote characters and > numbers as the value of the primary key. > > The challenge I have is that the widgets don't quote keys with primary key > value that is a number and the unicode of the number is a special > character. E.g, let's assume the primary key value is

Re: How to solve primary key error in django?

2023-01-09 Thread Derek
Also understand that using '0' for a primary key is NOT recommended by MySQL; look at: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_no_auto_value_on_zero This has bitten me before when migrating data from other types of DBMS. On Thursday, 5 January 2023 at 12:09:35 UTC+2

Re: How to solve primary key error in django?

2023-01-08 Thread Aviv Avitan
We have a lot of such fields in our database and never seen such an error. What I can think that may happen is that some row already assigned the id of 0, and changing the column type or adding a id column (which probably overrides the automatic one django generates for each model), and now it

Re: migrations not created for foreign key when primary key type is changed

2022-09-03 Thread Devang
get model. > > Cheers > Markus > > On Fri, Sep 2, 2022, at 10:39 AM, Manasvi Dobariya wrote: > > I have default primary key in the model which is being referenced as > foreign key in another model. Now, when I change this primary key type from > AutoField to BigAutoField, migrat

Re: migrations not created for foreign key when primary key type is changed

2022-09-03 Thread Markus Holtermann
ult primary key in the model which is being referenced as foreign > key in another model. Now, when I change this primary key type from AutoField > to BigAutoField, migrations for only primary keys are being generated no > migration for foreign key is generated. However, when I apply t

Re: migrations not created for foreign key when primary key type is changed

2022-09-02 Thread Devang
I guess it might be changed by postgres. Have you checked postgres documentation ? On Fri, 2 Sep 2022, 18:45 Manasvi Dobariya, wrote: > I have default primary key in the model which is being referenced as > foreign key in another model. Now, when I change this primary key type from >

migrations not created for foreign key when primary key type is changed

2022-09-02 Thread Manasvi Dobariya
I have default primary key in the model which is being referenced as foreign key in another model. Now, when I change this primary key type from AutoField to BigAutoField, migrations for only primary keys are being generated no migration for foreign key is generated. However, when I apply

Re: Recreation of foreign key constraints when changing type of referenced primary key

2022-05-05 Thread Baraka Kiula
i'm still a new here -- 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 view this discussion on the web visit

Re: Recreation of foreign key constraints when changing type of referenced primary key

2022-03-22 Thread Jason
You might want to ask this at https://groups.google.com/g/django-developers, as that is where the framework devs have their discussions. This is more of a users group, and I think you'll get a faster answer by posting there. On Tuesday, March 22, 2022 at 6:20:41 AM UTC-4 Gregor Jerše wrote: >

Recreation of foreign key constraints when changing type of referenced primary key

2022-03-22 Thread Gregor Jerše
Hi, I have a question regarding Django version 3.2.12. When I change the DEFAULT_AUTO_FIELD to BigAutoField and create migrations, the foreign keys of auto-generated through tables are dropped. This can be observed by running sqlmigrate which drops foreign key relations but never recreates

Re: Using primary key to update via POST request.

2020-07-21 Thread Liu Zheng
Hi, do you mean in the GET request, the user provides the pk (perhaps in URL) or the server sends to users an object where pk is a field? If it's the former, then @George's answer is the right one. An example of what you are trying to achieve will be helpful. Best Zheng On Tue, Jul 21, 2020 at

Re: Using primary key to update via POST request.

2020-07-20 Thread George
You use request.GET['choice_filed'] On Monday, July 20, 2020 at 9:14:48 AM UTC+5:30, Arpana Mehta wrote: > > Hi, > I have a class with a GET and a POST request. I am sending the data ( with > pk of the object ) in my GET request and I want the frontend to use that pk > to refer to the exact

Using primary key to update via POST request.

2020-07-19 Thread Arpana Mehta
Hi, I have a class with a GET and a POST request. I am sending the data ( with pk of the object ) in my GET request and I want the frontend to use that pk to refer to the exact instance of the model whenever doing any operation. In my POST request I am only sending the `choice field` value. How

Re: Custom Primary Key

2020-06-24 Thread Oleg Kishenkov
en, you should use a CharField with the primary_key=True > > attribute for your model. This way no no automatic primary key > > field is generated, your field will be implicitly unique and non- > > null though. Only one primary key is allowed in a model. > > > > class Foo(mod

Re: Custom Primary Key

2020-06-24 Thread Clive Bruton
On 24 Jun 2020, at 06:24, Soumen Khatua wrote: Yes, at the time of add a new record in model, automatically I want to create a custom ID and insert it into model There is a post about this at Stack Overflow: https://stackoverflow.com/questions/52070462/django-generate-custom-id -- Clive

Re: Custom Primary Key

2020-06-23 Thread Soumen Khatua
rimary_key=True > > attribute for your model. This way no no automatic primary key > > field is generated, your field will be implicitly unique and non- > > null though. Only one primary key is allowed in a model. > > > > class Foo(models.Model) > > id = models.

Re: Custom Primary Key

2020-06-23 Thread Clive Bruton
On 23 Jun 2020, at 23:32, Oleg Kishenkov wrote: Hello Soumen, you should use a CharField with the primary_key=True attribute for your model. This way no no automatic primary key field is generated, your field will be implicitly unique and non- null though. Only one primary key is allowed

Re: Custom Primary Key

2020-06-23 Thread Oleg Kishenkov
Hello Soumen, you should use a CharField with the primary_key=True attribute for your model. This way no no automatic primary key field is generated, your field will be implicitly unique and non-null though. Only one primary key is allowed in a model. class Foo(models.Model) id

Re: Custom Primary Key

2020-06-23 Thread Soumen Khatua
In the documentation they are specified, How to set Primary Key in Django model but In my case, I want to generate custom Primary Key?! On Wed, Jun 24, 2020 at 1:36 AM David Chorpash wrote: > Hi Soumen, > > Are you looking for this? > https://docs.djangoproject.com/en/3.0/ref/m

Re: Custom Primary Key

2020-06-23 Thread David Chorpash
Hi Soumen, Are you looking for this? https://docs.djangoproject.com/en/3.0/ref/models/fields/#primary-key You should be able to create a field in your model and set the primary_key to True On Tue, Jun 23, 2020 at 1:18 PM Soumen Khatua wrote: > Hi Folks, > > In Django is ther

Custom Primary Key

2020-06-23 Thread Soumen Khatua
Hi Folks, In Django is there any way to create custom Primark Key like: M01234GH, M056YUOIP, etc. Please help me guys. Thank you in advance Regards, Soumen Khatua -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this

Re: some value for primary key

2020-01-21 Thread maninder singh Kumar
ks, > > I want to start my primary key from saome random number like: (onwards) > but not from 1. How I can do that in django? > > Thank you in advance > > Regards, > Soumen > > -- > You received this message because you are subscribed to the Google Groups >

Re: some value for primary key

2020-01-21 Thread Mike Dewhirst
On 22/01/2020 5:32 am, Soumen Khatua wrote: Hi Folks, I want to start my primary key from saome random number like: (onwards) but not from 1. I wonder why? How I can do that in django? If I really had to do that I would adjust the relevant sequence manually via PGAdmin. Otherwise

Re: some value for primary key

2020-01-21 Thread Suraj Thapa FC
Just right a simple python function With random number generation... And call it where you want to use it On Wed, 22 Jan 2020, 12:03 am Soumen Khatua, wrote: > Hi Folks, > > I want to start my primary key from saome random number like: (onwards) > but not from 1.

some value for primary key

2020-01-21 Thread Soumen Khatua
Hi Folks, I want to start my primary key from saome random number like: (onwards) but not from 1. How I can do that in django? Thank you in advance Regards, Soumen -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubs

Changing Primary Key from BigAutoField to BigIntegerField not working

2020-01-20 Thread Amiganer
a migration, a look at the database nothing has changes, the id is still a autogenerated sequence (postgresql uses sequences as primary key). the "nexval(...seq)" is in it too. I does the manually: "ALTER TABLE xyz ALTER id DROP DEFAULT" and that worked. Now the id (=primary-k

Re: Primary Key

2020-01-20 Thread Kasper Laudrup
Hi Muhammed, On 20/01/2020 11.25, Muhammed Rafi A wrote: |importuuid uuid.uuid4().hex[:8] | |or |fromdjango.utils.crypto importget_random_string get_random_string(8).lower() || def get_random_string(length=12, allowed_chars='abcdefghijklmnopqrstuvwxyz'

Re: Primary Key

2020-01-20 Thread Muhammed Rafi A
Hi Folks, > > I want to generate unique 6 digit primary key for django models and I want > to generate this for 10 billon users. So guys please could you tell me How > I can do that? > > I tried UUID module but it's generating some big numbers. > > Thank you > > Regard

Re: Primary Key

2020-01-20 Thread Soumen Khatua
Thank you for your email On Mon, Jan 20, 2020 at 3:09 PM Kasper Laudrup wrote: > Hi again, > > On 20/01/2020 10.22, Kasper Laudrup wrote: > > > > You want to generate a number between 0 and 1.000.000 that should be > > unique for 10.000.000.000 instances? > > > > I hope you can understand why

Re: Primary Key

2020-01-20 Thread Kasper Laudrup
Hi again, On 20/01/2020 10.22, Kasper Laudrup wrote: You want to generate a number between 0 and 1.000.000 that should be unique for 10.000.000.000 instances? I hope you can understand why that doesn't make any sense. Thinking a bit more about, you don't specify whether it should be in

Re: Primary Key

2020-01-20 Thread Kasper Laudrup
Hi Soumen, On 20/01/2020 10.01, Soumen Khatua wrote: Hi Folks, I want to generate unique 6 digit primary key for django models and I want to generate this for 10 billon users. So guys please could you tell me How I can do that? You want to generate a number between 0 and 1.000.000

Re: Primary Key

2020-01-20 Thread Forrest Hartley
I’m not sure a six digit model would support 10bn unique values. On Mon, Jan 20, 2020 at 4:01 AM Soumen Khatua wrote: > Hi Folks, > > I want to generate unique 6 digit primary key for django models and I want > to generate this for 10 billon users. So guys please could you tell me

Primary Key

2020-01-20 Thread Soumen Khatua
Hi Folks, I want to generate unique 6 digit primary key for django models and I want to generate this for 10 billon users. So guys please could you tell me How I can do that? I tried UUID module but it's generating some big numbers. Thank you Regards, Soumen -- You received this message

Feature Request: set default model primary key to UUID or something else for entire project

2019-06-28 Thread Brian Carter
I am aware that I can specify any model's primary key by adding that kwarg to a field within the model. I currently do this with most my models, using UUIDField as the primary key: class MyModel(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False

Re: Migration Issues when updating model's default primary key from id to uuid

2019-02-19 Thread Thomas Leo
I'm running django 1.11, have this same issue. Has this issue been fixed in later versions of django? Is there a workaround for 1.11? On Sunday, November 12, 2017 at 7:30:45 AM UTC-5, Liuyang Wan wrote: > > Thanks for the link. It’s interesting that two years past the bug is still > unresolved.

Re: Get the maximum possible ID value for a primary key?

2019-01-09 Thread shiva kumar
can you explain it indetail On Wed, Jan 9, 2019 at 7:18 PM Stodge wrote: > Is there a way to get the maximum value that an ID can be for a model that > uses AutoField for its primary key? For example, in PostgreSQL I could do: > > SELECT maximum_value FROM information_schema.seq

Get the maximum possible ID value for a primary key?

2019-01-09 Thread Stodge
Is there a way to get the maximum value that an ID can be for a model that uses AutoField for its primary key? For example, in PostgreSQL I could do: SELECT maximum_value FROM information_schema.sequences WHERE sequence_name = 'my_sequence_id_seq'; maximum_value --- 9 (1 row

Re: DetailView only works with slug and primary key?

2019-01-02 Thread Andréas Kühne
réas Den ons 2 jan. 2019 kl 11:20 skrev Osezele Orukpe : > I would like to know if django DetailView can be used with other fields > apart from slug and primary key? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" g

DetailView only works with slug and primary key?

2019-01-02 Thread Osezele Orukpe
I would like to know if django DetailView can be used with other fields apart from slug and primary key? -- 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

Re: MySQL accepts 0 for a primary key but Django does not

2019-01-01 Thread mazz ahmed
gt;> >>>> In order to override it I suggest you create a subclass of >>>> django.db.backends.mysql.base.DatabaseWrapper in >>>> a custom foo.bar.base module and set feature_class to a >>>> .features.DatabaseFeatures[1] >>>> subclass t

Re: MySQL accepts 0 for a primary key but Django does not

2019-01-01 Thread Derek
ango.db.backends.mysql.features import DatabaseFeatures as >>> BaseDatabaseFeatures >>> >>> class DatabaseFeatures(BaseDatabaseFeatures): >>> allows_auto_pk_0 = True >>> >>> class DatabaseWrapper(BaseDatabaseWrapper): >>> featu

Re: MySQL accepts 0 for a primary key but Django does not

2018-12-30 Thread Simon Charette
907ebcb2d00bcf7c3f5bc/django/db/backends/mysql/features.py#L27 >> [1] >> https://github.com/django/django/blob/e817ae74da0e515db31907ebcb2d00bcf7c3f5bc/django/db/backends/mysql/base.py#L184 >> [2] >> https://github.com/django/django/blob/e817ae74da0e515db31907ebcb2d00bcf7c

Re: MySQL accepts 0 for a primary key but Django does not

2018-12-30 Thread Derek
7c3f5bc/django/db/utils.py#L110 > [3] > https://github.com/django/django/blob/e817ae74da0e515db31907ebcb2d00bcf7c3f5bc/django/db/utils.py#L203 > > Le vendredi 28 décembre 2018 07:47:31 UTC-5, Derek a écrit : >> >> I am working with some legacy data and need to preserve the existin

Re: MySQL accepts 0 for a primary key but Django does not

2018-12-28 Thread Simon Charette
shell: > > create table number (number int not null auto_increment primary key); > insert into number(number) values (0); select * from number; drop table > number; > > ++ > | number | > ++ > | 0 | > ++ > 1 row in set (0,00 sec) >

MySQL accepts 0 for a primary key but Django does not

2018-12-28 Thread Derek
that this works by running the following test inside the MySQL shell: create table number (number int not null auto_increment primary key); insert into number(number) values (0); select * from number; drop table number; ++ | number | ++ | 0 | ++ 1 row in set (0,00 sec) However

how do we create a custom primary key in django

2018-10-30 Thread chaitak
id = models.CharField(primary_key=True,default='first') .how can i insert a custom auto generated primary with the organization name for example 'cha' and a number starting from 1000 so the final id would be cha1000 and next id would be cha1001 Thanks & Regars

Re: Using Primary key in two fields

2018-10-20 Thread Vishvajit Pathak
: unique_together = (('icatid', 'makeid'),) On Wednesday, 17 October 2018 11:25:48 UTC+5:30, Rakhee Menon wrote: > > Hi Everyone, > > I have a scenario where one field needs to be a primary key and another > field needs to be an AutoFieldand Autofield requires a condition > primary_ke

Re: Using Primary key in two fields

2018-10-17 Thread Michal Petrucha
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On Tue, Oct 16, 2018 at 10:55:48PM -0700, Rakhee Menon wrote: > Hi Everyone, > > I have a scenario where one field needs to be a primary key and another > field needs to be an AutoFieldand Autofield requires a condition > pri

Re: Using Primary key in two fields

2018-10-17 Thread Ігор Магур
t; I have a scenario where one field needs to be a primary key and another > field needs to be an AutoFieldand Autofield requires a condition > primary_key = true > > I get this error > django_reports.MstCompositionFm.makeid: (fields.E100) AutoFields mus

Using Primary key in two fields

2018-10-16 Thread Rakhee Menon
Hi Everyone, I have a scenario where one field needs to be a primary key and another field needs to be an AutoFieldand Autofield requires a condition primary_key = true I get this error django_reports.MstCompositionFm.makeid: (fields.E100) AutoFields must set primary_key=True

Re: [SOLVED] primary key auto increment with PostgreSQL and non Django standard column name

2018-08-06 Thread Aditya Sangam
Naoko I ma facing the problem of updating primary key automatically in django with postgresql database Could you please suggest what need to be done. Do we need to create a sequence for the table to achieve this. Hoping for your reply On Sunday, May 29, 2011 at 8:32:45 PM UTC+5:30

Re: How to get the primary key of the underlying model in a ModelForm?

2018-05-30 Thread Mark Phillips
alf Of *Mark Phillips > *Sent:* Tuesday, May 29, 2018 4:15 PM > *To:* django users > *Subject:* How to get the primary key of the underlying model in a > ModelForm? > > > > I have a model, Document, and an associated DocumentForm(forms. > ModelForm), and a DocumentAdmin(ad

RE: How to get the primary key of the underlying model in a ModelForm?

2018-05-29 Thread Matthew Pava
in the clean method. If you are updating a document, then pk will populated. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Mark Phillips Sent: Tuesday, May 29, 2018 4:15 PM To: django users Subject: How to get the primary key of the underlying model

How to get the primary key of the underlying model in a ModelForm?

2018-05-29 Thread Mark Phillips
I have a model, Document, and an associated DocumentForm(forms. ModelForm), and a DocumentAdmin(admin.ModelAdmin). In the clean method of the DocumentForm, I need to get the document_id (ie primary key) of the underlying Document, but it is not included in the field set for that form. I need

Re: UUIDs eventually choke as primary key

2018-03-16 Thread M. Page-Lieberman
PM, M Mackey <mm...@mac.com> wrote: > Well, I don't seem to be able to get around this. I'm going to have to > switch away from using a UUID as a primary key, which fortunately doesn't > seem like too much work. > > > On Thursday, March 1, 2018 at 8:53:13 AM UTC-8, M Mackey w

Re: UUIDs eventually choke as primary key

2018-03-16 Thread Ahmed Cheikh
Hi, I think the problem comes from mod_wsgi. I had the same problem when virtualhost listen on multiple ports. Please look at this GH issue https://github.com/GrahamDumpleton/mod_wsgi/issues/206 and try this by https://github.com/GrahamDumpleton/mod_wsgi/issues/206#issuecomment-305019825 by

Re: UUIDs eventually choke as primary key

2018-03-15 Thread M Mackey
Well, I don't seem to be able to get around this. I'm going to have to switch away from using a UUID as a primary key, which fortunately doesn't seem like too much work. On Thursday, March 1, 2018 at 8:53:13 AM UTC-8, M Mackey wrote: > > I added some debug support, and there are on

Re: UUIDs eventually choke as primary key

2018-03-01 Thread M Mackey
I added some debug support, and there are only two classes called UUID when this fails: uuid UUID: psycopg2.extensions UUID: The psycopg extension is a converter, and it seems highly unlikely that it was put into place as the value, and I doubt it would report it's __str__ as the UUID

Re: UUIDs eventually choke as primary key

2018-02-23 Thread M Mackey
Not to belabor the point, but this is the part that I find weird. This is down in the "During handling of the above exception ('UUID' object has no attribute 'replace'), another exception occurred" section. /usr/local/venvs/attrack/lib/python3.6/site-packages/django/db/models/fields/__init__.py

Re: UUIDs eventually choke as primary key

2018-02-23 Thread M Mackey
Mackey wrote: > > I've run into a strange issue with using a UUID as primary key, and I'm > hoping we can either verify this is a bug, or figure out what I've done > wrong. > > I've got a core model object with a UUID for it's primary key. (Generated > external to th

Re: UUIDs eventually choke as primary key

2018-02-23 Thread M Mackey
My notes don't say I did that, and I tried a new env and sys.path still shows /usr/local/lib/python3.6. Maybe that's just a red herring. But I don't have any other good explanation for the UUID getting passed to the UUID __init__. On Friday, February 23, 2018 at 9:12:33 AM UTC-8, Tom Evans

Re: UUIDs eventually choke as primary key

2018-02-23 Thread 'Tom Evans' via Django users
On Fri, Feb 23, 2018 at 4:20 PM, M Mackey wrote: > I have noticed in the python > path that there are two paths to .../lib/python3.6. One from my virtualenv, > and one at /usr/local/. Not sure where to clear that up, since I don't > believe I've got my apache env set up to pull

Re: UUIDs eventually choke as primary key

2018-02-23 Thread M Mackey
The thing that gets me is this part: .../django/db/models/fields/__init__.py in to_python > return uuid.UUID(value) ... > /usr/local/lib/python3.6/uuid.py in __init__ > hex = hex.replace('urn:', '').replace('uuid:', '') ... > > During handling of the above exception

Re: UUIDs eventually choke as primary key

2018-02-22 Thread M Mackey
jango/core/handlers/exception.py in inner On Monday, February 12, 2018 at 1:00:53 PM UTC-8, M Mackey wrote: > > I've run into a strange issue with using a UUID as primary key, and I'm > hoping we can either verify this is a bug, or figure out what I've done > wrong. > >

Re: Multiple models and a primary key

2018-02-16 Thread ????????????
OnetoOneField may what you want! ---Original--- From: "Michael MacIntosh"<mmacint...@linear-systems.com> Date: 2018/2/17 09:42:29 To: "django-users"<django-users@googlegroups.com>; Subject: Re: Multiple models and a primary key I'm not sur

Re: Multiple models and a primary key

2018-02-16 Thread Michael MacIntosh
I'm not sure what you are trying to achieve, but you probably don't want all of the models to use the same primary key. You can access the primary key though via the pk or id attributes. For instance: Grade.objects.all().values("subjt_id", "subjt__pk", "subjt__profile_

Multiple models and a primary key

2018-02-16 Thread dahlen . lloyds
Ok, thanks for replying. am quite new in Django. Am looking for a way to use a primary key in 3 models in my django project. for instance. The models are Profile, Subject and Grade. Want subject to link to profile and grade to link to subject. class Profile(models.Model): f_name

Re: UUIDs eventually choke as primary key

2018-02-12 Thread Ɐha Hah
Use a storage/caching layer of CUIDs instead? http://usecuid.org/ Aha On Mon, Feb 12, 2018 at 11:24 AM, M Mackey <mm...@mac.com> wrote: > I've run into a strange issue with using a UUID as primary key, and I'm > hoping we can either verify this is a bug, or figure out what I've

UUIDs eventually choke as primary key

2018-02-12 Thread M Mackey
I've run into a strange issue with using a UUID as primary key, and I'm hoping we can either verify this is a bug, or figure out what I've done wrong. I've got a core model object with a UUID for it's primary key. (Generated external to this system, thus using that for when additional

RE: PRIMARY KEY in view PostgreSQL

2017-12-11 Thread Matthew Pava
Sent: Monday, December 11, 2017 1:35 PM To: Django users Subject: Re: PRIMARY KEY in view PostgreSQL Hello Matthew, This should be fixed in Django 2.0 by daf2bd3efe53cbfc1c9fd00222b8315708023792[0]. I'd appreciate if you could chime in the related django-developer thread[1] to mention you were

Re: PRIMARY KEY in view PostgreSQL

2017-12-11 Thread Simon Charette
> > Upon further investigation, it appears that I need a PRIMARY KEY in the > backend to avoid having to include columns in a GROUP BY clause, but > PostgreSQL does not allow for such constraints to be added to a VIEW. The > “id” column is just a row_number(). > > > > I was

PRIMARY KEY in view PostgreSQL

2017-12-11 Thread Matthew Pava
egate function." Upon further investigation, it appears that I need a PRIMARY KEY in the backend to avoid having to include columns in a GROUP BY clause, but PostgreSQL does not allow for such constraints to be added to a VIEW. The "id" column is just a row_number(). I was wondering how

Re: Migration Issues when updating model's default primary key from id to uuid

2017-11-12 Thread Liuyang Wan
Thanks for the link. It’s interesting that two years past the bug is still unresolved. -- 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

Re: Migration Issues when updating model's default primary key from id to uuid

2017-11-11 Thread Liuyang Wan
gt; a = models.ForeignKey(A) >> >> Later on I decided to use uuid as the primary key value. so I update the >> models: >> >> import uuid >> >> class A(models.Model): >> id = models.UUIDField( >> db_index=True, >> default=uu

Re: Migration Issues when updating model's default primary key from id to uuid

2017-11-11 Thread m1chael
ing... > > class B(models.Model): > a = models.ForeignKey(A) > > Later on I decided to use uuid as the primary key value. so I update the > models: > > import uuid > > class A(models.Model): > id = models.UUIDField( > db_index=True, > default=uu

Migration Issues when updating model's default primary key from id to uuid

2017-11-10 Thread Liuyang Wan
Let's say in my Django project I have two models A and B. class A(models.Model): something... class B(models.Model): a = models.ForeignKey(A) Later on I decided to use uuid as the primary key value. so I update the models: import uuid class A(models.Model): id = models.UUIDField

Re: Access data associated to a primary key

2017-10-03 Thread tango ward
thanks Gourav. I really appreciate your inputs. On Tue, Oct 3, 2017 at 9:16 PM, Gourav Chawla < gauravchawla.chawla...@gmail.com> wrote: > Glad, you worked it out. You can use them whenever you want. Function > based views require you to write more code but give you more clarity on > what's

Re: Access data associated to a primary key

2017-10-03 Thread Gourav Chawla
Glad, you worked it out. You can use them whenever you want. Function based views require you to write more code but give you more clarity on what's happening. On the other hand CBV help you keep the codebase cleaner. At the end of the day, it's you who has to decide what to use. -- You

Re: Access data associated to a primary key

2017-10-02 Thread tango ward
ctional > view. But for CBV you have DetailView that takes care of this. Hope this > helps. > > > On Monday, October 2, 2017 at 2:53:04 PM UTC+5:30, tangoward15 wrote: >> >> Hi guys, I just want to know how to access and load the data associated >> to a primar

Re: Access data associated to a primary key

2017-10-02 Thread tango ward
just the approach you would follow for functional > view. But for CBV you have DetailView that takes care of this. Hope this > helps. > > > On Monday, October 2, 2017 at 2:53:04 PM UTC+5:30, tangoward15 wrote: >> >> Hi guys, I just want to know how to access and load

Re: Access data associated to a primary key

2017-10-02 Thread Gourav Chawla
follow for functional view. But for CBV you have DetailView that takes care of this. Hope this helps. On Monday, October 2, 2017 at 2:53:04 PM UTC+5:30, tangoward15 wrote: > > Hi guys, I just want to know how to access and load the data associated to > a primary key in a template. >

Access data associated to a primary key

2017-10-02 Thread tango ward
Hi guys, I just want to know how to access and load the data associated to a primary key in a template. models.py class Team_Region(models.Model): name = models.CharField(max_length=50) # String representation def __str__(self): return self.name class Team_Name

Re: Avoid primary key in Django models.py

2017-08-04 Thread Samuel Dorsaz
if you remove your primary key, you will not be able to identify your record in your database, could you please precise what do you want to achieve by doing this ? Le vendredi 4 août 2017 14:07:19 UTC+2, jagadishreddy bommareddy a écrit : > > I am using Django frame work in that mod

RE: Avoid primary key in Django models.py

2017-08-04 Thread Matthew Pava
You can’t. You can change what field is the primary key, but you can’t remove the primary key. Just specify primary_key=True on the field you would like to make your primary key. >From the docs: Each model requires exactly one field to have primary_key=True<https://docs.djangoproject.

Avoid primary key in Django models.py

2017-08-04 Thread jagadishreddy bommareddy
I am using Django frame work in that models.py in any field i don't want primarykey how can i avoid primary key -- 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, sen

Add new primary key to model

2017-02-18 Thread Joakim Hove
Hello; I have a model with a CharField which is used as primary key: class MyModel( Model ): string_id = CharField("StringID" , primary_key = True ) I would now like to migrate this model to have a normal integer AutoField as primary key, and the string_id field s

primary key, foreign key combination

2017-01-30 Thread dsfqce cwfe
When I try to update_or_create model object with primary key that is also a foreign key in some other model I get DoesNotExist error and then IntegrityError duplicate entry error. My way around this is to try get the object and then update it without the primary key or create it (with primary

Re: Multiple Fields as Primary Key in MySQL - Django 1.10

2017-01-05 Thread ramesh
200)NOT > NULLCOMMENT 'Field3', > Field4 > VARCHAR(300)DEFAULT NULLCOMMENT > 'Field4', > KEY ( Field2 ), > FOREIGN KEY (Field2) REFERENCES item (Field2) ON DELETE C

Re: Multiple Fields as Primary Key in MySQL - Django 1.10

2017-01-03 Thread Michal Petrucha
On Tue, Jan 03, 2017 at 01:56:00PM +0100, Simone Federici wrote: > Hi, > > from compositekey import db > > On my compositekey project the development is stopped on 1.5 django release. > https://github.com/simone/django-compositekey > > The Django 1.6 release, with an huge ORM refactoring and a

Re: Multiple Fields as Primary Key in MySQL - Django 1.10

2017-01-03 Thread Simone Federici
0)NOT > NULLCOMMENT 'Field3', > Field4 VARCHAR(300) > DEFAULT NULLCOMMENT 'Field4', > KEY ( Field2 ), > FOREIGN KEY (Field2) REFERENCES item (Field2) ON DELETE CASCADE, >

Multiple Fields as Primary Key in MySQL - Django 1.10

2017-01-03 Thread ramesh
FAULT NULLCOMMENT 'Field4', KEY ( Field2 ), FOREIGN KEY (Field2) REFERENCES item (Field2) ON DELETE CASCADE, PRIMARY KEY ( Field1, Field2 ) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Migrations failed with the error, "A model can't have more tha

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

Re: Django 1.10 "Cannot force an update in save() with no primary key", using model with composite primary key (unique_together)

2016-10-29 Thread Tim Graham
') > > @property > def link_disabled(self): > return self.type == AssociationType.REMOVED > ``` > > When trying to simply create a new object django raises an error: > > ``` > link_assoc = NetworkLinkAssociation() > link_assoc.link = link > link_

Django 1.10 "Cannot force an update in save() with no primary key", using model with composite primary key (unique_together)

2016-10-29 Thread info
ociationType.REMOVED ``` When trying to simply create a new object django raises an error: ``` link_assoc = NetworkLinkAssociation() link_assoc.link = link link_assoc.network = network link_assoc.save() ``` "ValueError: Cannot force an update in save() with no primary key.". I'm 10

Re: Downside of using shortuuid as primary key

2016-10-27 Thread Bruno A.
use shortuuid > <https://github.com/nebstrebor/django-shortuuidfield> as the primary key > for my models. > > Is there any downside to this? > Does it severely affect db indexing? > -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Downside of using shortuuid as primary key

2016-10-27 Thread Avraham Serour
why are you considering? On Thu, Oct 27, 2016 at 7:34 AM, Suren Sth <srn...@gmail.com> wrote: > I am considering to use shortuuid > <https://github.com/nebstrebor/django-shortuuidfield> as the primary key > for my models. > > Is there any downside to this? > Does

Downside of using shortuuid as primary key

2016-10-26 Thread Suren Sth
I am considering to use shortuuid <https://github.com/nebstrebor/django-shortuuidfield> as the primary key for my models. Is there any downside to this? Does it severely affect db indexing? -- You received this message because you are subscribed to the Google Groups "Django u

Re: How can I create a new table without primary key filed?

2015-11-24 Thread Rohan Nagalkar
a new table without primary key in Django modeling. ? > > I'm porting a old program to Django web framework. After inspect > database to modules.py and then syncdb, It create the id filed with > primary key attribute, how can I disable this feature ? -- You received this message be

migrate primary key changes

2015-05-15 Thread raviteja nandula
Hi All, I have created a model with primary key, later i have removed the primary key and used default `id` as primary key When i tried to migrate it is throwing error with multiple primary keys defined Before running migrate i have executed on MySQL command interface "ALTER

The inline foreign key did not match the parent instance primary key.

2015-05-09 Thread Ajay Kumar
le its not working.Its just shows "Please correct the error below".And then i tried to save through userinterface views(out of admin) it shows the following error "The inline foreign key did not match the parent instance primary key". -- You received this message

  1   2   3   4   5   >