Skip to main content

django-bidi-input

Django doesn't let you control the text direction of individual form/admin input fields — when a site's language is RTL (Farsi, Arabic, Hebrew, ...), every input renders RTL, including fields where that's wrong: email, URL, slug, UUID, IP address, numbers, passwords, phone numbers, etc. Only free text fields should follow the page direction.

This has been an accepted Django ticket (#35482) for a while with no implementation yet. django-bidi-input fixes it today, without patching Django, for both admin and regular forms.

Install

pip install django-bidi-input
INSTALLED_APPS = [
    ...,
    "django_bidi_input",
]

That's it. Every ModelForm, plain Form, and admin form in your project now gets a correct dir attribute (and a bidi-input-ltr/bidi-input-rtl CSS class as a fallback) on each field, automatically.

How direction is decided

For each field, in order (first match wins):

  1. You already set dir on the widget yourself — left untouched.
  2. direction set directly on the model field instance:
    phone_number = models.CharField(max_length=32)
    phone_number.direction = "ltr"
    
  3. BIDI_INPUT_OVERRIDES setting, for fields you can't edit directly (third-party app models, etc.):
    BIDI_INPUT_OVERRIDES = {
        "myapp.Contact.phone_number": "ltr",
    }
    
  4. Built-in default, in order:
    • widget input_type is password, number, tel, date, time, etc.
    • widget autocomplete is username, email, tel, new-password, current-password, one-time-code. This is what makes Django's own admin/auth login form (username + password) render LTR, even though UsernameField is a plain CharField — Django sets autocomplete="username" on it unconditionally, including when a custom user model uses USERNAME_FIELD = "email".
    • field class is EmailField, URLField, SlugField, UUIDField, GenericIPAddressField, FilePathField, IntegerField, FloatField, DecimalField, DurationField, RegexField, JSONField, DateField, DateTimeField, TimeField, SplitDateTimeField (the two-input widget admin uses for DateTimeField by default — dir propagates to both boxes). Date/time fields need this class-based check specifically because Django's date/time widgets render as <input type="text">, not native HTML5 type="date"/type="time", even in admin.
  5. Otherwise left alone — inherits the page's direction (correct for plain CharField/TextField).

Settings

Setting Default Purpose
BIDI_INPUT_ENABLED True Turn the whole thing off.
BIDI_INPUT_OVERRIDES {} "app_label.Model.field": "ltr"/"rtl" map.
BIDI_INPUT_LTR_FIELD_CLASSES see conf.py Dotted paths of extra form field classes to treat as LTR.
BIDI_INPUT_LTR_INPUT_TYPES see conf.py Extra widget input_type values to treat as LTR.
BIDI_INPUT_LTR_AUTOCOMPLETE_VALUES see conf.py Extra widget autocomplete values to treat as LTR.

Why this works for admin too

Django admin builds its forms as ordinary ModelForm subclasses via modelform_factory. This package hooks BaseForm.__init__ once, so admin inherits the behavior automatically — no ModelAdmin changes needed.

Scope

This targets the actual pain point: Django admin and Django forms. It does not attempt to make direction a real Field kwarg (that requires changing Django itself, which is what ticket #35482 is for), so introspection-based tools built outside the forms API (DRF serializers, etc.) won't see it.

Running the tests

pip install -e ".[test]"
pytest

Metadata

Release files for django-bidi-input 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-bidi-input 1.1.0
File Size Uploaded Provenance Actions
django_bidi_input-1.1.0.tar.gz 6.7 kB With provenance Details for django_bidi_input-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-bidi-input 1.1.0
File Interpreter ABI Platform Actions
django_bidi_input-1.1.0-py3-none-any.whl Python 3 none any Details for django_bidi_input-1.1.0-py3-none-any.whl

Total release size: 12.8 kB

Release files / django_bidi_input-1.1.0.tar.gz

Download URL django_bidi_input-1.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9968bd56c95e590ae4a1902d7f74490694b05ba2b5b062a909e5df88c5b965d3
BLAKE2b-256 checksum
How to use checksums
27b6e5c855d87896465cf93c20117d88bd3723e1ff1d7af73366f969060ba33a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / django_bidi_input-1.1.0-py3-none-any.whl

Download URL django_bidi_input-1.1.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
136249130b932a13957748e6b13a6e1740e5cbe8eee100dd484fe2eafcdbe259
BLAKE2b-256 checksum
How to use checksums
ab1b087b5c5f5b3d794e0d69a8f1dcd7e0082a4becdebcede003918b81d7435c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Security for django-bidi-input 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_bidi_input-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page