{{{
from django.db import models
class MyAbstractModel(models.Model):
class Meta:
abstract = True
# behaviour in 3.1.10:
MyAbstractModel.check() # returns []
# behaviour in 3.2:
MyAbstractModel.check() # raises AttributeError: 'NoneType' object has no
attribute 'auto_created' in `_check_default_pk`
}}}
It seems to me (but I might be wrong here) that this was not an
intentional change (as the feature is all about default autofield), but
rather a bug.
However, feel free to correct me!
Best,
Rust
--
Ticket URL: <https://code.djangoproject.com/ticket/32733>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Johannes Maron (added)
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
It is arguable, whether if the checks need to work on an abstract class. I
also noticed that Django will raise an error since 3.2 if you try to
instantiate an abstract model.
Though, there is no place where checks are called on abstract models
inside an application, this does make unit testing harder.
With that in mind, maybe this is best classified as an optimization not a
bug, since no public API is broken, not does this affect the application
itself. However, since Django is a developer-friendly framework and comes
with an excellent test suite, I believe an improvement would be welcome by
many.
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:1>
Comment (by amureki):
Replying to [comment:1 Johannes Maron]:
> It is arguable, whether if the checks need to work on an abstract class.
I also noticed that Django will raise an error since 3.2 if you try to
instantiate an abstract model.
> Though, there is no place where checks are called on abstract models
inside an application, this does make unit testing harder.
>
> With that in mind, maybe this is best classified as an optimization not
a bug, since no public API is broken, not does this affect the application
itself. However, since Django is a developer-friendly framework and comes
with an excellent test suite, I believe an improvement would be welcome by
many.
Thanks, Johannes!
I made a draft [https://github.com/django/django/pull/14375 PR] with blunt
solution - freshly introduced auto-field check would not run on abstract
models.
I am more than happy to get better ideas or any other feedback!
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:2>
* owner: nobody => amureki
* status: new => assigned
* has_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:3>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:4>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:5>
* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:6>
* severity: Normal => Release blocker
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a24fed399ced6be2e9dce4cf28db00c3ee21a21c" a24fed39]:
{{{
#!CommitTicketReference repository=""
revision="a24fed399ced6be2e9dce4cf28db00c3ee21a21c"
Fixed #32733 -- Skipped system check for specifying type of auto-created
primary keys on abstract models.
Regression in b5e12d490af3debca8c55ab3c1698189fdedbbdb.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:8>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"349bb58b8a0b6f4b98193dbfe369e41b8780f225" 349bb58b]:
{{{
#!CommitTicketReference repository=""
revision="349bb58b8a0b6f4b98193dbfe369e41b8780f225"
[3.2.x] Fixed #32733 -- Skipped system check for specifying type of auto-
created primary keys on abstract models.
Regression in b5e12d490af3debca8c55ab3c1698189fdedbbdb.
Backport of a24fed399ced6be2e9dce4cf28db00c3ee21a21c from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32733#comment:9>