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
0
votes
1 answer

Django-registration - uncomplete stuff

I'm using django-registration and django-profiles and after having confirm the registration, I meet a 404 when I try to access to the page http://example.com/profiles/fox/ - I saw with the debug_toolbar all the queries that have been made and saw…
user1593705
0
votes
1 answer

Django - multiple profiles

In my project I have two different types of users: teacher and student, each with their own profile data. After searching for the best approach it seems the way to go forward is using multi-table inheritance: class BaseProfile(models.Model): …
Köver
  • 371
  • 4
  • 12
0
votes
1 answer

Can't accessing Django profile with query from db while it get profile of logged in user

I am developing a site in Django and having two types of profiles. One of them named Person. So I am trying to access a Person object, using following code: from django.contrib.auth.forms import UserCreationForm from django.template import…
Hafiz
  • 4,187
  • 12
  • 58
  • 111
0
votes
3 answers

Django {{ profile }} globally available in templates

I'm building app with django-registration and django-profiles. Everywhere on the page I have the section displaying data of currently logged in user (like first and last name, using syntax like: {{ user.first_name }}) and it works fine. It is done…
0
votes
1 answer

Do I need to override save method to add data to different models from django UserCreationForm

I want to add another field in UserCreationForm to be shown in RegistrationForm , I saw a couple of examples on stackoverflow for that purpose. I mean the examples by defining different RegisterForm inherited from UserCreationForm as explained in…
Hafiz
  • 4,187
  • 12
  • 58
  • 111
0
votes
1 answer

populating multi-table inherited models in django

I am using models in following way: class UserProfile: # Some Stuff class CompanyProfile(UserProfile): # Some more stuff class CandidateProfile(UserProfile): # Even more stuff mean CompanyProfile and CandidateProfile are inheriting from…
Hafiz
  • 4,187
  • 12
  • 58
  • 111
1 2 3 4
5