A Django-based RESTful API application for managing employer information with custom user authentication using Django REST Framework (DRF) and Simple JWT.
The Employer Management System is designed to provide a robust API for managing employer details. It features custom user authentication with email and password login, token-based authentication using Simple JWT, and CRUD operations for employers. Each employer is associated with a user.
- Custom User Authentication:
- Register new users with email and password.
- Login to generate JWT tokens (access and refresh).
- Retrieve the current user's profile.
- Employer Management:
- Create, list, retrieve, update, and delete employer records.
- Only the owner of the employer record has permission to get list, create, update and delete.
- Employers are linked to users (one user can have multiple employers).
- API Endpoints:
POST /api/auth/signup/- Register a new user.POST /api/auth/login/- Login and get JWT tokens.GET /api/auth/profile/- Get logged-in user's profile.POST /api/employers/- Create an employer.GET /api/employers/- List all employers for the logged-in user.GET /api/employers/<id>/- Retrieve a specific employer.PUT /api/employers/<id>/- Update a specific employer.DELETE /api/employers/<id>/- Delete a specific employer.
EmployerManagement/
├── accounts/
│ ├── __init__.py
│ ├── models.py
│ ├── serializers.py
│ ├── urls.py
│ └── views.py
├── employer/
│ ├── __init__.py
│ ├── models.py
│ ├── permissions.py
│ ├── serializers.py
│ ├── urls.py
│ └── views.py
├── EmployerManagement/
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
├── postmanCollection
│ ├── EmployerManagement.postman_collection.json
├── .gitignore
├── LICENSE
├── manage.py
├── README.md
└── requirements.txt
- Python 3.12.3
- pip (Python package manager)
- Virtualenv
-
Clone the repository:
git clone https://github.com/imsnto/EmployerManagement.git cd EmployerManagement -
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Apply migrations:
python manage.py makemigrations python manage.py migrate
-
Create a superuser for admin access:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
- Import this file
postmanCollection/EmployerManagement.postman_collection.jsonto your postman workspace. - Update collection variables
access_tokenandbase_url(if needed). - Access token valid for 60 minutes. After 60 minutes you need to generate access token again and update varible
access_token.
- Authentication:
- Register a user via
POST /api/auth/signup/with
{ "first_name": "<your-first-name>", "last_name": "<your-last-name>", "email": "<user@example.com>", "password": "<your-password>", "password2": "<your-password>" }- Login via
POST /api/auth/login/to get JWT tokens:
{ "email": "<your-email>", "password": "<password>" }- Use the access token in the
Authorizationheader (e.g.,Bearer <token>) for protected endpoints. - Retrieve profile via
GET /api/auth/profile/.
- Register a user via
- Employer Management:
- Create an employer via
POST /api/employers/with
{ "contact_person_name": "<name>", "company_name": "<your-comapny-name>", "email": "<your-email>", "phone_number": "<your-phone>", "address": "<your-address>" }- List employers via
GET /api/employers/. - Retrieve, update, or delete an employer via
GET,PUT, orDELETE /api/employers/<id>/.
- Create an employer via
- Uses a custom User model extending
AbstractBaseUserandPermissionsMixin. - Token-based authentication with
djangorestframework-simplejwt. - All
/employers/endpoints require authentication and restrict access to the logged-in user's employers.
