#32367: Problems with 3.2 alpha - primary keys
-------------------------------+--------------------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by אורי):
Replying to [comment:1 Simon Charette]:
> Hello Uri, thanks for testing out the alpha and the report.
>
> > These models should not use auto-created primary keys! I already
defined the primary key in the ancestor of the model. For example class
Entity which class User inherits from. It looks to me like a bug in Django
3.2 alpha.
>
> Could you provide a minimal project with a set of models to reproduce
the issue. I tried the following but couldn't reproduce
>
> {{{#!python
> from django.db import models
>
> class Entity(models.Model):
> id = models.AutoField(primary_key=True)
>
> class User(Entity):
> pass
> }}}
>
> Also neither the `User` or `Entity` models are mentioned in your check
failures above.
Hi Simon,
Notice that `accounts.User` above is class `User` in the `accounts` app.
I'm not sure if I can provide a minimal project as you requested, but you
can see my code on GitHub. For example the models of the `accounts` app
are here:
https://github.com/speedy-net/speedy-
net/blob/master/speedy/core/accounts/models.py
(Search for "`class Entity`" and "`class User`". The `id =
SmallUDIDField()` field in class `Entity` is the primary key. It also
works for getting a `User` model by `User.objects.get(pk=...)`.
Also same is for `class ReservedUsername` above, which is a much more
simpler model than `class User`.
The definition of `SmallUDIDField` above (the primary key field) is on
https://github.com/speedy-net/speedy-
net/blob/master/speedy/core/base/fields.py .
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/069.660d0cf6313d602920f0da307155f596%40djangoproject.com.