internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: cookiecutter/cookiecutter-django

Issue:
Django 3.0 support
## Django 3.0 support?

[//]: # (What's it you're proposing? How should it be implemented?)
when will django 3.0 be supported?



 

[//]: # (Why should this feature be implemented?)



 

[//]: # ("Better to see something once than to hear about it a thousand times.")





Discussion:
Support will be done sometime in the future, when all dependencies have updated support for Django 3.0.
Is there a list already of the packages and which have been updated? So we can keep track of which have been which need to be updated and their status. 

I'm noticing many packages not in Cookiecutter are updated for 3.0 so it would be good to just have a simple table to keep track for this ticket.

Happy to put this together, but just want to make sure I'm not recreating something that already exists.
Good idea, such table would be very helpful indeed. I don't think anyone is doing it at the moment :+1: 
@emilepetrone I am about to move to Django manually, but if you have that list please list them here to save up community time

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@
 
 # Our version ALWAYS matches the version of Django we support
 # If Django has a new release, we branch, tag, then update this setting after the tag.
-version = "2.2.1"
+version = "3.0.4"
 
 if sys.argv[-1] == "tag":
     os.system(f'git tag -a {version} -m "version {version}"')
@@ -34,7 +34,7 @@
     classifiers=[
         "Development Status :: 4 - Beta",
         "Environment :: Console",
-        "Framework :: Django :: 2.2",
+        "Framework :: Django :: 3.0",
         "Intended Audience :: Developers",
         "Natural Language :: English",
         "License :: OSI Approved :: BSD License",
diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py
--- a/{{cookiecutter.project_slug}}/config/settings/base.py
+++ b/{{cookiecutter.project_slug}}/config/settings/base.py
@@ -228,7 +228,7 @@
 EMAIL_BACKEND = env(
     "DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend"
 )
-# https://docs.djangoproject.com/en/2.2/ref/settings/#email-timeout
+# https://docs.djangoproject.com/en/dev/ref/settings/#email-timeout
 EMAIL_TIMEOUT = 5
 
 # ADMIN


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Upgrade to Python 3.8
Python 3.8 is out, and it would be nice to upgrade to it. We would need to check that all of our dependencies support it.

[The previous upgrade was done recently](https://github.com/pydanny/cookiecutter-django/pull/2240), we would need to do something similar to start with, and potentially fix issues that come up.


Discussion:

Resolving patch:
diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py
--- a/hooks/pre_gen_project.py
+++ b/hooks/pre_gen_project.py
@@ -35,7 +35,7 @@
     if python_major_version == 2:
         print(
             WARNING + "You're running cookiecutter under Python 2, but the generated "
-            "project requires Python 3.7+. Do you want to proceed (y/n)? " + TERMINATOR
+            "project requires Python 3.8+. Do you want to proceed (y/n)? " + TERMINATOR
         )
         yes_options, no_options = frozenset(["y"]), frozenset(["n"])
         while True:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -40,7 +40,7 @@
         "License :: OSI Approved :: BSD License",
         "Programming Language :: Python",
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: Implementation :: CPython",
         "Topic :: Software Development",
     ],


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
OfflineGenerationError when deploying with compressor on Heroku
## What happened?

While trying to reproduce #2328, I got a different error with Heroku. Deployment works fine, but got a server error when opening the website:

```
OfflineGenerationError

You have offline compression enabled but key "d61d41e4f5705bf7675fe8d6b372b4b43ea27d8bbbb4af00a2012fbc8ebc98fa" 
is missing from offline manifest. 
You may need to run "python manage.py compress". Here is the original content:


    <!-- This file stores project-specific CSS -->
    
    <link href="/static/css/project.a9bf09099778.css" rel="stylesheet">
```

## Steps to reproduce

I think it's down to the following combination:

- use_heroku: y
- use_whitenoise: y
- use_compressor: y
- cloud_provider: None

Extract from the replay file:

```
{
    "use_docker": "n",
    "postgresql_version": "11.3",
    "js_task_runner": "None",
    "cloud_provider": "None",
    "mail_service": "Mailgun",
    "use_async": "n",
    "use_drf": "n",
    "custom_bootstrap_compilation": "n",
    "use_compressor": "y",
    "use_celery": "n",
    "use_mailhog": "n",
    "use_sentry": "y",
    "use_whitenoise": "y",
    "use_heroku": "y"
}
```


Discussion:
We run the `compress` admin command in Docker:

https://github.com/pydanny/cookiecutter-django/blob/a63278fb4ec4e3359202603777411ea16359babe/%7B%7Bcookiecutter.project_slug%7D%7D/compose/production/django/start#L9-L28
There is a solution here: https://github.com/django-compressor/django-compressor/issues/486#issuecomment-341791105

Resolving patch:
diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py
--- a/hooks/post_gen_project.py
+++ b/hooks/post_gen_project.py
@@ -75,6 +75,11 @@ def remove_heroku_files():
             # don't remove the file if we are using travisci but not using heroku
             continue
         os.remove(file_name)
+    remove_heroku_build_hooks()
+
+
+def remove_heroku_build_hooks():
+    shutil.rmtree("bin")
 
 
 def remove_gulp_files():
@@ -346,6 +351,8 @@ def main():
 
     if "{{ cookiecutter.use_heroku }}".lower() == "n":
         remove_heroku_files()
+    elif "{{ cookiecutter.use_compressor }}".lower() == "n":
+        remove_heroku_build_hooks()
 
     if (
         "{{ cookiecutter.use_docker }}".lower() == "n"


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Adding django-cors-headers to requirements if drf selected
## Description

[//]: # (What's it you're proposing? How should it be implemented?)
Adding django-cors-headers to requirements/base.txt if drf is selected in the setup process, having it setup in the settings.



## Rationale

[//]: # (Why should this feature be implemented?)
As far as I know, data from the DRF cannot be consumed without the cors headers properly configured.




Discussion:
Would this be adding `django-cors-headers` when `use_drf` is true in `{{cookiecutter.project_slug}}/requirements.base.txt` or would there be more steps involved? I'd like to take this if it's open.
I think that's all we need to do, yes.
Okay, I'll take a look at the guidelines and make a PR. Thanks! 

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py
--- a/{{cookiecutter.project_slug}}/config/settings/base.py
+++ b/{{cookiecutter.project_slug}}/config/settings/base.py
@@ -80,6 +80,7 @@
 {%- if cookiecutter.use_drf == "y" %}
     "rest_framework",
     "rest_framework.authtoken",
+    "corsheaders",
 {%- endif %}
 ]
 
@@ -134,6 +135,9 @@
 # https://docs.djangoproject.com/en/dev/ref/settings/#middleware
 MIDDLEWARE = [
     "django.middleware.security.SecurityMiddleware",
+{%- if cookiecutter.use_drf == 'y' %}
+    "corsheaders.middleware.CorsMiddleware",
+{%- endif %}
 {%- if cookiecutter.use_whitenoise == 'y' %}
     "whitenoise.middleware.WhiteNoiseMiddleware",
 {%- endif %}
@@ -321,6 +325,10 @@
     ),
     "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
 }
+
+# django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup
+CORS_URLS_REGEX = r"^/api/.*$"
+
 {%- endif %}
 # Your stuff...
 # ------------------------------------------------------------------------------


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
selective settings in context
## Description

Change the settings_context processor to only pass a required subset of the settings variables instead of all. We could have a special settings variable called CONTEXT_SETTINGS and set as an array of settings variable names to pass to the templates, e.g. ['GOOGLE_ID', 'MY_OTHER_SETTINGS', 'PAGINATION_SIZE', 'SITE_TITLE']. settings_context() would read that and only pass the relevant settings variable to the context.

## Rationale

Am I the only one to feel a bit uneasy about the idea of passing the whole settings to the context? It is very convenient but is that a best practice? 

https://github.com/pydanny/cookiecutter-django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/%7B%7Bcookiecutter.project_slug%7D%7D/utils/context_processors.py#L5

For various reasons:

1. it is unnecessary
2. it may clutter the context or debugging metadata with a lot of unneeded text
3. it is harder to track dependencies between templates and settings (i.e. we bypass the controller for a lot of stuff)
4. it spreads sensitive information (software stack, database connection, passwords, secret keys, ...) to the context and may accidentally end up on screen, in logs, ...





Discussion:

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/context_processors.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/context_processors.py
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/context_processors.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/context_processors.py
@@ -2,4 +2,7 @@
 
 
 def settings_context(_request):
-    return {"settings": settings}
+    """Settings available by default to the templates context."""
+    # Note: we intentionally do NOT expose the entire settings
+    # to prevent accidental leaking of sensitive information
+    return {"DEBUG": settings.DEBUG}


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Compressor CACHE not publicly available on S3
## What happened?

Using Django compressor with AWS on S3 will cache outputs and send them to S3. Unfortunately, if you have CORS setup, the CACHE directory is still sending back 403 errors. If you go directly to the static directory of your S3, there's no problem.

## What should've happened instead?

The public new files should be publicly available. I believe this COULD help but I haven't tested it out yet: https://django-compressor.readthedocs.io/en/latest/remote-storages/

## Steps to reproduce

- Start a new cookiecutter-django project. 
- Enable django compressor
- If you'd like, enable compress in a different HTML file with a different static file.
- Go to your production website.

I could only fix it by making each file public.


Discussion:
Ah I see. It's probably because COMPRESS_STORAGE is not equal to STATICFILES_STORAGE which is what the compressor documentation asks for https://django-compressor.readthedocs.io/en/latest/remote-storages/#using-staticfiles
I also noticed something similar. Pull request welcome!

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py
--- a/{{cookiecutter.project_slug}}/config/settings/production.py
+++ b/{{cookiecutter.project_slug}}/config/settings/production.py
@@ -235,13 +235,11 @@
 # ------------------------------------------------------------------------------
 # https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
 COMPRESS_ENABLED = env.bool("COMPRESS_ENABLED", default=True)
-# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
-{%- if cookiecutter.cloud_provider == 'AWS' %}
-COMPRESS_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
-{%- elif cookiecutter.cloud_provider == 'GCP' %}
-COMPRESS_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
-{%- elif cookiecutter.cloud_provider == 'None' %}
+{%- if cookiecutter.cloud_provider == 'None' %}
 COMPRESS_STORAGE = "compressor.storage.GzipCompressorFileStorage"
+{%- elif cookiecutter.cloud_provider in ('AWS', 'GCP') and cookiecutter.use_whitenoise == 'n' %}
+# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
+COMPRESS_STORAGE = STATICFILES_STORAGE
 {%- endif %}
 # https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL
 COMPRESS_URL = STATIC_URL{% if cookiecutter.use_whitenoise == 'y' or cookiecutter.cloud_provider == 'None' %}  # noqa F405{% endif %}


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Update mypy to 0.782

This PR updates [mypy](https://pypi.org/project/mypy) from **0.770** to **0.782**.



*The bot wasn't able to find a changelog for this release. [Got an idea?](https://github.com/pyupio/changelogs/issues/new)*

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/mypy
  - Homepage: http://www.mypy-lang.org/
</details>




Discussion:

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/admin.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/admin.py
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/admin.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/admin.py
@@ -12,6 +12,8 @@ class UserAdmin(auth_admin.UserAdmin):
 
     form = UserChangeForm
     add_form = UserCreationForm
-    fieldsets = (("User", {"fields": ("name",)}),) + auth_admin.UserAdmin.fieldsets
+    fieldsets = (("User", {"fields": ("name",)}),) + tuple(
+        auth_admin.UserAdmin.fieldsets
+    )
     list_display = ["username", "name", "is_superuser"]
     search_fields = ["name"]


Test patch:
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py
@@ -64,7 +64,7 @@ def test_authenticated(self, user: User, rf: RequestFactory):
 
     def test_not_authenticated(self, user: User, rf: RequestFactory):
         request = rf.get("/fake-url/")
-        request.user = AnonymousUser()  # type: ignore
+        request.user = AnonymousUser()
 
         response = user_detail_view(request, username=user.username)
Repository: cookiecutter/cookiecutter-django

Issue:
Custom user model still contains first_name and last_name
The custom user model provided by this template has a `name` field which works better with name patterns around the globe, but still inherits `first_name` and `last_name` from AbstractUser.

Is this intended behavior? If that's the case, it would be appropiate to document it.


Discussion:
Would people be interested in integrating [`django-improved-user`](https://github.com/jambonsw/django-improved-user/)?

Full disclosure: I am one of the original authors.

I understand not wishing to add yet another dependency, but we also built it specifically to deal with this problem.

Note that it uses an email as an identifier, not a username, which [comes with its own issues](https://django-improved-user.readthedocs.io/en/latest/email_warning.html). That said, it would also be easy to leverage the mix-in classes to remove Django's names and use more international friendly short name, full name on a model with a Username.

Given the potential conflict of interest, I'll leave it at that. However, I'm happy to answer questions or create a PR if people want this.

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/migrations/0001_initial.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/migrations/0001_initial.py
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/migrations/0001_initial.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/migrations/0001_initial.py
@@ -53,18 +53,6 @@ class Migration(migrations.Migration):
                         verbose_name="username",
                     ),
                 ),
-                (
-                    "first_name",
-                    models.CharField(
-                        blank=True, max_length=30, verbose_name="first name"
-                    ),
-                ),
-                (
-                    "last_name",
-                    models.CharField(
-                        blank=True, max_length=150, verbose_name="last name"
-                    ),
-                ),
                 (
                     "email",
                     models.EmailField(
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/models.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/models.py
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/models.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/models.py
@@ -9,6 +9,8 @@ class User(AbstractUser):
 
     #: First and last name do not cover name patterns around the globe
     name = CharField(_("Name of User"), blank=True, max_length=255)
+    first_name = None  # type: ignore
+    last_name = None  # type: ignore
 
     def get_absolute_url(self):
         """Get url for user's detail view.


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Django 3.1
I haven't seen anyone asked this question yet. So I'll go first. Is it ok now to upgrade to django 3.1.x?

Another newbie question: beside the tests that I wrote, is there any other test that I could run to make sure the django-cookiecutter on my computer works with django 3.1.1?

Thank you. 


Discussion:
I did some research. The very first one was djangorestframework only supports upto django 3.0. Case closed. Sorry about this.
https://www.django-rest-framework.org
Seems latest DRF support Django 3.1. Any plan for go with Django 3.1?

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0004_alter_options_ordering_domain.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0004_alter_options_ordering_domain.py
new file mode 100644
--- /dev/null
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0004_alter_options_ordering_domain.py
@@ -0,0 +1,17 @@
+# Generated by Django 3.1.7 on 2021-02-04 14:49
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('sites', '0003_set_site_domain_and_name'),
+    ]
+
+    operations = [
+        migrations.AlterModelOptions(
+            name='site',
+            options={'ordering': ['domain'], 'verbose_name': 'site', 'verbose_name_plural': 'sites'},
+        ),
+    ]


Test patch:
diff --git a/tests/test_docker.sh b/tests/test_docker.sh
--- a/tests/test_docker.sh
+++ b/tests/test_docker.sh
@@ -30,4 +30,4 @@ docker-compose -f local.yml run django pytest
 docker-compose -f local.yml run django python manage.py makemigrations --dry-run --check || { echo "ERROR: there were changes in the models, but migration listed above have not been created and are not saved in version control"; exit 1; }
 
 # Test support for translations
-docker-compose -f local.yml run django python manage.py makemessages
+docker-compose -f local.yml run django python manage.py makemessages --all
Repository: cookiecutter/cookiecutter-django

Issue:
Upgrade to Bootstrap v5
https://v5.getbootstrap.com/

https://github.com/twbs/bootstrap/projects

Wouldn't be a bad idea to get a head start.


Discussion:
would love to see that happening too.
There is also a version of https://github.com/django-crispy-forms/crispy-bootstrap5
I agree, but we should also wait until it's out of beta.
You can see the progress in the second link above.

v5 looks very close to being stable and out of beta. Might as well work on some drafts and when it comes out, be done instead of waiting last minute or falling behind.
You timed your messages well 😄 

https://blog.getbootstrap.com/2021/05/05/bootstrap-5/
lmao we're from the future :O Should we also get rid of the IE support (html shim) since bootstrap also dropped it? https://github.com/pydanny/cookiecutter-django/blob/c650acc19bd7aadeaca9ba4fa2a17a13a8ab0e68/%7B%7Bcookiecutter.project_slug%7D%7D/%7B%7Bcookiecutter.project_slug%7D%7D/templates/base.html#L11-L14

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py
--- a/{{cookiecutter.project_slug}}/config/settings/base.py
+++ b/{{cookiecutter.project_slug}}/config/settings/base.py
@@ -71,6 +71,7 @@
 ]
 THIRD_PARTY_APPS = [
     "crispy_forms",
+    "crispy_bootstrap5",
     "allauth",
     "allauth.account",
     "allauth.socialaccount",
@@ -208,7 +209,8 @@
 FORM_RENDERER = "django.forms.renderers.TemplatesSetting"
 
 # http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
-CRISPY_TEMPLATE_PACK = "bootstrap4"
+CRISPY_TEMPLATE_PACK = "bootstrap5"
+CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
 
 # FIXTURES
 # ------------------------------------------------------------------------------


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Auto-update pre-commit hooks
Update versions of tools in pre-commit configs to latest version


Discussion:

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py
--- a/{{cookiecutter.project_slug}}/config/settings/base.py
+++ b/{{cookiecutter.project_slug}}/config/settings/base.py
@@ -44,7 +44,10 @@
 DATABASES = {"default": env.db("DATABASE_URL")}
 {%- else %}
 DATABASES = {
-    "default": env.db("DATABASE_URL", default="postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}"),
+    "default": env.db(
+        "DATABASE_URL",
+        default="postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}",
+    ),
 }
 {%- endif %}
 DATABASES["default"]["ATOMIC_REQUESTS"] = True


Test patch:
diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py
--- a/tests/test_cookiecutter_generation.py
+++ b/tests/test_cookiecutter_generation.py
@@ -179,7 +179,12 @@ def test_black_passes(cookies, context_override):
 
     try:
         sh.black(
-            "--check", "--diff", "--exclude", "migrations", _cwd=str(result.project)
+            "--check",
+            "--diff",
+            "--exclude",
+            "migrations",
+            ".",
+            _cwd=str(result.project),
         )
     except sh.ErrorReturnCode as e:
         pytest.fail(e.stdout.decode())