Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flake8-django] DJ001 is not raised for fields which has unique=True #13887

Open
kiddten opened this issue Oct 23, 2024 · 2 comments
Open

[flake8-django] DJ001 is not raised for fields which has unique=True #13887

kiddten opened this issue Oct 23, 2024 · 2 comments
Labels
question Asking for support or clarification

Comments

@kiddten
Copy link

kiddten commented Oct 23, 2024

class Product(models.Model):
    test = models.CharField(null=True, blank=True, max_length=255)

is correct

DJ001 Avoid using null=True on string-based fields such as CharField

but

class Product(models.Model):
    test = models.CharField(null=True, blank=True, max_length=255, unique=True)

All checks passed!

gives no warning

ruff version 0.7.0

@kiddten
Copy link
Author

kiddten commented Oct 23, 2024

Hmm looks like this is expected behaviour

@UnknownPlatypus
Copy link

See https://docs.djangoproject.com/en/5.1/ref/models/fields/#null for the rationale. This is indeed expected behavior

@MichaReiser MichaReiser added the question Asking for support or clarification label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

3 participants