73115

Removing an email from a Django User

Question:

When in Django I try the following with a Django user:

user.email = None user.save()

I get the exception:

NOT NULL constraint failed: auth_user.email

How does one go about deleting a user's email?

Answer1:

In Django, a User is defined as follows:

email = models.EmailField(_('email address'), blank=True)

Consequently, a user's email can be blank (i.e. "") but not null (i.e. None). You clear a user's email with the following:

user.email = "" user.save()

Recommend

  • How to get STRING response from RestTemplate postForLocation?
  • Why can't I delete a model instance with related objects?
  • Column Nullability/Optionality: NULL vs NOT NULL
  • Joining Model with Table Laravel 5.2
  • if I want to find what's referencing an object in SQL Server, is searching syscomments comprehe
  • insert a picture into database(sqlite) with java code. what should i do?
  • Why is django manage.py syncdb failing to create new columns on my development server?
  • docx4j replace variable with html
  • c# winform DrawToBitmap offscreen
  • distinct values from multiple fields within one table ORACLE SQL
  • How to validate a year I enter in textbox using jquery rule?
  • How to Model Ternary Relationship in CakePhp?
  • Regex for Specific Tag
  • WordPress > setting permalink option via script buggy?
  • Python PIL to extract number from image
  • Updating product post meta data in admin meta box field
  • Django return user model id with L
  • Cannot save model when using ember render helper
  • C#: Import/Export Settings into/from a File
  • Unable to install Git-core+svn by MacPorts
  • How can I set a binding to a Combox in a UserControl?
  • Django simple Captcha “No module named fields” error
  • AJAX Html Editor Extender upload image appearing blank
  • Email verification using google app script and google forms
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • ilmerge with a PFX file
  • Email format validation in mvc3 view
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • javascript inside java/jsp code
  • sending/ receiving email in Java
  • In LanguageTool, how do you create a dictionary and use it for spell checking?
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Android Studio and gradle
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • LevelDB C iterator
  • Busy indicator not showing up in wpf window [duplicate]
  • How can i traverse a binary tree from right to left in java?
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF