Skip to content

Commit

Permalink
Reformatted code with black
Browse files Browse the repository at this point in the history
  • Loading branch information
bmispelon committed May 21, 2024
1 parent 75a8187 commit 2d65903
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/modelsubquery/functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tools to build subqueries that produce model instances
"""

from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.functions import JSONObject
Expand All @@ -26,6 +27,7 @@ class JSONModelField(models.JSONField):
Any missing fields in the JSON object are marked as "deferred" (and will be
loaded from the db on access).
"""

# TODO: support the "pk" alias
# TODO: support fk fields (recursive __ access)
def __init__(self, model, *args, **kwargs):
Expand Down Expand Up @@ -70,6 +72,5 @@ def ModelSubquery(queryset, fields=None):
"""
jsonobj = model_to_json(queryset.model, fields=fields)
return models.Subquery(
queryset.values_list(jsonobj),
output_field=JSONModelField(queryset.model)
queryset.values_list(jsonobj), output_field=JSONModelField(queryset.model)
)
4 changes: 2 additions & 2 deletions testproject/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testproject.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand All @@ -18,5 +18,5 @@ def main():
execute_from_command_line(sys.argv)


if __name__ == '__main__':
if __name__ == "__main__":
main()
14 changes: 7 additions & 7 deletions testproject/testproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = 'insecure'
SECRET_KEY = "insecure"
DEBUG = True

INSTALLED_APPS = [
'testapp',
"testapp",
]

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"
USE_TZ = True

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

0 comments on commit 2d65903

Please sign in to comment.