I tend to agree with Marc. While I’m less than enthusiastic about the prospect of adding a new setting for this, I noticed a few times in the past that Django's support for UUID PKs was buggy, perhaps in the admin (I don’t remember the details and I can’t say if all these bugs have been fixed).
First-class support for UUID PKs — which are strings, that’s the interesting property here — may require removing various shortcuts that assume integer PKs and that would be a good thing. This is neither very concrete nor very helpful, sorry… -- Aymeric. > On 01 Sep 2016, at 19:10, Marc Tamlyn <[email protected]> wrote: > > For what it's worth I think this is *much* harder than it appears on the > surface. Whilst setting another field as the PK is easy, setting another base > type as an "auto" field is surprisingly tricky - lots of AutoField assumes > integers. > > However, I do think it has some merits. An obvious benefit to the consistency > is when you are using another framework with Django which makes certain > assumptions about the way you identify objects. Some front end frameworks > prefer guids to integers, as would some security protocols. > > M > > > On 1 Sep 2016 5:49 p.m., "Emett Speer" <[email protected] > <mailto:[email protected]>> wrote: > I agree with you in recommending against using `.filter(pk=1)` in testing. > > What do you think of the idea though. Do you think it would be worth looking > into adding a flag for new projects or not worth the time/effort to add it. > > On Wednesday, August 31, 2016 at 10:11:55 PM UTC-7, Shai Berger wrote: > On Thursday 01 September 2016 02:51:54 Josh Smeaton wrote: > > A major issue with this would be the many apps out in the wild (and their > > tests!) that assume the pk is an integer, and do queries like > > .filter(pk=1). > > FWIW, this is a bad practice which we should recommend against. In databases > which rely on sequences, after you've run some tests, the pk of the first > record in a table is not necessarily 1 (because records in the table are > removed when test transactions are rolled back, but sequence values are not > re-used). Similar issues can arise in parallel execution of tests. > > [This is a bit off-topic for the pk-type setting idea, I know] > > Shai. > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/django-developers > <https://groups.google.com/group/django-developers>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/4422aad9-a9aa-4076-b24a-659c0594e4f9%40googlegroups.com > > <https://groups.google.com/d/msgid/django-developers/4422aad9-a9aa-4076-b24a-659c0594e4f9%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/django-developers > <https://groups.google.com/group/django-developers>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/CAMwjO1F9_ftSGLnaGQPp73CLrn6L167qVZMeTOOuasiTEWZSkg%40mail.gmail.com > > <https://groups.google.com/d/msgid/django-developers/CAMwjO1F9_ftSGLnaGQPp73CLrn6L167qVZMeTOOuasiTEWZSkg%40mail.gmail.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/6E221E4A-B7A3-403C-9E73-8930559B30E2%40polytechnique.org. For more options, visit https://groups.google.com/d/optout.
