---
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
---
DJ001 Avoid using `null=True` on string-based fields such as `CharField`
 --> DJ001.py:7:17
  |
6 | class IncorrectModel(models.Model):
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 Avoid using `null=True` on string-based fields such as `TextField`
  --> DJ001.py:8:17
   |
 6 | class IncorrectModel(models.Model):
 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)
10 |     emailfield = models.EmailField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `SlugField`
  --> DJ001.py:9:17
   |
 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)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 |     emailfield = models.EmailField(max_length=255, null=True)
11 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `EmailField`
  --> DJ001.py:10:18
   |
 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)
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 |     filepathfield = models.FilePathField(max_length=255, null=True)
12 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `FilePathField`
  --> DJ001.py:11:21
   |
 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)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `URLField`
  --> DJ001.py:12:16
   |
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 Avoid using `null=True` on string-based fields such as `CharField`
  --> DJ001.py:16:17
   |
15 | class IncorrectModelWithAlias(DjangoModel):
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 Avoid using `null=True` on string-based fields such as `CharField`
  --> DJ001.py:17:17
   |
15 | class IncorrectModelWithAlias(DjangoModel):
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)
19 |     emailfield = models.EmailField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `SlugField`
  --> DJ001.py:18:17
   |
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)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 |     emailfield = models.EmailField(max_length=255, null=True)
20 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `EmailField`
  --> DJ001.py:19:18
   |
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)
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 |     filepathfield = models.FilePathField(max_length=255, null=True)
21 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `FilePathField`
  --> DJ001.py:20:21
   |
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)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `URLField`
  --> DJ001.py:21:16
   |
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 Avoid using `null=True` on string-based fields such as `CharField`
  --> DJ001.py:25:17
   |
24 | class IncorrectModelWithoutSuperclass:
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 Avoid using `null=True` on string-based fields such as `CharField`
  --> DJ001.py:26:17
   |
24 | class IncorrectModelWithoutSuperclass:
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)
28 |     emailfield = models.EmailField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `SlugField`
  --> DJ001.py:27:17
   |
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)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28 |     emailfield = models.EmailField(max_length=255, null=True)
29 |     filepathfield = models.FilePathField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `EmailField`
  --> DJ001.py:28:18
   |
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)
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29 |     filepathfield = models.FilePathField(max_length=255, null=True)
30 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `FilePathField`
  --> DJ001.py:29:21
   |
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)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30 |     urlfield = models.URLField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `URLField`
  --> DJ001.py:30:16
   |
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 Avoid using `null=True` on string-based fields such as `CharField`
  --> DJ001.py:52:35
   |
51 | class IncorrectModelWithSimpleAnnotations(models.Model):
52 |     charfield: models.CharField = models.CharField(max_length=255, null=True)
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53 |     textfield: models.TextField = models.TextField(max_length=255, null=True)
54 |     slugfield: models.SlugField = models.SlugField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `TextField`
  --> DJ001.py:53:35
   |
51 | class IncorrectModelWithSimpleAnnotations(models.Model):
52 |     charfield: models.CharField = models.CharField(max_length=255, null=True)
53 |     textfield: models.TextField = models.TextField(max_length=255, null=True)
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54 |     slugfield: models.SlugField = models.SlugField(max_length=255, null=True)
   |

DJ001 Avoid using `null=True` on string-based fields such as `SlugField`
  --> DJ001.py:54:35
   |
52 |     charfield: models.CharField = models.CharField(max_length=255, null=True)
53 |     textfield: models.TextField = models.TextField(max_length=255, null=True)
54 |     slugfield: models.SlugField = models.SlugField(max_length=255, null=True)
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
