Skip to content

Django request middleware and auto CSRF for unsafe requests #56

Description

@MarcusL11

Hi! I've been using Datastar with Django for some time now and loving it! I would like to get your guys feedback on expanding the Django module with two additional features (1) a request metadata middleware and; (2) a CSRF bridge for unsafe requests.

The proposed API would include:

  • is_datastar(request) that detects Datastar-Request: true
  • DatastarDetails, providing boolean request metadata
  • DatastarHttpRequest, as a typing contract for request.datastar
  • DatastarMiddleware, supporting sync and async Django middleware

I have a PoC for this called django-datastar. If this fits the intended scope of datastar-py I'm happy to open a PR on it!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions