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' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345

Re: Primary Key

2020-01-20 Thread Muhammed Rafi A
import uuid uuid.uuid4().hex[:8] or from django.utils.crypto import get_random_string get_random_string(8).lower() def get_random_string(length=12, allowed_chars='abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'): On Mon, Jan 20, 2020 at 2:31 PM Soumen Khatua wrote: > Hi Fo

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 th

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 b

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 that sh

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 How > I can do

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

Re: PRIMARY KEY in view PostgreSQL

2017-12-11 Thread Simon Charette
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 using an unmanaged model to query views as there was no consensus regarding whether or not the patch

Re: Primary key for read-only models

2012-01-14 Thread JohnA
I think you can do what you want as long as you set your read-only model to managed=False in the Meta. You have to set some field to primary_key=True but it doesn’t have to actually be unique. To avoid situations where django will do something that will only work if it is unique you might want to

Re: Primary key for read-only models

2012-01-13 Thread Simone Federici
Try this: https://github.com/simone/django-compositekey/wiki and send me feedback :-) On Thu, Jan 12, 2012 at 16:03, Demetrio Girardi wrote: > I need to read data from an "external" database table from my django > project. I am not interested in modifying the data, only reading it. > Of course

Re: Primary key for read-only models

2012-01-12 Thread Thorsten Sanders
Had recently kinda the same just that I have 2 tables without a primary key at all and I just declared one of the fields as primary key and works fine. On 12.01.2012 16:03, Demetrio Girardi wrote: I need to read data from an "external" database table from my django project. I am not interested

Re: Primary key for read-only models

2012-01-12 Thread Javier Guerra Giraldez
On Thu, Jan 12, 2012 at 10:03 AM, Demetrio Girardi wrote: > I have already done this previously, however in this case the table > has a multiple field primary key, unsupported by Django. There is no > other field which is guaranteed to be unique that I can use as primary > key in the Django model.

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

2011-05-28 Thread Naoko Reeves
Malcolm, Thank you for your advice! I changed my model as follows: poll_key = models.AutoField(primary_key=True, db_column='poll_key') However, the result remain the same as shown below. If you could point me out to right direction again, I would appreciate. Thank you very much for your time.

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

2011-05-28 Thread Malcolm Box
You need to tell django what the db column name for your pollkey field is. Look at the dbname field option in the docs. Sent from my iPhone, please excuse any typos On 28 May 2011, at 05:13, Naoko Reeves wrote: > I see if column is set to AutoField then Django won't send INSERT poll_key > as

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

2011-05-27 Thread Naoko Reeves
I see if column is set to AutoField then Django won't send INSERT poll_key as null. Now my problem is that it doesn't return newly assigned primary key value for me if primary key name is _key instead of _id It looks as if sequence name is not understood correctly. Could you tell me if 1) I need to

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

2011-05-27 Thread Naoko Reeves
Casey, Thank you for your help! As Casey suggested by changing the column definition of model to: poll_key = models.AutoField(primary_key=True) Now create INSERT statement as follows: INSERT INTO "poll" ("poll_question", "poll_pub_date") VALUES ('Question!', '2011-05-27 00:00:00') With PostgreS

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

2011-05-27 Thread Casey Greene
Doesn't autofield with primary_key=True handle this for you (instead of making it an IntegerField): https://docs.djangoproject.com/en/1.3/ref/models/fields/#autofield Hope this helps! Casey On 05/27/2011 07:22 PM, Naoko Reeves wrote: Hi, I have a Django newbie question. My goal is to auto inc

Re: primary key problem [solved]

2010-07-19 Thread Franklin Einspruch
The client's manual insertion of table id numbers, which was necessary to make the admin panel work with the table ids set to IntegerField in models.py, caused the sequence behind the serial field to go out of whack in postgres. This had to be fixed in postgres. SELECT SETVAL ('primary_key_seq', 3

Re: Primary key in queryset even when using only()

2010-03-22 Thread Kevin Renskers
Thank you very much, this works perfectly! On Mar 22, 12:01 pm, bruno desthuilliers wrote: > On 22 mar, 11:08, Kevin Renskers wrote: > > > Hi, > > > I am using a combination of the only() and distinct() functions on a > > model to get the unique values of one column. Sadly, the only() > > functi

Re: Primary key in queryset even when using only()

2010-03-22 Thread bruno desthuilliers
On 22 mar, 11:08, Kevin Renskers wrote: > Hi, > > I am using a combination of the only() and distinct() functions on a > model to get the unique values of one column. Sadly, the only() > function also includes the primary key (even though I only give one > column name), which has the effect that

Re: Primary key defined by two foreignkeys?

2009-06-07 Thread Jaime Casanova
On Sun, Jun 7, 2009 at 2:11 PM, akaariai wrote: > > Use unique_together: > http://docs.djangoproject.com/en/dev/ref/models/options/ > what's the difference about this and primary key? at the database level they are almost the same thing (just adding a not null constraint to the column and you hav

Re: Primary key defined by two foreignkeys?

2009-06-07 Thread Joakim Hove
> Use unique_together:http://docs.djangoproject.com/en/dev/ref/models/options/ > > class Table3(models.Model): >     ... >     class Meta: >         unique_together = ("table1_key", "table2_key") Beautiful - thank you very much :-) Joakim --~--~-~--~~~---~--~~ Yo

Re: Primary key defined by two foreignkeys?

2009-06-07 Thread akaariai
On 7 kesä, 22:02, Joakim Hove wrote: > Hello, > > I have the following (schematic) situation: > > Class Table1(models.model): >     >     > > Class Table2(models.model): >     >     > > class Table3(models.model): >       table1_key = models.ForeignKey( Table1 ) >       table2

Re: Primary key error

2008-10-10 Thread dusans
Ah my bad, tnx :) On Oct 10, 10:45 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 10 oct, 10:19, dusans <[EMAIL PROTECTED]> wrote: > > > If i set a primary key by myself, django syncdb doesnt create a > > sequence, so when i make a new Row i get primary key is null valiation > > > like t

Re: Primary key error

2008-10-10 Thread Malcolm Tredinnick
On Fri, 2008-10-10 at 01:19 -0700, dusans wrote: > If i set a primary key by myself, django syncdb doesnt create a > sequence, so when i make a new Row i get primary key is null valiation > > like this > id_ifs_uifn = models.IntegerField(db_column='ID_IFS_UIFN', > primary_key=True) Exactly. You

Re: Primary key error

2008-10-10 Thread bruno desthuilliers
On 10 oct, 10:19, dusans <[EMAIL PROTECTED]> wrote: > If i set a primary key by myself, django syncdb doesnt create a > sequence, so when i make a new Row i get primary key is null valiation > > like this > id_ifs_uifn = models.IntegerField(db_column='ID_IFS_UIFN', > primary_key=True) Use models

Re: primary key type in customized save() method

2008-04-15 Thread Rajesh Dhawan
On Apr 15, 10:04 am, aabele <[EMAIL PROTECTED]> wrote: > I have a customized save() method in model. If the record ir new > (without ID) - then self.id type is unicode, otherwise self.id is > integer. So when I try to do a many-to-many relationship search - in > first case it doesn't work, in sec

Re: Primary key field can be empty

2007-04-26 Thread Kai Kuehne
Hi, On 4/26/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Wow .. there's been a lot of response to this without the answer > actually appearing: it's a bug! :-) > > Ticket #3774 is the relevant ticket. > > I'm very tempted to fix this by actually implementing the documented > behaviour, bec

Re: Primary key field can be empty

2007-04-25 Thread Malcolm Tredinnick
On Wed, 2007-04-25 at 16:14 +0200, Kai Kuehne wrote: > Hi list, > why can I add a record in the admin where the name field is empty, > when the docs say: > "primary_key=True implies blank=False, null=False and unique=True. > Only one primary key is allowed on an object." > > My code: > name = mod

Re: Primary key field can be empty

2007-04-25 Thread Jason McVetta
On 4/25/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > > Try adding blank=False explicitely because it works > at the admin UI level so it doesn't know about database > primary keys and such. I have experienced the same bug. I have a model that sets its primary key like this: CharField(blank=Fa

Re: Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Hi, On 4/25/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > Try adding blank=False explicitely because it works > at the admin UI level so it doesn't know about database > primary keys and such. I thoght "implies" means "automatically added". Well, I will try add it manually... seems like a bug,

Re: Primary key field can be empty

2007-04-25 Thread Ramiro Morales
On 4/25/07, Kai Kuehne <[EMAIL PROTECTED]> wrote: > > Argh, sorry... I made a mistake: >primary_key implies blank=False and null=False. > > Now it should be correct. :) Oh, I kept reading that as "why can't I add..." Try adding blank=False explicitely because it works at the admin UI level s

Re: Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Argh, sorry... I made a mistake: primary_key implies blank=False and null=False. Now it should be correct. :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send emai

Re: Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Hola, On 4/25/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > Sorry, I don't understand what you are asking.then.The > first paragraph of your message was: Second try: primary_key=True implies blank=True and null=True. This means that you cannot add an entry where the name (in my case) is empty.

Re: Primary key field can be empty

2007-04-25 Thread Ramiro Morales
On 4/25/07, Kai Kuehne <[EMAIL PROTECTED]> wrote: > > Hi, > > On 4/25/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > > > Hi list, > > > why can I add a record in the admin where the name field is empty, > > > > Because, as you wrote, blank and null are False? > > blank=False means that a blank fi

Re: Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Hi, On 4/25/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > > Hi list, > > why can I add a record in the admin where the name field is empty, > > Because, as you wrote, blank and null are False? blank=False means that a blank field ISN'T allowed. Kai --~--~-~--~~~--

Re: Primary key field can be empty

2007-04-25 Thread Ramiro Morales
On 4/25/07, Kai Kuehne <[EMAIL PROTECTED]> wrote: > > Hi list, > why can I add a record in the admin where the name field is empty, Because, as you wrote, blank and null are False? -- Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you ar

Re: Primary Key for auth_user is User.__str__() ??

2006-09-26 Thread gkelly
Alan, I've tried using ForeignKey also. It gives me different problems. See http://groups.google.com/group/django-users/browse_thread/thread/ad493aadb30b3cde/ I'd love to get some more input. Thanks, Grant --~--~-~--~~~---~--~~ You received this message because

Re: Primary Key for auth_user is User.__str__() ??

2006-09-26 Thread Alan Green
On 9/26/06, gkelly <[EMAIL PROTECTED]> wrote: > > I have the following model and view: > > http://pastebin.ca/182428 > > If I manually edit > /usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/auth/models.py > and change User.__str__(self) to return a string like > 'TEST'+

Re: Primary Key for auth_user is User.__str__() ??

2006-09-26 Thread gkelly
bump. please help. this is driving me nuts. --~--~-~--~~~---~--~~ 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 group, se