3

I've lost an user today :(

An user tried to signup to my site and his email was bigger than 75 characters (Django's auth.User default), I'm working on a migration to fix that, but I wonder, how big can I make the column without having to worry about performance|storage|memory issues?

I use PostgreSQL and Django 1.3.1 on Heroku.

Here's the South migration I intend to run:

class Migration(SchemaMigration):

    def forwards(self, orm):
        # Changing User.username, User.email, User.first_name and User.last_name
        # to bigger fields
        db.alter_column('auth_user', 'username', models.CharField(max_length=255, unique=True))
        db.alter_column('auth_user', 'email', models.CharField(max_length=255, blank=True))
        db.alter_column('auth_user', 'first_name', models.CharField(max_length=255, blank=True))
        db.alter_column('auth_user', 'last_name', models.CharField(max_length=255, blank=True))

    def backwards(self, orm):
        db.alter_column('auth_user', 'username', models.CharField(max_length=30, unique=True))
        db.alter_column('auth_user', 'email', models.CharField(max_length=75, blank=True))
        db.alter_column('auth_user', 'first_name', models.CharField(max_length=30, blank=True))
        db.alter_column('auth_user', 'last_name', models.CharField(max_length=30, blank=True))
igorgue
  • 17,884
  • 13
  • 37
  • 54
  • possible duplicate of [Can django's auth\_user.username be varchar(75)? How could that be done?](http://stackoverflow.com/questions/2610088/can-djangos-auth-user-username-be-varchar75-how-could-that-be-done) – Denilson Sá Maia Apr 23 '14 at 20:33

1 Answers1

1

Using only migrations will leave problems associated with form validation, django.contrib.admin and etc.

There is very similar question you can see here: Can django's auth_user.username be varchar(75)? How could that be done?

There's also package than you can use to extend username field: https://github.com/GoodCloud/django-longer-username (based on that question)

You can extend that code found in that package to extend email field too (since it extends only username field)

Community
  • 1
  • 1
Marius Grigaitis
  • 2,520
  • 3
  • 23
  • 30