DEV Community

Cover image for django framework
Asina Abdullahi
Asina Abdullahi

Posted on

django framework

Building PetPal with Django: Authentication, User Roles, and a Pet Adoption System
Introduction

As part of a Django assignment, I was required to start from an existing Django starter template and build a complete web application with a fully functional authentication system. Instead of creating a simple CRUD application, I decided to build PetPal, a pet adoption platform that allows adopters to browse pets and submit adoption requests while giving shelter administrators tools to manage pets and requests.

This article walks through my development process, the challenges I faced, and what I learned.

Project Requirements

The project had several requirements:

Build from the provided Django starter template
User registration
User login
Password reset
Password change
Profile image upload
At least two user types
Tailwind CSS frontend
Progressive Web App (PWA) features
Deploy the application
Write documentation
Choosing My Project

I chose to build PetPal, a simple pet adoption management system.

The application has two types of users:

Adopters
Shelter Administrators

This separation made the application feel more realistic and allowed me to implement role-based functionality.

Authentication

The starter template already included Django authentication using django-allauth.

I customized it to support:

User Registration
User Login
Forgot Password
Password Reset
Password Change
Logout

I also configured user profile images so every user can upload their own avatar.

User Roles

One of the assignment requirements was supporting multiple user types.

I implemented two roles:

Adopter

An adopter can:

Register
Login
Browse available pets
View pet details
Submit adoption requests
View only their own requests
Cancel pending requests
Update their profile
Shelter Admin

The shelter administrator can:

Add pets
Edit pets
Delete pets
View all adoption requests
Approve requests
Reject requests
Manage available pets
Database Design

The application revolves around three main models.

Custom User

I used the starter template's custom user model and extended it with:

Profile picture
User type
Pet

Each pet stores:

Name
Species
Breed
Age
Gender
Description
Image
Status
Adoption Request

Each adoption request stores:

User
Pet
Request status
Date submitted

The relationships between these models make it easy to track which user requested which pet.

Pet Adoption Workflow

The application follows a simple workflow.

The user logs in.
The user browses available pets.
The user opens a pet's details page.
The user submits an adoption request.
The request is marked as Pending.
The administrator reviews the request.
The administrator either approves or rejects it.
If approved, the pet is marked as adopted and is no longer shown in the available pets list.

This prevents multiple users from requesting the same adopted pet.

User Dashboard

The adopter dashboard focuses on personal information.

It displays:

Number of adoption requests
Pending requests
Approved requests
Quick navigation to Browse Pets
Quick navigation to My Requests

The My Requests page only shows requests belonging to the currently logged-in user.

Pending requests can be cancelled, while approved and rejected requests become read-only.

Admin Dashboard

The administrator dashboard focuses on management rather than browsing.

It includes:

Pet management
Adoption request management
User management
Dashboard statistics

This creates a clear separation between the administrator and adopter experiences.

Challenges I Faced

Like most Django projects, development wasn't completely smooth.

Some challenges included:

Configuring the starter template correctly.
Understanding how Django's authentication system works.
Connecting models using foreign keys.
Preventing duplicate adoption requests.
Making sure users only see their own requests.
Configuring password reset emails using Gmail SMTP.
Preparing the application for deployment.

Each challenge helped me better understand how Django handles authentication, models, views, templates, and permissions.

Technologies Used
Django
Python
HTML
Tailwind CSS
SQLite (development)
PostgreSQL (production)
Django Allauth
Git
GitHub
What I Learned

This project taught me much more than creating CRUD pages.

I learned how to:

Extend Django's custom user model
Implement role-based access control
Handle image uploads
Build authentication flows
Connect related models
Manage user permissions
Build a real-world application using Django

Most importantly, I gained confidence working with Django's project structure and understanding how different components fit together.

Future Improvements

Some features I would like to add include:

Email notifications for adoption status updates
Search and filtering by species or breed
Favorite pets
Shelter profiles
Adoption history
Appointment scheduling
Admin analytics dashboard
Conclusion

Building PetPal allowed me to apply Django concepts to a practical problem. Instead of focusing only on authentication, I built an application with meaningful user roles, profile management, and a complete adoption workflow.

Although there were challenges along the way, solving them improved my understanding of Django development and prepared me for building larger web applications in the future.

Thank you for reading!

Top comments (0)