From fd25955dfddeaa060f21f8601b2d1b7d8ce67307 Mon Sep 17 00:00:00 2001 From: dalrrard <8892319+dalrrard@users.noreply.github.com> Date: Wed, 13 Oct 2021 05:41:19 -0500 Subject: [PATCH 1/3] Add django-admin startapp template django-admin has a --template flag that lets you specify a directory to base new apps off of. I've added a `startapp_template` directory to the top level directory, updated the post gen hook to remove any files that may not be needed, and updated the documentation for this new process. --- docs/troubleshooting.rst | 4 ++-- hooks/post_gen_project.py | 4 ++++ .../startapp_template/__init__.py-tpl | 0 .../startapp_template/admin.py-tpl | 5 +++++ .../startapp_template/api/serializers.py-tpl | 3 +++ .../startapp_template/api/views.py-tpl | 2 ++ .../startapp_template/apps.py-tpl | 6 ++++++ .../startapp_template/forms.py-tpl | 5 +++++ .../startapp_template/migrations/__init__.py-tpl | 0 .../startapp_template/models.py-tpl | 5 +++++ .../startapp_template/tasks.py-tpl | 3 +++ .../startapp_template/tests/__init__.py-tpl | 0 .../startapp_template/tests/factories.py-tpl | 6 ++++++ .../startapp_template/tests/test_admin.py-tpl | 5 +++++ .../startapp_template/tests/test_drf_urls.py-tpl | 5 +++++ .../startapp_template/tests/test_drf_views.py-tpl | 5 +++++ .../startapp_template/tests/test_forms.py-tpl | 8 ++++++++ .../startapp_template/tests/test_models.py-tpl | 4 ++++ .../startapp_template/tests/test_urls.py-tpl | 5 +++++ .../startapp_template/tests/test_views.py-tpl | 12 ++++++++++++ .../startapp_template/views.py-tpl | 5 +++++ 21 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/startapp_template/__init__.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/admin.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/api/serializers.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/apps.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/forms.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/migrations/__init__.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/models.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/__init__.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/factories.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/test_admin.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/test_drf_urls.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/test_drf_views.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/test_forms.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/test_models.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/test_urls.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/tests/test_views.py-tpl create mode 100644 {{cookiecutter.project_slug}}/startapp_template/views.py-tpl diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 8aa1b1f9be..2df9db3447 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -45,7 +45,7 @@ Others #. ``jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'.``: please upgrade your cookiecutter version to >= 1.4 (see `#528`_) -#. New apps not getting created in project root: This is the expected behavior, because cookiecutter-django does not change the way that django startapp works, you'll have to fix this manually (see `#1725`_) +#. To create a new app using the recommended directory structure, run `django-admin startapp --template=../startapp_template myappname` from inside the project root. This template can be customized to suit your needs. (see `startapp`_) .. _#528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373 -.. _#1725: https://github.com/pydanny/cookiecutter-django/issues/1725#issuecomment-407493176 +.. _startapp: https://docs.djangoproject.com/en/dev/ref/django-admin/#startapp diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ede14c324c..1c85288f34 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -101,6 +101,7 @@ def remove_celery_files(): os.path.join( "{{ cookiecutter.project_slug }}", "users", "tests", "test_tasks.py" ), + os.path.join("startapp_template", "tasks.py-tpl"), ] for file_name in file_names: os.remove(file_name) @@ -318,6 +319,9 @@ def remove_drf_starter_files(): "{{cookiecutter.project_slug}}", "users", "tests", "test_drf_views.py" ) ) + shutil.rmtree(os.path.join("startapp_template", "api")) + os.remove(os.path.join("startapp_template", "tests", "test_drf_urls.py-tpl")) + os.remove(os.path.join("startapp_template", "tests", "test_drf_views.py-tpl")) def remove_storages_module(): diff --git a/{{cookiecutter.project_slug}}/startapp_template/__init__.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/__init__.py-tpl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/{{cookiecutter.project_slug}}/startapp_template/admin.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/admin.py-tpl new file mode 100644 index 0000000000..ec53222463 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/admin.py-tpl @@ -0,0 +1,5 @@ +"""Define and register {{ '{{' }} app_name {{ '}}' }} app admin models.""" +from django.contrib import admin + +# Register your models here. + diff --git a/{{cookiecutter.project_slug}}/startapp_template/api/serializers.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/api/serializers.py-tpl new file mode 100644 index 0000000000..a3a5630ac3 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/api/serializers.py-tpl @@ -0,0 +1,3 @@ +"""Define serializers for the {{ '{{' }} app_name {{ '}}' }} api.""" +from rest_framework import serializers + diff --git a/{{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl new file mode 100644 index 0000000000..88fcce611a --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl @@ -0,0 +1,2 @@ +"""Define API views for {{ '{{' }} app_name {{ '}}' }} app.""" + diff --git a/{{cookiecutter.project_slug}}/startapp_template/apps.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/apps.py-tpl new file mode 100644 index 0000000000..dd0f30a5a1 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/apps.py-tpl @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class {{ '{{' }} camel_case_app_name {{ '}}' }}Config(AppConfig): + name = '{{ "{{" }} app_name {{ "}}" }}' + diff --git a/{{cookiecutter.project_slug}}/startapp_template/forms.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/forms.py-tpl new file mode 100644 index 0000000000..2882cd9ccc --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/forms.py-tpl @@ -0,0 +1,5 @@ +"""Define {{ '{{' }} app_name {{ '}}' }} app forms.""" +from django.utils.translation import gettext_lazy as _ + +# Create your forms here. + diff --git a/{{cookiecutter.project_slug}}/startapp_template/migrations/__init__.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/migrations/__init__.py-tpl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/{{cookiecutter.project_slug}}/startapp_template/models.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/models.py-tpl new file mode 100644 index 0000000000..35238c9f53 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/models.py-tpl @@ -0,0 +1,5 @@ +"""Define {{ '{{' }} app_name {{ '}}' }} app models.""" +from django.db import models + +# Create your models here. + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl new file mode 100644 index 0000000000..305d5a8607 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl @@ -0,0 +1,3 @@ +"""Define {{ '{{' }} app_name {{ '}}' }} app Celery tasks.""" +from config import celery_app + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/__init__.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/__init__.py-tpl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/factories.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/factories.py-tpl new file mode 100644 index 0000000000..cb0bed8bc1 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/factories.py-tpl @@ -0,0 +1,6 @@ +"""Define factories to generate testing data.""" +from typing import Any, Sequence + +from factory import Faker, post_generation +from factory.django import DjangoModelFactory + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_admin.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_admin.py-tpl new file mode 100644 index 0000000000..a3da079fb0 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_admin.py-tpl @@ -0,0 +1,5 @@ +import pytest +from django.urls import reverse + +pytestmark = pytest.mark.django_db + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_urls.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_urls.py-tpl new file mode 100644 index 0000000000..3715e52232 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_urls.py-tpl @@ -0,0 +1,5 @@ +import pytest +from django.urls import resolve, reverse + +pytestmark = pytest.mark.django_db + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_views.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_views.py-tpl new file mode 100644 index 0000000000..39c952bebd --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_views.py-tpl @@ -0,0 +1,5 @@ +import pytest +from django.test import RequestFactory + +pytestmark = pytest.mark.django_db + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_forms.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_forms.py-tpl new file mode 100644 index 0000000000..17ce40abdf --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_forms.py-tpl @@ -0,0 +1,8 @@ +""" +Module for all {{ '{{' }} app_name {{ '}}' }} Form Tests. +""" +import pytest +from django.utils.translation import gettext_lazy as _ + +pytestmark = pytest.mark.django_db + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_models.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_models.py-tpl new file mode 100644 index 0000000000..0a5f0ae47b --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_models.py-tpl @@ -0,0 +1,4 @@ +import pytest + +pytestmark = pytest.mark.django_db + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_urls.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_urls.py-tpl new file mode 100644 index 0000000000..3715e52232 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_urls.py-tpl @@ -0,0 +1,5 @@ +import pytest +from django.urls import resolve, reverse + +pytestmark = pytest.mark.django_db + diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_views.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_views.py-tpl new file mode 100644 index 0000000000..b765faef09 --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_views.py-tpl @@ -0,0 +1,12 @@ +import pytest +from django.conf import settings +from django.contrib import messages +from django.contrib.auth.models import AnonymousUser +from django.contrib.messages.middleware import MessageMiddleware +from django.contrib.sessions.middleware import SessionMiddleware +from django.http import HttpRequest +from django.test import RequestFactory +from django.urls import reverse + +pytestmark = pytest.mark.django_db + diff --git a/{{cookiecutter.project_slug}}/startapp_template/views.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/views.py-tpl new file mode 100644 index 0000000000..70ed4c90cd --- /dev/null +++ b/{{cookiecutter.project_slug}}/startapp_template/views.py-tpl @@ -0,0 +1,5 @@ +"""Define {{ '{{' }} app_name {{ '}}' }} app views.""" +from django.shortcuts import render + +# Create your views here. + From 1faa3fbdc71a8f4380e1749531948efe6fcdd6b9 Mon Sep 17 00:00:00 2001 From: dalrrard <8892319+dalrrard@users.noreply.github.com> Date: Wed, 13 Oct 2021 06:05:53 -0500 Subject: [PATCH 2/3] Fix ends of files --- {{cookiecutter.project_slug}}/startapp_template/admin.py-tpl | 1 - {{cookiecutter.project_slug}}/startapp_template/apps.py-tpl | 1 - {{cookiecutter.project_slug}}/startapp_template/forms.py-tpl | 1 - {{cookiecutter.project_slug}}/startapp_template/models.py-tpl | 1 - {{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl | 1 - .../startapp_template/tests/factories.py-tpl | 1 - .../startapp_template/tests/test_admin.py-tpl | 1 - .../startapp_template/tests/test_forms.py-tpl | 1 - .../startapp_template/tests/test_models.py-tpl | 1 - .../startapp_template/tests/test_urls.py-tpl | 1 - .../startapp_template/tests/test_views.py-tpl | 1 - {{cookiecutter.project_slug}}/startapp_template/views.py-tpl | 1 - 12 files changed, 12 deletions(-) diff --git a/{{cookiecutter.project_slug}}/startapp_template/admin.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/admin.py-tpl index ec53222463..e56681f781 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/admin.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/admin.py-tpl @@ -2,4 +2,3 @@ from django.contrib import admin # Register your models here. - diff --git a/{{cookiecutter.project_slug}}/startapp_template/apps.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/apps.py-tpl index dd0f30a5a1..12c0725ad1 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/apps.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/apps.py-tpl @@ -3,4 +3,3 @@ from django.apps import AppConfig class {{ '{{' }} camel_case_app_name {{ '}}' }}Config(AppConfig): name = '{{ "{{" }} app_name {{ "}}" }}' - diff --git a/{{cookiecutter.project_slug}}/startapp_template/forms.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/forms.py-tpl index 2882cd9ccc..1b2c3801f9 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/forms.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/forms.py-tpl @@ -2,4 +2,3 @@ from django.utils.translation import gettext_lazy as _ # Create your forms here. - diff --git a/{{cookiecutter.project_slug}}/startapp_template/models.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/models.py-tpl index 35238c9f53..c971bbcbc3 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/models.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/models.py-tpl @@ -2,4 +2,3 @@ from django.db import models # Create your models here. - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl index 305d5a8607..8174f8b0ef 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tasks.py-tpl @@ -1,3 +1,2 @@ """Define {{ '{{' }} app_name {{ '}}' }} app Celery tasks.""" from config import celery_app - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/factories.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/factories.py-tpl index cb0bed8bc1..86c4c6a70a 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tests/factories.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/factories.py-tpl @@ -3,4 +3,3 @@ from typing import Any, Sequence from factory import Faker, post_generation from factory.django import DjangoModelFactory - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_admin.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_admin.py-tpl index a3da079fb0..875dbf7886 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tests/test_admin.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_admin.py-tpl @@ -2,4 +2,3 @@ import pytest from django.urls import reverse pytestmark = pytest.mark.django_db - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_forms.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_forms.py-tpl index 17ce40abdf..0344d53235 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tests/test_forms.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_forms.py-tpl @@ -5,4 +5,3 @@ import pytest from django.utils.translation import gettext_lazy as _ pytestmark = pytest.mark.django_db - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_models.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_models.py-tpl index 0a5f0ae47b..a7057c2cc3 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tests/test_models.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_models.py-tpl @@ -1,4 +1,3 @@ import pytest pytestmark = pytest.mark.django_db - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_urls.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_urls.py-tpl index 3715e52232..2d5b56ed77 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tests/test_urls.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_urls.py-tpl @@ -2,4 +2,3 @@ import pytest from django.urls import resolve, reverse pytestmark = pytest.mark.django_db - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_views.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_views.py-tpl index b765faef09..b0f53c2358 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tests/test_views.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_views.py-tpl @@ -9,4 +9,3 @@ from django.test import RequestFactory from django.urls import reverse pytestmark = pytest.mark.django_db - diff --git a/{{cookiecutter.project_slug}}/startapp_template/views.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/views.py-tpl index 70ed4c90cd..1d8ccb464c 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/views.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/views.py-tpl @@ -2,4 +2,3 @@ from django.shortcuts import render # Create your views here. - From dd898435efa93514e9c646370f72f9b7be9d122d Mon Sep 17 00:00:00 2001 From: dalrrard <8892319+dalrrard@users.noreply.github.com> Date: Wed, 13 Oct 2021 06:09:37 -0500 Subject: [PATCH 3/3] Fix ends of files --- .../startapp_template/api/serializers.py-tpl | 1 - {{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl | 1 - .../startapp_template/tests/test_drf_urls.py-tpl | 1 - .../startapp_template/tests/test_drf_views.py-tpl | 1 - 4 files changed, 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/startapp_template/api/serializers.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/api/serializers.py-tpl index a3a5630ac3..40c8ef03d2 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/api/serializers.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/api/serializers.py-tpl @@ -1,3 +1,2 @@ """Define serializers for the {{ '{{' }} app_name {{ '}}' }} api.""" from rest_framework import serializers - diff --git a/{{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl index 88fcce611a..2077870b2e 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/api/views.py-tpl @@ -1,2 +1 @@ """Define API views for {{ '{{' }} app_name {{ '}}' }} app.""" - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_urls.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_urls.py-tpl index 3715e52232..2d5b56ed77 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_urls.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_urls.py-tpl @@ -2,4 +2,3 @@ import pytest from django.urls import resolve, reverse pytestmark = pytest.mark.django_db - diff --git a/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_views.py-tpl b/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_views.py-tpl index 39c952bebd..e2fb3849f3 100644 --- a/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_views.py-tpl +++ b/{{cookiecutter.project_slug}}/startapp_template/tests/test_drf_views.py-tpl @@ -2,4 +2,3 @@ import pytest from django.test import RequestFactory pytestmark = pytest.mark.django_db -