{{{
System check identified some issues:
WARNINGS:
accounts.ReservedUsername: (models.W042) Auto-created primary key used
when not defining a primary key type, by default
'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
SpeedyCoreAccountsConfig.default_auto_field attribute to point to a
subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
accounts.User: (models.W042) Auto-created primary key used when not
defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
SpeedyCoreAccountsConfig.default_auto_field attribute to point to a
subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
blocks.Block: (models.W042) Auto-created primary key used when not
defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
AppConfig.default_auto_field attribute to point to a subclass of
AutoField, e.g. 'django.db.models.BigAutoField'.
contact_by_form.Feedback: (models.W042) Auto-created primary key used when
not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
SpeedyCoreContactByFormConfig.default_auto_field attribute to point to a
subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
core_messages.ReadMark: (models.W042) Auto-created primary key used when
not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
SpeedyCoreMessagesConfig.default_auto_field attribute to point to a
subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
friendship.Block: (models.W042) Auto-created primary key used when not
defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
AppConfig.default_auto_field attribute to point to a subclass of
AutoField, e.g. 'django.db.models.BigAutoField'.
friendship.Follow: (models.W042) Auto-created primary key used when not
defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
AppConfig.default_auto_field attribute to point to a subclass of
AutoField, e.g. 'django.db.models.BigAutoField'.
friendship.Friend: (models.W042) Auto-created primary key used when not
defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
AppConfig.default_auto_field attribute to point to a subclass of
AutoField, e.g. 'django.db.models.BigAutoField'.
friendship.FriendshipRequest: (models.W042) Auto-created primary key used
when not defining a primary key type, by default
'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
AppConfig.default_auto_field attribute to point to a subclass of
AutoField, e.g. 'django.db.models.BigAutoField'.
likes.UserLike: (models.W042) Auto-created primary key used when not
defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
AppConfig.default_auto_field attribute to point to a subclass of
AutoField, e.g. 'django.db.models.BigAutoField'.
uploads.Image: (models.W042) Auto-created primary key used when not
defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
AppConfig.default_auto_field attribute to point to a subclass of
AutoField, e.g. 'django.db.models.BigAutoField'.
}}}
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/32367>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by 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(models.Model):
pass
}}}
Also neither the `User` or `Entity` models are mentioned in your check
failures above.
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:1>
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>
* severity: Normal => Release blocker
* cc: Tom Forbes (added)
* component: Uncategorized => Database layer (models, ORM)
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
Thanks for the report.
Reproduced at bbd18943c6c00fb1386ecaaf6771a54f780ebf62.
Bug in b5e12d490af3debca8c55ab3c1698189fdedbbdb.
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:3>
* Attachment "tests-32367.diff" added.
Regression test.
* Attachment "tests-32367.diff" added.
Regression test.
--
Comment (by Hasan Ramezani):
Shouldn't the `Child` class inherits from `Parent` in the regression test?
{{{
class Child(Parent):
pass
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:4>
* owner: nobody => Hasan Ramezani
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:5>
Comment (by Mariusz Felisiak):
Replying to [comment:4 Hasan Ramezani]:
> Shouldn't the `Child` class inherits from `Parent` in the regression
test?
>
>
> {{{
> class Child(Parent):
> pass
> }}}
True, typo.
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:6>
* has_patch: 0 => 1
Comment:
[PR https://github.com/django/django/pull/13922]
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:7>
Comment (by Mariusz Felisiak):
[https://github.com/django/django/pull/13925 Alternative PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a03a36121d22c8784985c7e45727eddef6a3ea7f" a03a3612]:
{{{
#!CommitTicketReference repository=""
revision="a03a36121d22c8784985c7e45727eddef6a3ea7f"
Fixed #32367 -- Fixed system check for specifying type of auto-created
primary keys for inherited PKs.
Regression in b5e12d490af3debca8c55ab3c1698189fdedbbdb.
Thanks אורי for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"e45b944d69b6bacaccb22b351a76272aa4f93581" e45b944]:
{{{
#!CommitTicketReference repository=""
revision="e45b944d69b6bacaccb22b351a76272aa4f93581"
[3.2.x] Fixed #32367 -- Fixed system check for specifying type of auto-
created primary keys for inherited PKs.
Regression in b5e12d490af3debca8c55ab3c1698189fdedbbdb.
Thanks אורי for the report.
Backport of a03a36121d22c8784985c7e45727eddef6a3ea7f from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32367#comment:10>