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.4.tar.gz (35.7 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.4-py3-none-any.whl (49.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_jestit-0.1.4.tar.gz
  • Upload date:
  • Size: 35.7 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.4.tar.gz
Algorithm Hash digest
SHA256 c1b799511bdb051221650d5d063ce7b0e45b99fd4264ec4b4c49a11462841429
MD5 3b92a87887ac6f8c0ae51a189ffba9b9
BLAKE2b-256 0bc440f49bce07df1a8f7330910eef209ca4ed83a4ad6805b1bd1824043d5a0d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_jestit-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 49.0 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d05c1de1262688504e780afdd45263899ad57dc4eb1e09f94bef1a1bf3dd9ce0
MD5 d02243ce55d9222aed994ead542e0b39
BLAKE2b-256 f9b4862451d5660ac1a267dc8cf536f13c272a849e97b611b8ba874ce8421b08

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