In the previous chapter, you learned how to create sitemaps and feeds, and you built a search engine for your blog application. In this chapter, you will develop a social application. You will create functionality for users to login, logout, edit, and reset their password. You will learn how to create a custom profile for your users, and you will add social authentication to your site.
This chapter will cover the following points:
User
model with a custom profile modelLet's start by creating our new project.
We are going to create a social application that will allow users to share images they find on the Internet. We will need to build the following elements for this project:
This chapter addresses the first point.
Open the terminal and use the following commands to create a virtual environment for your project and activate it:
mkdir env virtualenv env/bookmarks source env/bookmarks/bin/activate
The shell prompt will display your active virtual environment as follows:
(bookmarks)laptop:~ zenx$
Install Django in your virtual environment with the following command:
pip install Django==1.8.5
Run the following command to create a new project:
django-admin startproject bookmarks
After creating the initial project structure, use the following commands to get into your project directory and create a new application named account
:
cd bookmarks/ django-admin startapp account
Remember to activate the new application in your project by adding it to the INSTALLED_APPS
setting in the settings.py
file. Place it in the INSTALLED_APPS
list before any of the other installed apps:
INSTALLED_APPS = (
'account',
# ...
)
Run the next command to sync the database with the models of the default applications included in the INSTALLED_APPS
setting:
python manage.py migrate
We are going to build an authentication system into our project using the authentication framework.