---
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
---
DJ001.py:7:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField`
  |
6 | class IncorrectModel(models.Model):
7 |     charfield = models.CharField(max_length=255, null=True)
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
8 |     textfield = models.TextField(max_length=255, null=True)
9 |     slugfield = models.SlugField(max_length=255, null=True)
  |

DJ001.py:8:17: DJ001 Avoid using `null=True` on string-based fields such as `TextField`
   |
 6 | class IncorrectModel(models.Model):
 7 |     charfield = models.CharField(max_length=255, null=True)
 8 |     textfield = models.TextField(max_length=255, null=True)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
 9 |     slugfield = models.SlugField(max_length=255, null=True)
10 |     emailfield = models.EmailField(max_length=255, null=True)
   |

DJ001.py:9:17: DJ001 Avoid using `null=True` on string-based fields such as `SlugField`
   |
 7 |     charfield = models.CharField(max_length=255, null=True)
 8 |     textfield = models.TextField(max_length=255, null=True)
 9 |     slugfield = models.SlugField(max_length=255, null=True)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
10 |     emailfield = models.EmailField(max_length=255, null=True)
11 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |

DJ001.py:10:18: DJ001 Avoid using `null=True` on string-based fields such as `EmailField`
   |
 8 |     textfield = models.TextField(max_length=255, null=True)
 9 |     slugfield = models.SlugField(max_length=255, null=True)
10 |     emailfield = models.EmailField(max_length=255, null=True)
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
11 |     filepathfield = models.FilePathField(max_length=255, null=True)
12 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001.py:11:21: DJ001 Avoid using `null=True` on string-based fields such as `FilePathField`
   |
 9 |     slugfield = models.SlugField(max_length=255, null=True)
10 |     emailfield = models.EmailField(max_length=255, null=True)
11 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
12 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001.py:12:16: DJ001 Avoid using `null=True` on string-based fields such as `URLField`
   |
10 |     emailfield = models.EmailField(max_length=255, null=True)
11 |     filepathfield = models.FilePathField(max_length=255, null=True)
12 |     urlfield = models.URLField(max_length=255, null=True)
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
   |

DJ001.py:16:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField`
   |
15 | class IncorrectModelWithAlias(DjangoModel):
16 |     charfield = DjangoModel.CharField(max_length=255, null=True)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
17 |     textfield = SmthCharField(max_length=255, null=True)
18 |     slugfield = models.SlugField(max_length=255, null=True)
   |

DJ001.py:17:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField`
   |
15 | class IncorrectModelWithAlias(DjangoModel):
16 |     charfield = DjangoModel.CharField(max_length=255, null=True)
17 |     textfield = SmthCharField(max_length=255, null=True)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
18 |     slugfield = models.SlugField(max_length=255, null=True)
19 |     emailfield = models.EmailField(max_length=255, null=True)
   |

DJ001.py:18:17: DJ001 Avoid using `null=True` on string-based fields such as `SlugField`
   |
16 |     charfield = DjangoModel.CharField(max_length=255, null=True)
17 |     textfield = SmthCharField(max_length=255, null=True)
18 |     slugfield = models.SlugField(max_length=255, null=True)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
19 |     emailfield = models.EmailField(max_length=255, null=True)
20 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |

DJ001.py:19:18: DJ001 Avoid using `null=True` on string-based fields such as `EmailField`
   |
17 |     textfield = SmthCharField(max_length=255, null=True)
18 |     slugfield = models.SlugField(max_length=255, null=True)
19 |     emailfield = models.EmailField(max_length=255, null=True)
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
20 |     filepathfield = models.FilePathField(max_length=255, null=True)
21 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001.py:20:21: DJ001 Avoid using `null=True` on string-based fields such as `FilePathField`
   |
18 |     slugfield = models.SlugField(max_length=255, null=True)
19 |     emailfield = models.EmailField(max_length=255, null=True)
20 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
21 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001.py:21:16: DJ001 Avoid using `null=True` on string-based fields such as `URLField`
   |
19 |     emailfield = models.EmailField(max_length=255, null=True)
20 |     filepathfield = models.FilePathField(max_length=255, null=True)
21 |     urlfield = models.URLField(max_length=255, null=True)
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
   |

DJ001.py:25:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField`
   |
24 | class IncorrectModelWithoutSuperclass:
25 |     charfield = DjangoModel.CharField(max_length=255, null=True)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
26 |     textfield = SmthCharField(max_length=255, null=True)
27 |     slugfield = models.SlugField(max_length=255, null=True)
   |

DJ001.py:26:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField`
   |
24 | class IncorrectModelWithoutSuperclass:
25 |     charfield = DjangoModel.CharField(max_length=255, null=True)
26 |     textfield = SmthCharField(max_length=255, null=True)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
27 |     slugfield = models.SlugField(max_length=255, null=True)
28 |     emailfield = models.EmailField(max_length=255, null=True)
   |

DJ001.py:27:17: DJ001 Avoid using `null=True` on string-based fields such as `SlugField`
   |
25 |     charfield = DjangoModel.CharField(max_length=255, null=True)
26 |     textfield = SmthCharField(max_length=255, null=True)
27 |     slugfield = models.SlugField(max_length=255, null=True)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
28 |     emailfield = models.EmailField(max_length=255, null=True)
29 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |

DJ001.py:28:18: DJ001 Avoid using `null=True` on string-based fields such as `EmailField`
   |
26 |     textfield = SmthCharField(max_length=255, null=True)
27 |     slugfield = models.SlugField(max_length=255, null=True)
28 |     emailfield = models.EmailField(max_length=255, null=True)
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
29 |     filepathfield = models.FilePathField(max_length=255, null=True)
30 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001.py:29:21: DJ001 Avoid using `null=True` on string-based fields such as `FilePathField`
   |
27 |     slugfield = models.SlugField(max_length=255, null=True)
28 |     emailfield = models.EmailField(max_length=255, null=True)
29 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
30 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001.py:30:16: DJ001 Avoid using `null=True` on string-based fields such as `URLField`
   |
28 |     emailfield = models.EmailField(max_length=255, null=True)
29 |     filepathfield = models.FilePathField(max_length=255, null=True)
30 |     urlfield = models.URLField(max_length=255, null=True)
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001
   |


