Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Automatically validates when you call your model’s save()

Project Description

Make save call full_clean.

Do you think Django models save method will validate all fields (i.e. call full_clean) before saving or any time at all? Wrong!

I discovered this awful truth when I couldn’t understand why a model object with an email field (without blank=True) could be saved with an empty string as email address.

More info:


First add the application to your Python path. The easiest way is to use pip:

pip install django-smart-save

You should install by downloading the source and running:

$ python install


Make sure you have django.contrib.auth installed, and add the smart_save application to your INSTALLED_APPS list:


You can specify a different method name in your project settings (default: save_if_valid):


Usage Overview

It is simple:

>>> user = User(username="chris")
>>> user.save_if_valid()
>>> user = User(username="")
>>> user.save_if_valid()
>>> user._errors
{'username': ['This field cannot be blank.']}


Anyone is free to use or modify this software under the terms of the BSD license.

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(2.4 kB) Copy SHA256 Hash SHA256
Source None Jun 19, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting