Search code examples
pythondjangoapachedjango-users

Django User's user.get_profile() is not working while running on apache


I am facing a weird problem. While I am running my python server using python manage.py runserver I get my user.get_profile() working and everything seems to be fine, but when I am running the same application from apache server + mod wsgi setup I am getting this AttributeError error : 'User' object has no attribute 'get_profile'. I have no clue what should I do.

wsgi.py

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "passportpay.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

models.py

from django.db import models
from django.contrib.auth.models import User


class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    operator_id = models.CharField(max_length=20)
    is_admin = models.BooleanField(default=False)

Solution

  • get_profile was removed in Django 1.7, having been deprecated since version 1.5.

    You should make sure you are running the same version of Django in production as in development. In the longer term, you should rewrite your code so as not to use get_profile.