Migrating existing auth.User data to new Django 1.5 custom user model?

South is more than able to do this migration for you, but you need to be smart and do it in stages. Here’s the step-by-step guide: (This guide presupposed you subclass AbstractUser, not AbstractBaseUser) Before making the switch, make sure that south support is enabled in the application that contains your custom user model (for … Read more

AttributeError: ‘Manager’ object has no attribute ‘get_by_natural_key’ error in Django?

You have created a new user model but you have not yet specified a manager for that model. If you’re not yet familiar with managers in Django I suggest reading the documentation on that first. As the Django 1.5 say (source): You should also define a custom manager for your User model. If your User … Read more

AUTH_USER_MODEL refers to model .. that has not been installed and created AbstractUser models not able to login

I’ve run into this a few times. It’s always been an import issue. Suppose we have core/models.py that implements a custom user and imports a symbol from another file (say Else): from Something import Else class CustomUser(AbstractBaseUser): pass And then we have another file that uses CustomUser and also defines Else. Let’s call this something/models.py: … Read more

Django allauth social login: automatically linking social site profiles using the registered email

Note (2018-10-23): I’m not using this anymore. Too much magic happening. Instead I enabled SOCIALACCOUNT_EMAIL_REQUIRED and ‘facebook’: { ‘VERIFIED_EMAIL’: False, … }. So allauth will redirect social logins on a social signup form to enter a valid email address. If it’s already registered an error shows up to login first and then connect the account. … Read more

select_related with reverse foreign keys

Yes, that is what prefetch_related() is for. It will require an additional query, but the idea is that it will get all of the related information at once, instead of once per Person. In your case: qs.select_related(‘position__report_to’) .prefetch_related(‘position__report_to__person_set’) should require two queries, regardless of the number of Persons in the original query set. Compare this … Read more

Setting DEBUG = False causes 500 Error

Django 1.5 introduced the allowed hosts setting that is required for security reasons. A settings file created with Django 1.5 has this new section which you need to add: # Hosts/domain names that are valid for this site; required if DEBUG is False # See https://docs.djangoproject.com/en/1.9/ref/settings/#allowed-hosts ALLOWED_HOSTS = [] Add your host here like [‘www.beta800.net’] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)