This Django project implements a login system, "Loginify," that includes CRUD (Create, Read, Update, Delete) operations for user management. It provides features for creating, retrieving, updating, and deleting user details through API endpoints. The project also utilizes Django's admin interface and is tested thoroughly using Postman.
- Create a virtual environment:
python -m venv django
- Activate the virtual environment:
- Windows:
django\Scripts\activate
- macOS/Linux:
source django/bin/activate
- Windows:
- Install Django:
pip install django
- Create a new Django project named "LoginSystem":
django-admin startproject LoginSystem
- Create an app named "Loginify":
python manage.py startapp Loginify
The UserDetails
model includes the following fields:
- username: Primary key (CharField, max length 50)
- email: Unique field (EmailField)
- password: CharField (max length 12)
The application provides the following CRUD views:
- Endpoint:
/loginify/signup/
- Method: POST
- Description: Creates a new user.
- Fields:
username
email
password
- Endpoint:
/loginify/users/
- Method: GET
- Description: Retrieves and displays details of all users.
- Endpoint:
/loginify/search/<email>/
- Method: GET
- Description: Retrieves a specific user's details based on their email.
- Endpoint:
/loginify/update/<email>/
- Method: POST
- Description: Updates a user's username and/or password.
- Endpoint:
/loginify/delete/<email>/
- Method: DELETE
- Description: Deletes a user based on their email.
Ensure Loginify/urls.py
contains:
from django.urls import path
from . import views
urlpatterns = [
path("hello/", views.hello, name='hello'),
path("login/", views.user_login, name='login'),
path("signup/", views.user_create, name='signup'),
path("users/", views.get_all_users, name='get_all'),
path("search/<str:email>/", views.get_by_email, name="search_by_email"),
path("update/<str:email>/", views.update_by_email, name="update_by_email"),
path("delete/<str:email>/", views.del_by_email, name="del_by_email"),
]
Include these URLs in the project's main urls.py
:
from django.urls import path, include
urlpatterns = [
path('loginify/', include('Loginify.urls')),
]
- Create a superuser to access the Django admin interface:
python manage.py createsuperuser
- Verify user creation and management through the admin panel at
/admin/
.
- URL:
http://127.0.0.1:8000/api/create/
- Method: POST
- Body (form-data):
username
:example_user
email
:[email protected]
password
:example123
- URL:
http://127.0.0.1:8000/api/users/
- Method: GET
- URL:
http://127.0.0.1:8000/api/user/[email protected]/
- Method: GET
- URL:
http://127.0.0.1:8000/api/update/[email protected]/
- Method: POST
- Body (form-data):
email
:[email protected]
password
:new_pwd@123
- URL:
http://127.0.0.1:8000/api/delete/[email protected]/
- Method: DELETE
Login_System/
|├── Loginify/
|├── __pycache__/
| |├── migrations/
| |├── __init__.py
| |├── admin.py
| |├── apps.py
| |├── models.py
|├── tests.py
| |├── views.py
| |├── urls.py
|├── Login_System/
|├── __pycache__/
| |├── __init__.py
|├── asgi.py
| |├── settings.py
| |├── urls.py
| |├── wsgi.py
|├── Static/
|├── db.sqlite3
|├── manage.py
- Run the server:
python manage.py runserver
- Apply migrations:
python manage.py makemigrations python manage.py migrate
- Access the admin panel:
http://127.0.0.1:8000/admin/
Postman:
User Signup:
All Users:
Search:
Update:
Delete:
Final List of Users:
- [Saurabh Takle] (https://github.com/saura-t) - Primary developer