Created
June 27, 2012 14:08
-
-
Save niwinz/3004276 to your computer and use it in GitHub Desktop.
Correct monky patching of django User.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django.db.models import signals | |
def model_class_prepared(sender, **kwargs): | |
if sender._meta.app_label == 'auth' and sender._meta.module_name == 'user': | |
print "Monky patching user..." | |
email_field = sender._meta.get_field("email") | |
email_field.max_length = 200 | |
email_field._unique = True | |
last_name = sender._meta.get_field("last_name") | |
last_name.max_length = 200 | |
first_name = sender._meta.get_field("first_name") | |
first_name.max_length = 200 | |
signals.class_prepared.connect(model_class_prepared) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment