Sale!

Soft Deletion Project in Django | Apycoder

(5 customer reviews)

Original price was: ₹199.00.Current price is: ₹0.00.

+ Free Shipping

This Django project is a simple contact management system that allows users to view, create, and soft-delete contacts. Soft deletion is implemented to mark contacts as deleted without permanently removing them from the database.

Models: The project has a single model, Contact, defined in the models.py file. This model represents contact information, including the first name, last name, email, phone number, and a message. The model also includes a Boolean field is_deleted to track whether a contact has been soft-deleted.

Indian rupee (₹) - INR
  • Indian rupee (₹) - INR
  • United States dollar ($) - USD
  • Russian ruble (₽) - RUB
Category:

Soft Deletion Implementation: The Contact model has a custom delete method that overrides the default delete method. Instead of permanently deleting the contact, this method sets the is_deleted field to True and saves the object. The soft-deletion logic is encapsulated within this method.

def delete(self, using=None, keep_parents=False):
self.is_deleted = True
self.save()

Views: The project includes several views in the views.py file:

  • contact_list: Renders the list of contacts, excluding those marked as soft-deleted (is_deleted=False).
  • contact_detail: Displays detailed information for a specific contact.
  • soft_delete_contact: Marks a contact as soft-deleted when a POST request is received. Redirects to the contact list after soft deletion.
  • create_contact: Handles both GET and POST requests for creating a new contact. On a POST request, a new contact is created, and the user is redirected to the contact list.

Templates: The templates are located in the contacts directory and include:

  • contact_list.html: Displays a list of contacts.
  • contact_detail.html: Shows detailed information for a specific contact.
  • create_contact.html: Form for creating a new contact.

API Call: The requests library is imported to facilitate potential integration with external APIs or services, though this feature is not implemented in the current code.

Soft Deletion in Action: The key feature of this project is the soft deletion of contacts. When a contact is marked for deletion using the soft_delete_contact view, it is not immediately removed from the database. Instead, the is_deleted field is set to True. This approach allows for the recovery of deleted contacts and maintains a more audit-friendly data history.

Feel free to explore and customize this project for your specific needs. The soft deletion mechanism can be extended to include additional functionality, such as a trash bin or recovery options for deleted contacts.

5 reviews for Soft Deletion Project in Django | Apycoder

There are no reviews yet.

Be the first to review “Soft Deletion Project in Django | Apycoder”

Your email address will not be published. Required fields are marked *

Shopping Basket