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.
  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.0.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.0.0
File Size Uploaded Provenance Actions
django_bidi_input-1.0.0.tar.gz 6.2 kB With provenance Details for django_bidi_input-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 12.1 kB

Release files / django_bidi_input-1.0.0.tar.gz

Download URL django_bidi_input-1.0.0.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
972157e844cf627fe72f2ef6fa12418679dd3b355184881426dbfec1e207f357
BLAKE2b-256 checksum
How to use checksums
c500223587dd577b1d79129ca64f9402be5c1d1d5b05eee41bdf5d65480b9595
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.0.0-py3-none-any.whl

Download URL django_bidi_input-1.0.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d64b787b6e5da83377323d75d2e2479b9ef9fa396c7dbf5364a1d7999594605
BLAKE2b-256 checksum
How to use checksums
132590f51a1eec353fd7ea538d599e98da8cfe30500c5b43ce0d111af73dfa04
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.0.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.0.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