Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is a good place to work on accounts/profile in Django with the Django registration app?

Tags:

I've noticed that after I log in with Django registration it redirects me to accounts/profile/. By default Django registration's url.py doesn't handle accounts/profile/, so I need to create my own.

Actually this questions is three-fold:

  1. Why does after logging in, it redirects to accounts/profile/? Is there a way to change that? Preferably after successfully logging in I would like Django to redirect back to the page before the login page.
  2. If I were to create my own view and template for accounts/profile/, then where should I put it? Django's built-in users (auth_user) is shared among all Django apps inside a project, so should I place the view.py in the project folder and not inside the app folder?
  3. Or does Django profile actually takes care of this whole account/profiles/ thing? I already extended Django's User class with my own UserProfile, but it's more like additional fields to the User table than an actual "profile" (I didn't create avatars or anything like that, just simple stuff like addresses and phone numbers, but most importantly, some custom user types that my app depends on).
like image 928
hobbes3 Avatar asked Mar 23 '12 07:03

hobbes3


1 Answers

Why does after logging in, it redirects to accounts/profile/? Is there a way to change that? Preferably after successfully logging in I would like Django to redirect back to the page before the login page.

Just change setting LOGIN_REDIRECT_URL

If I were to create my own view and template for accounts/profile/, then where should I put it? Django's built-in users (auth_user) is shared among all Django apps inside a project, so should I place the view.py in the project folder and not inside the app folder?

I like to create an app called "project_specific" in every project. That's where I put all the stuff that's not meant to be reusable and that couples many apps.

You can also create a views.py at the project level, but that is sort of messy compared to making a project specific app.

In reality it does not matter where you put it.

Or does Django profile actually takes care of this whole account/profiles/ thing? I already extended Django's User class with my own UserProfile, but it's more like additional fields to the User table than an actual "profile" (I didn't create avatars or anything like that, just simple stuff like addresses and phone numbers, but most importantly, some custom user types that my app depends on).

That's not the way to add extra user fields. I recommend that you read the docs on Storing additional information about users.

like image 161
jpic Avatar answered Sep 23 '22 15:09

jpic