Try to overwrite the save()
method of the Model
, to check for empty values:
class MyModel(models.Model):
my_nullable_string = models.CharField(max_length=15, null=True, blank=True)
def save(self, *args, **kwargs):
if not self.my_nullable_string:
self.my_nullable_string = None
super(MyModel, self).save(*args, **kwargs)
Related Contents:
- How to see the raw SQL queries Django is running?
- Can “list_display” in a Django ModelAdmin display attributes of ForeignKey fields?
- Django auto_now and auto_now_add
- Django Admin – change header ‘Django administration’ text
- Setting Django up to use MySQL
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock
- MySQL “incorrect string value” error when save unicode string in Django
- How to override and extend basic Django admin templates?
- sql “LIKE” equivalent in django query
- How to run Django’s test database only in memory?
- Resize fields in Django Admin
- DateTimeField doesn’t show in admin system
- Default filter in Django admin
- What is the easiest way to clear a database from the CLI with manage.py in Django?
- django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
- model not showing up in django admin
- Error loading MySQLdb Module ‘Did you install mysqlclient or MySQL-python?’
- Importing data from a MySQL database into a Pandas data frame including column names [duplicate]
- How to add custom search box in Django-admin?
- In the Django admin interface, is there a way to duplicate an item?
- Django Admin: Using a custom widget for only one model field
- Not able to create super user with Django manage.py
- Django Admin: OneToOne Relation as an Inline?
- Overriding the save method in Django ModelForm
- one-to-many inline select with django admin
- Custom Filter in Django Admin on Django 1.3 or below
- Raw SQL queries in Django views
- Can you change a field label in the Django Admin application?
- Not all parameters were used in the SQL statement (Python, MySQL)
- What is the SQL ”LIKE” equivalent on Django ORM queries?
- Force django-admin startproject if project folder already exists
- How to check (in template) if user belongs to a group
- Django Admin nested inline
- pip install mysqlclient returns “fatal error C1083: Cannot open file: ‘mysql.h’: No such file or directory
- “No installed app with label ‘admin'” running Django migration. The app is installed correctly
- Custom validation in Django admin
- Adding model-wide help text to a django model’s admin form
- How to set another Inline title in Django Admin?
- Disable link to edit object in django’s admin (display list only)?
- Django admin: How to display the field marked as “editable=False” in the model?
- How to override css in Django Admin?
- Aggregating save()s in Django?
- Simple Subquery with OuterRef
- Remove the default delete action in Django admin
- Django F expressions joined field
- Install mysql-python (Windows)
- How to translate a model label in Django Admin?
- Ordering admin.ModelAdmin objects in Django Admin
- What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?
- How to change Django Admin Custom list field label?