Long Django query statements

I have a preference to wrap long Django queries like this:

for p58 in (Piece2x2
            .objects
            .filter(side4=p58_exp_s4,
                    side1__in=p58_exp_s1_set)
            .exclude(nr1__in=used1)
            .exclude(nr2__in=used1)
            .exclude(nr3__in=used1)
            .exclude(nr4__in=used1)):
 

How to configure PyCharm to get this indentation behavior?

When I break a line at the dot it gets indented a static amount (8 in my case) while function call parameters are nicely aligned with the initial parenthesis (see below).

def long_function_with_many_args(self,
                                 long_argument_1: int,
                                 long_argument_2: list,
                                 optional_extra_arguments="this is an example"):
 

Suggestions which settings that could help?

More pythonic layout suggestions are also welcome  :-)

Ramon

0
1 comment
Hello, 
Unfortunately, there is no way to configure this code style in the current PyCharm release.
But if Black supports this, you can set black formatter by following this guide: https://www.jetbrains.com/help/pycharm/reformat-and-rearrange-code.html#format-python-code-with-black
0

Please sign in to leave a comment.