import factory

from django.contrib.auth import get_user_model


class UserFactory(factory.DjangoModelFactory):
    FACTORY_FOR = get_user_model()
    email = factory.Sequence(lambda i: 'email{}@example.com'.format(i))
    name = factory.Sequence(lambda i: 'Test User {}'.format(i))

import factory

try:
    from django.contrib.auth import get_user_model
    User = get_user_model()
except ImportError:  # Django 1.4
    from django.contrib.auth.models import User


class UserFactory(factory.DjangoModelFactory):
    FACTORY_FOR = User
    email = factory.Sequence(lambda i: 'email{}@example.com'.format(i))
    name = factory.Sequence(lambda i: 'Test User {}'.format(i))

Fix UserFactory for django 1.4
Fix UserFactory for django 1.4
