0

I need to work with Persian language. Persian is right aligned so I want the labels of model fields to appear on the right side of the input box.

I tried to change the admin page CSS but it didn't work.(I changed text-aligned to right-aligned).

markwalker_
  • 12,078
  • 7
  • 62
  • 99
behnam.m
  • 41
  • 5

1 Answers1

0

Could try adding this to the css:

.form-row div {
    display:flex;
    flex-direction: row-reverse;
}

You could also use direction: rtl instead of flex-direction: row-reverse This works because the structure of the generated html will be something like:

<div class="form-row>
    <div>
        <label ...>
        <input ...>
    </div>
</div>

Depending on how complicated the layout it, this might not work 100%, I've not looked at how it will affect inlines and other ways you can lay things out in the django-admin, but some variation of it should fix your basic problem.

tim-mccurrach
  • 6,395
  • 4
  • 23
  • 41
  • Thank you so much. I used the code you suggested but I change `direction: row-reverse;` to `direction: rtl;` and It worked! – behnam.m May 06 '20 at 09:07
  • Ah, my bad. That should have said `flex-direction: row-reverse`. But yes, `direction: rtl` works just as well. I'll update my answer. If you're happy with it as the correct answer please give it an upvote, and tick to accept it as correct. – tim-mccurrach May 06 '20 at 10:25
  • @behnam.m if you're happy with this answer, could you accept it and upvote it. Thanks :) – tim-mccurrach May 29 '20 at 12:39