Registering a user profile

465 views
Skip to first unread message

Christos Jonathan Hayward

unread,
Feb 14, 2012, 12:53:50 PM2/14/12
to django...@googlegroups.com
I am trying to make a user profile object; my models.py presently reads:

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

class UserProfile(models.Model):
    name = models.TextField()
    scratchpad = models.TextField()
    user = models.ForeignKey(User, unique = True)

def create_user_profile(sender, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user = instance)

post_save.connect(create_user_profile, sender = User)

In my settings.py I have at the top:

AUTH_PROFILE_MODULE = 'models.UserProfile'

I am getting an error screen:

SiteProfileNotAvailable at /

Unable to load the profile model, check AUTH_PROFILE_MODULE in your project settings
Request Method: GET
Request URL: http://localhost:8000/
Django Version:1.3.1
Exception Type: SiteProfileNotAvailable
Exception Value:
Unable to load the profile model, check AUTH_PROFILE_MODULE in your project settings
Exception Location: /usr/local/Cellar/python/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py in get_profile, line 380
Python Executable:/usr/local/bin/python
Python Version:2.7.0
Python Path:
['/Users/jonathan/pim',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg',
 '/usr/local/Cellar/python/2.7/lib/python27.zip',
 '/usr/local/Cellar/python/2.7/lib/python2.7',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-darwin',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-mac',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-tk',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-old',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-dynload',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/PIL',
 '/usr/local/lib/python2.7/site-packages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time: Tue, 14 Feb 2012 11:48:23 -0600

The models.py file is in /Users/jonathan/pim.

What am I doing wrong here? How can I set things so that the UserProfile in models.py registers as a user profile?

Thanks,
--
Christos Jonathan Hayward
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio • Email • Facebook • Google Plus Kindle + Books! • LinkedIn • Twitter • Web • What's New?

I invite you to visit my "theology, literature, and other creative works" site. See a random page!

little master

unread,
Feb 14, 2012, 1:16:26 PM2/14/12
to django...@googlegroups.com
try giving  your appname.models.UserProfile

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

creecode

unread,
Feb 14, 2012, 1:20:40 PM2/14/12
to django...@googlegroups.com
Hello Jonathan,

See the "Storing additional information about users" section in the docs.  There it mentions the expected format of AUTH_PROFILE_MODULE.

I suspect what you need to do is wrap your UserProfile model up in it's own app if it isn't in one already.  Alternately you need to change the "models" in AUTH_PROFILE_MODULE to the name of your app.

Let us know if that works for you.

Toodle-looooooooo..............
creecode

Christos Jonathan Hayward

unread,
Feb 14, 2012, 1:27:19 PM2/14/12
to django...@googlegroups.com
Thank you, little master and creecode. I tried 'pim.UserProfile' and 'pim.models.UserProfile' and they both errored out. With 'pim.UserProfile', which it looks like the documentation calls for, I get:

Server time: Tue, 14 Feb 2012 12:17:42 -0600

With 'pim.models.UserProfile' I get a slightly different:

SiteProfileNotAvailable at /

app_label and model_name should be separated by a dot in the AUTH_PROFILE_MODULE setting
Request Method: GET
Request URL: http://localhost:8000/
Django Version:1.3.1
Exception Type: SiteProfileNotAvailable
Exception Value:
app_label and model_name should be separated by a dot in the AUTH_PROFILE_MODULE setting
Exception Location: /usr/local/Cellar/python/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py in get_profile, line 373
Python Executable:/usr/local/bin/python
Python Version:2.7.0
Python Path:
['/Users/jonathan/pim',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg',
 '/usr/local/Cellar/python/2.7/lib/python27.zip',
 '/usr/local/Cellar/python/2.7/lib/python2.7',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-darwin',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-mac',
 '/usr/local/Cellar/python/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-tk',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-old',
 '/usr/local/Cellar/python/2.7/lib/python2.7/lib-dynload',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/PIL',
 '/usr/local/lib/python2.7/site-packages',
 '/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time: Tue, 14 Feb 2012 12:25:41 -0600

"pim" is the name of the project. Do I need to create a distinct application within that project?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/HSX4NGpn66kJ.

To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Kevin Anthony

unread,
Feb 14, 2012, 1:32:33 PM2/14/12
to django...@googlegroups.com

Did you include the module in your settings.py?

Kevin
Please excuse brevity, sent from phone

Christos Jonathan Hayward

unread,
Feb 14, 2012, 1:38:39 PM2/14/12
to django...@googlegroups.com
If I import models, it crashes. The top-level project is pim; under that I have models.py, which contains UserProfile. Specifying pim.UserProfile and pim.models.UserProfile gets two different error messages. Do I need to create a separate application under pim and load "<new application>.UserProfile"?

Christos Jonathan Hayward

unread,
Feb 14, 2012, 1:44:56 PM2/14/12
to django...@googlegroups.com

creecode

unread,
Feb 14, 2012, 1:51:57 PM2/14/12
to django...@googlegroups.com
Hello Jonathan,


On Tuesday, February 14, 2012 10:38:39 AM UTC-8, Jonathan Hayward wrote:

Do I need to create a separate application under pim and load "<new application>.UserProfile"?

From the docs...

To indicate that this model is the user profile model for a given site, fill in the setting AUTH_PROFILE_MODULE with a string consisting of the following items, separated by a dot:

  1. The name of the application (case sensitive) in which the user profile model is defined (in other words, the name which was passed to manage.py startapp to create the application).
  2. The name of the model (not case sensitive) class.

For example, if the profile model was a class named UserProfile and was defined inside an application named accounts, the appropriate setting would be:

AUTH_PROFILE_MODULE = 'accounts.UserProfile'
 
So yes your UserProfile model should be inside of a separate app.  I usually call this app accounts just like the docs.  I generally put all my models inside an app not at the top level of a project.

Toodle-looooooooo..........
creecode

Christos Jonathan Hayward

unread,
Feb 14, 2012, 2:08:28 PM2/14/12
to django...@googlegroups.com
Thank you!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/v-G9LkGXdEoJ.

To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Reply all
Reply to author
Forward
0 new messages