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 }}" />