AttributeError: 'NoneType' object has no attribute 'generated'
See original GitHub issueDescribe the bug Can’t create a model with custom pk (id) data type (TextField).
Some part of pytest log:
def __init__(self, **kwargs) -> None:
# self._meta is a very common attribute lookup, lets cache it.
meta = self._meta
> self._saved_in_db = meta.pk_attr in kwargs and meta.pk.generated
E AttributeError: 'NoneType' object has no attribute 'generated'
To Reproduce
class UserModel(Model):
id: str = fields.TextField(pk=True, generated=False)
email: str = fields.CharField(index=True, unique=True, null=False, max_length=255)
hashed_password: str = fields.CharField(null=False, max_length=255)
is_active: bool = fields.BooleanField(default=True, null=False)
is_superuser: bool = fields.BooleanField(default=False, null=False)
class Meta:
table = "user"
Expected behavior All work.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Why do I get AttributeError: 'NoneType' object has no attribute ...
NoneType means that instead of an instance of whatever Class or Object you think you're working with, you've actually got None .
Read more >[FIXED] AttributeError: 'NoneType' object has no attribute ...
Hence, AttributeError: 'NoneType' object has no attribute 'something' error occurs when the type of object you are referencing is None.
Read more >AttributeError: 'NoneType' object has no attribute ... - GitHub
In my case the problem was caused by adding a module directory to sys path and using import directory.module . Using import module...
Read more >AttributeError: 'NoneType' object has no attribute 'dtype'
When trying to start the Training, I get the following Error: AttributeError: 'NoneType' object has no attribute 'dtype'.
Read more >AttributeError: 'NoneType' object has no attribute 'call' on ...
Hello, I'm at a loss to explain why this flow fails and succeeds at the same time… It only consists in triggering a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yes but it doesn’t take a generated value at all because it isn’t valid. it doesn’t want
generated
, true or false, because it can’t do anything with it. in the context of of a ``TextField´´ the concept of auto-generating values doesn’t exist, so it doesn’t accept configuration options for it as there is no point in accepting options it can’t do anything withReleased v0.15.6 with DeprecationWarning when using TextField as primary key with suggestion to use CharField instead.