Skip to main content

configurations and settings.

Project description

Prema Django

premadjango is a Python package designed to streamline the setup of new Django projects by providing default configurations and settings.

Installation

You can install premadjango via pip:

pip install premadjango

Features

Field Validators

premadjango includes a collection of Django model field validators to ensure data integrity and consistency. These validators cover common validation scenarios and help maintain data quality within your Django models.

Basic Usage

from premadjango.models.field_validators import email_validator

class MyModel(models.Model): email = models.EmailField(validators=[email_validator])

Field Converts

premadjango offers a variety of Django model field converters to transform field values into desired formats, such as lowercase, uppercase, etc. These converters help standardize data representation and facilitate data manipulation.

Basic Usage

from premadjango.models.field_converts import LowercaseCharField

class MyModel(models.Model): name = LowercaseCharField(max_length=100)

Middleware

The package includes middleware components to enhance the functionality of Django projects. One such middleware is DisableClientSideCachingMiddleware, which disables client-side caching to ensure the most up-to-date content is served to users.

Basic Usage

To disable client-side caching, add the middleware to your MIDDLEWARE setting in the Django project's settings.py file:

MIDDLEWARE = [ # Other middleware classes... 'premadjango.middleware.DisableClientSideCachingMiddleware', ]

Response handlers

Custom response handlers in Django Rest Framework (DRF) are used to customize the structure and content of HTTP responses returned by API endpoints. By defining custom response handlers, we can standardize the response format, include additional metadata, and handle common scenarios consistently across the API.

Why Use Custom Response Handlers?

Standardized Response Format: Custom response handlers allow us to define a standardized response format for our API. This consistency makes it easier for frontend developers to understand and handle API responses.

Include Metadata: We can include additional metadata in the response, such as status codes, error messages, pagination information, and timestamps. This metadata provides valuable context to the consumers of the API.

Handle Common Scenarios: Custom response handlers enable us to handle common scenarios, such as pagination, authentication errors, and validation failures, in a centralized and consistent manner. This reduces code duplication and simplifies maintenance.

Fields Added to the Response

The custom response handler included in this project adds the following fields to the HTTP response:

Status: The HTTP status code indicating the success or failure of the request.

Message: An optional message providing additional context about the response. This field is useful for conveying success messages or error descriptions.

Total: The total number of objects in the queryset, used for pagination purposes.

Page: The current page number in the paginated results.

Next: The page number of the next page in the paginated results. This field helps users navigate through the paginated data.

Last Page: The page number of the last page in the paginated results. This field provides information about the total number of pages available.

Data: The serialized data for the current page of results. This field contains the actual objects returned by the API endpoint.

Conclusion

With premadjango, setting up new Django projects becomes more efficient and straightforward. By leveraging its default configurations, field validators, converters, and middleware, developers can focus more on building their applications rather than configuring project settings from scratch.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PremaDjango-1.0.6.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

PremaDjango-1.0.6-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file PremaDjango-1.0.6.tar.gz.

File metadata

  • Download URL: PremaDjango-1.0.6.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for PremaDjango-1.0.6.tar.gz
Algorithm Hash digest
SHA256 b0aca15f7db41d2d1d2791c5be3ada1ea0f17d8b72d00e49fa6e785def1ef0b9
MD5 3ff96112f8c8655c2c80126422446fc9
BLAKE2b-256 9b2515737e8a65bcfd32e65ee12c514bf320d99f94465d6ab4e7e1a78d3b92cf

See more details on using hashes here.

File details

Details for the file PremaDjango-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: PremaDjango-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for PremaDjango-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 daba9b2ff0003b559e4a785b1fed207a6721c55b56f5bdfb30c7192cf2c7a94f
MD5 833158237c7302a698265354c6e2e8f1
BLAKE2b-256 6508fbd685006b7d4ed073e14aca1fbd791b10eefb8ec7e5cf034481fabb115c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page