Questions tagged [django-profiles]

Django-profiles is a module that allows you to add additional fields that extend the "out of the box" User Profile provided by Django.

Explanation of django-profiles

django-profiles is a module that allows you to add additional fields that extend the "out of the box" User Profile provided by Django.


Steps to Implement Module

1. Modify Settings

settings.py

AUTH_PROFILE_MODULE = 'application_name.UserProfile'

2. Add Routing

urls.py

(r'^profiles/', include('profiles.urls'))

3. Add Form Fields

forms.py

class ProfileForm(ModelForm):

twitter = forms.CharField(label="Twitter")
about = forms.CharField(label="About", widget=forms.Textarea)
url = forms.CharField(label="URL")

4. Add View

views.py

Write the view for the edit_profile

5. Create Templates

  • profiles/create_profile.html
  • profiles/edit_profile.html
  • profiles/profile_detail.html
  • profiles/profile_list.html

Download Code

https://bitbucket.org/ubernostrum/django-profiles

Additional Resources

django-profiles: The Missing Manual

Further Tips

  • If you are adding an ImageField to your profile model, chmod -R 755 that folder

avatar = models.ImageField(upload_to = 'avatar/')

Note: If you have /avatar/ then you will get a SuspiciousOperation exception

  • In your template add enctype="multipart/form-data" in form tag.

<form method="post" action="." enctype="multipart/form-data">

To display the image add something similar to the example below <img id="avatar" src="/media/{{ profile.avatar }}" />

66 questions
30
votes
3 answers

Django: When extending User, better to use OneToOneField(User) or ForeignKey(User, unique=True)?

I'm finding conflicting information on whether to use OneToOneField(User) or ForeignKey(User, unique=True) when creating a UserProfile model by extending the Django User model. Is it better to use this?: class UserProfile(models.Model): user =…
Tony Guinta
  • 633
  • 1
  • 8
  • 14
21
votes
3 answers

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

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: Why does…
hobbes3
  • 28,078
  • 24
  • 87
  • 116
6
votes
2 answers

What's the best way to have different profiles for different kinds of users in django?

In my application I have students, professors and staff. Staff members do not need a profile but professors and students each need a different profile. I'd rather not implement it all myself (middleware and whatnot), so is there anyway to just have…
Marcos Marin
  • 752
  • 1
  • 5
  • 17
6
votes
1 answer

Different user profiles with django-profiles & django-registration

My models.py: USER_TYPES = ( ('D', 'Demo' ), …
5
votes
0 answers

Multiple registration flows and profile types with django-allauth

I have two kind of users: the first has to pay in oder to register to the site and he can perform a set of actions. The second can register and login for free (with their Facebook or Google or Username&Password) and can perform a different set of…
3
votes
3 answers

Django Class Based view for a profile page

I want to use class based views to build a profile page. Are there any inbuilt views to achieve this. For eg: I have used auth_views for login and register. Django auth.views doesnt contain a profile view. So I decided to create my own using django…
Sahal Sajjad
  • 235
  • 1
  • 5
  • 18
3
votes
2 answers

'ImageFieldFile' object has no attribute 'content_type' only after picture has already been uploaded then isn't either changed or removed

I'm working on a project that uses both django registration and django profiles. I have a form that allows users edit/create a profile, which includes uploading a photo. Everything works fine in the following situations: a profile is created or…
GetItDone
  • 566
  • 7
  • 22
2
votes
1 answer

What is better way to have multiple type of member profiles in django

I see another question on stackoverflow.com whose title seems similar but that doesnot fulfil my requirements and my users are very different so only different roles will may be not work well. I have scenario of job portal where one type of user is…
Hafiz
  • 4,187
  • 12
  • 58
  • 111
2
votes
1 answer

AUTH_PROFILE_MODULE value in django when the models is not a file but a directory

I had the following: (it worked as expected) # In <..>/profile/models.py class UserProfile() #In settings.py AUTH_PROFILE_MODULE = "profile.UserProfile" I have the following: (not working) # In <..>/profile/models/__init__.py class…
Val Neekman
  • 17,692
  • 14
  • 63
  • 66
2
votes
1 answer

Django-profiles, user profile with Geo field?

I am working with django-profiles for the first time, so I might be missing something basic. I'd like to create a UserProfile model that includes geographic fields. Specifically something along these lines: class UserProfile(models.Model): user…
user1046162
  • 55
  • 1
  • 6
2
votes
1 answer

python Django fill in auto-created Profile model with User registration form

I am creating an art marketplace with django. I have the registration and the auto-create signal set up for the profile. There are three types of Users who will register on this app: Artists, Patrons, and Brokers (I call these user_status.) I would…
2
votes
2 answers

django-registration create_user() unexpected keyword

I am trying to create a custom profile to add additional fields to django-registration. Here is the code I have so far -- in models.py from django.db import models from django.contrib.auth.models import User class Profile(models.Model): user =…
David542
  • 104,438
  • 178
  • 489
  • 842
2
votes
1 answer

Django - permissions and profiles

I have a couple of different profiles. I want to associate permissions with these profiles. I've done so like this: class StudentProfile(UserProfile): school = models.CharField(max_length=30) class Meta: permissions = ( …
JPC
  • 8,096
  • 22
  • 77
  • 110
2
votes
1 answer

Extends User profile in Django

I'm trying to make editable User profile and found, how to add some fields to it... But also I need to make editable first and last name, email and one field for change user password. Now I got only user and additional fields in my form... How can I…
s.spirit
  • 343
  • 1
  • 7
  • 19
2
votes
2 answers

Temporarily upload profile image in Django during registration?

In a Django application, during registration, I want the user to be able to see the profile image he/she selects, rather than just see a path as done purely using django forms (for an example of what I want see pinterests registration form). I…
ip.
  • 3,306
  • 6
  • 32
  • 42
1
2 3 4 5