A
A
adrenalinruslan2019-09-17 20:44:19
Django
adrenalinruslan, 2019-09-17 20:44:19

Writes a required field, although Null is set?

In general, when adding a record to the database through the admin panel, it says that all fields must be filled in, but when creating a table, I indicated that these fields can be Null. How to fix it ?

from django.db import models

# Create your models here.

class Settings(models.Model):
  date = models.CharField(max_length = 255, null = True)
  is_current = models.CharField(max_length = 255, null = True)

  def __str__(self):
    return "{0} - {1}" . format(self.is_current, self.date)

  class Meta:
    verbose_name = 'Настройка'
    verbose_name_plural = 'Настройки'

That is, if you enter in the console:
Settings.objects.create()
Then the record will be added to the database, but if you add it through the admin panel, then it says that you need to fill in all the required fields ...
What I was talking about:
5d811bd369af0844363194.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-09-17
@adrenalinruslan

Addblank=True

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question