google-code-export / django-hotclub

Automatically exported from code.google.com/p/django-hotclub
MIT License
0 stars 0 forks source link

Going to the profile page crash under some conditions #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. delete dev.db
2. manage.py syncdb
3. create super user
4. log on with super user 
5. go straight to the profile tab.

What is the expected output? What do you see instead?
I should see a profile, even an empty one.
Instead of that I see a crash report.

What version of the product are you using? On what operating system?

Environment:

Request Method: GET
Request URL: http://localhost:8000/profiles/roland/
Django Version: 0.97-pre-SVN-8010
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.humanize',
 'django.contrib.markup',
 'notification',
 'emailconfirmation',
 'extensions',
 'robots',
 'dbtemplates',
 'friends',
 'mailer',
 'messages',
 'announcements',
 'django_openidconsumer',
 'django_openidauth',
 'oembed',
 'crashlog',
 'pagination',
 'gravatar',
 'threadedcomments',
 'wiki',
 'timezones',
 'feedutil',
 'app_plugins',
 'voting',
 'tagging',
 'bookmarks',
 'blog',
 'ajax_validation',
 'photologue',
 'analytics',
 'profiles',
 'zwitschern',
 'account',
 'tribes',
 'projects',
 'core',
 'things',
 'photos',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django_openidconsumer.middleware.OpenIDMiddleware',
 'profiles.middleware.LocaleMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'djangologging.middleware.LoggingMiddleware',
 'pagination.middleware.PaginationMiddleware',
 'things.middleware.SortOrderMiddleware',
 'crashlog.CrashLogMiddleware')

Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in
get_response
  85.                 response = callback(request, *callback_args,
**callback_kwargs)
File "/home/roland/Projets et Notes/Creative
Convergence/django-hotclub/projects/pinax/profiles/views.py" in profile
  103.             profile_form =
ProfileForm(instance=other_user.get_profile())
File "/usr/lib/python2.5/site-packages/django/contrib/auth/models.py" in
get_profile
  291.                 self._profile_cache =
model._default_manager.get(user__id__exact=self.id)
File "/usr/lib/python2.5/site-packages/django/db/models/manager.py" in get
  82.         return self.get_query_set().get(*args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in get
  302.                     % self.model._meta.object_name)

Exception Type: DoesNotExist at /profiles/roland/
Exception Value: Profile matching query does not exist.

Please provide any additional information below.

Original issue reported on code.google.com by frol...@gmail.com on 22 Jul 2008 at 8:40

GoogleCodeExporter commented 9 years ago
froland,

i dont think its really expected to add a super user when syncing db. Instead, 
just
answer 'no' and then create a user on your site.

Original comment by rajeev.s...@gmail.com on 24 Jul 2008 at 2:42

GoogleCodeExporter commented 9 years ago
i guess we can add a syncdb signal listener to create the profile even when 
super
user is created via syncdb

Original comment by jtau...@gmail.com on 25 Jul 2008 at 8:19

GoogleCodeExporter commented 9 years ago
So how do we fix this if we already ran the syncdb, as is expected in initially
setting up a django project?

Also, how does a superuser get created if it's not done at syncdb? Should we be
modifying settings.py? Is the first user created automatically made superuser?

Original comment by bobwayc...@gmail.com on 1 Aug 2008 at 5:41

GoogleCodeExporter commented 9 years ago
I'm not sure if I should separate these into separate issues, but the /tweets 
page
and /account/other_services page exhibit identical behavior to what is 
described here
for the /profile/username page. 

I have removed the dev.db file and reran syncdb, answering 'no' when asked to 
create
the superuser. Indeed, the errors on profile, tweets, and 
account/other_services no
longer exhibit this behavior -- but now my user is not able to login at /admin.

I can provide more thorough error reports, but didn't want to create a duplicate
issue since all three failures are linked to the same step -- answering 'yes' to
create a superuser during initial syncdb.

Is pinax designed to expect that we define our admin user explicitly in 
settings.py?

I am running pinax with default django test server atop a repaired Python2.5 in 
Mac
OS 10.5.4 

Original comment by bobwayc...@gmail.com on 1 Aug 2008 at 1:27

GoogleCodeExporter commented 9 years ago
The fix if you're already done a syncdb is to run ./manage.py shell_plus, grab 
the
user, (e.g. user = User.objects.get(pk=1)) then create the project with
Profile(user=user).save()

Original comment by jtau...@gmail.com on 1 Aug 2008 at 5:10

GoogleCodeExporter commented 9 years ago
Maybe Pinax could add a command that creates profiles for users who do not have 
them: 

from django.core.management.base import NoArgsCommand
from django.contrib.auth.models import User
from django.contrib.profile.models import Profile

class Command(NoArgsCommand):
    option_list = NoArgsCommand.option_list 
    help = 'Used to create profiles for user who do not have one'

    def handle_noargs(self, **options):
        for user in User.objects.all():
        try:
            user.get_profile()
        except:
            Profile(user=user).save()
            print "Creating profile for user.username"

Original comment by ingenier...@gmail.com on 2 Aug 2008 at 9:38

GoogleCodeExporter commented 9 years ago
The fix didn't solve the problem for me; I created a separate issue for what's
happening now. 

If I re-syncdb, how do I make my user a superuser and access the admin area?

Original comment by bobwayc...@gmail.com on 4 Aug 2008 at 3:34

GoogleCodeExporter commented 9 years ago
Attaching create_missing_profiles command.

Original comment by ingenier...@gmail.com on 13 Aug 2008 at 11:57

Attachments:

GoogleCodeExporter commented 9 years ago
fixed in r762 and r763.

r762 creates the post_save signal which ensures there is always a profile for a 
user.
r763 adds the management command.

Original comment by doug.nap...@gmail.com on 17 Aug 2008 at 1:44