Skip to main content

No project description provided

Project description

Django-Jestit Documentation

Django-Jestit is a streamlined set of Django applications and a lightweight REST framework designed to simplify user authentication, authorization, and efficient API testing. This documentation provides descriptions and examples to help you get started quickly.

Why Django-Jestit?

We built Django-Jestit to address the complexity and overhead of existing REST frameworks. Many frameworks are feature-heavy, making them cumbersome for projects that require simplicity, speed, and robust security.

Key Differentiators

  • Lightweight Framework: Django-Jestit is minimalistic, providing an easy way to add REST APIs to your Django models without unnecessary complexity.

  • Built-in Security: Security is integral to Django-Jestit. We offer an alternative to Django's built-in permissions system, automatically protecting your REST APIs and data.

  • Robust Object-Level Permission System: Unlike Django's native model-level permissions, Django-Jestit provides a simple yet robust permission system at the object level. This allows fine-grained control, enabling permissions to be applied to individual objects and extended to both user and group levels.

  • Effortless Integration: Adding REST endpoints to your models is straightforward, enabling rapid development without compromising security or performance.

With Django-Jestit, you get a simple, efficient framework with powerful security features designed for developers who value speed and control.

Table of Contents

  1. Overview
  2. Installation
  3. Authit - Authentication and Authorization
  4. Jestit - REST framework
  5. Testit - Testing Suite
  6. Taskit - Task Runner
  7. Utilities

Overview

Django-Jestit is a collection of Django-based applications focused on authentication, task management, and testing. These tools are built to enhance development efficiency by providing utilities for common requirements such as user management, token-based authentication, and automated testing.

Installation

pip install django-jestit

Authit

The Authit application manages authentication and authorization using JSON Web Tokens (JWT). It includes models to represent users and groups, and middleware to handle JWT authentication.

JWT Authentication

The JWTAuthenticationMiddleware is a critical component that checks the validity of JWT tokens accompanying HTTP requests.

Example: Middleware Setup

To use the JWT middleware, add it to the middleware list in your Django settings:

MIDDLEWARE = [
    # other middleware classes
    'authit.middleware.jwt.JWTAuthenticationMiddleware',
]

The middleware checks for JWT tokens in the Authorization header of requests and validates them. If validation fails, it returns an appropriate JSON response with an error message.

Models

Authit's models define the structure of users and groups in the system.

  • User: The primary model for user management with fields like username, email, password, and permissions.
  • Group: Represents groups that users can belong to, with a hierarchical structure.
  • GroupMember: Manages the membership of users in groups, along with specific group permissions.

Authit REST API

Authit provides RESTful endpoints for managing users and groups. These endpoints leverage Django's request handling framework and custom decorators for URL routing.

Example: User REST API

Users can be managed through RESTful operations. Here’s how you can interact with the user API:

  • Create a User: POST to /api/authit/user with user data.
  • Retrieve Users: GET from /api/authit/user to fetch all users or /api/authit/user/<int:id> for a specific user.
  • Update a User: PUT to /api/authit/user/<int:id> with updated user data.
  • Delete a User: DELETE from /api/authit/user/<int:id>.

Jestit

Jestit offers a lightweight framework for building REST APIs in Django. It features decorators for automatic URL mapping and serialization tools for data transfer.

URL Decorators

The @jd.URL and other suffix decorators like @jd.GET, @jd.POST, etc., register view functions with specific URL patterns and HTTP methods.

Example: Registering a URL

from jestit.decorators import URL, GET

@URL('myresource')
@GET
def my_view_function(request):
    # handle GET request for /myresource
    return JsonResponse({'message': 'Hello, Jestit!'})

GraphSerializer

GraphSerializer is a custom serialization mechanism that uses model-defined graphs for data conversion.

Example: Using GraphSerializer

serializer = GraphSerializer(instance=my_model_instance, graph='default')
json_data = serializer.to_json()

This approach allows customization of serialized output by defining graphs in your model's RestMeta class.

Testit

Testit is a testing suite designed to run unit tests for your Django applications efficiently.

Writing Tests

Testit facilitates organizing tests in modules, with decorators to mark and describe each test.

Example: Using the Test Decorator

from testit.helpers import unit_test

@unit_test("Verifying addition logic")
def test_addition():
    assert 1 + 1 == 2, "Addition failed"

Running Tests

You can run tests using testit.runner.main() by specifying options.

python jestit/testit/runner.py --module authit --verbose

These tests streamline application and API validation with clear summaries upon completion.

Taskit

Taskit includes the RedisSubscriber class for subscribing to Redis channels. It processes messages asynchronously using multithreading.

Example: Subscribing to a Redis Channel

from redis import Redis
from taskit.runner import RedisSubscriber

def process_task(data):
    # handle incoming task
    task_type = data['type']
    # do something with the task

redis_subscriber = RedisSubscriber(redis_connection=Redis(), channels=['my_channel'])
redis_subscriber.start_listening()

Utilities

Django-Jestit also offers various helper utilities, ranging from logging (logit) to cryptographic operations. Familiarize yourself with these utilities to further refine your project's functionality.


Django-Jestit optimizes the way you handle authentication, build REST APIs, and conduct testing. By using these integrated applications and utilities, you can significantly enhance your development workflow in a Django environment.

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

django_jestit-0.1.13.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_jestit-0.1.13-py3-none-any.whl (55.1 kB view details)

Uploaded Python 3

File details

Details for the file django_jestit-0.1.13.tar.gz.

File metadata

  • Download URL: django_jestit-0.1.13.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.16 Darwin/24.3.0

File hashes

Hashes for django_jestit-0.1.13.tar.gz
Algorithm Hash digest
SHA256 c464fa35d997ffb047ca669dc37eebe7dea46fd6531d7d5e34276fc834a9e8b0
MD5 4591686ab7103fa1483bfcb491ac5c6c
BLAKE2b-256 236f68aa2cc549c07d1a6763e66e56a2d9f97a975e98b869fed9c7f113f45102

See more details on using hashes here.

File details

Details for the file django_jestit-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: django_jestit-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 55.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.16 Darwin/24.3.0

File hashes

Hashes for django_jestit-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 216c1145c673b0cbe5764cd39581962d5e19bfd737ddfbc00691c7e7879ea99e
MD5 84ea07810751dfca37ff0d3a748b5ba5
BLAKE2b-256 6f207cca8ef71b3b26833b6a9970b3afd7e19e2f8327e5a51edde7337baec7a6

See more details on using hashes here.

Supported by

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