Commit f6b5dd24 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

parsemail: Setup Django right after importing

If we won't do that importing some of the classes (e.g. User) will cause
and exception complaining about apps not being loaded with newer Django.

Because of this we also have to add an exception for module level
imports that are not on the top (i.e. before any actual code).
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <>
parent d39c994e
......@@ -36,7 +36,11 @@ import re
import sys
import weakref
# we have to setup django before we import anything!
import django
if __name__ == '__main__':
from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import MultipleObjectsReturned
......@@ -860,7 +864,6 @@ def lock():
def main(args):
logger = setup_error_handler()
parser = argparse.ArgumentParser()
parse_lock = None
......@@ -24,7 +24,7 @@ deps = flake8
commands = flake8 {posargs:patchwork patchwork/bin/pwclient git-pw/git-pw}
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E203,E241,E251,H405,F405
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E203,E241,E251,E402,H405,F405
exclude = ./patchwork/migrations
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment