🐛 fix cookiecutter not generating proper template bug

This commit is contained in:
Abdullah Adeel 2022-01-21 16:16:41 +05:00
parent 0ad833eedb
commit bb60df15fb

View File

@ -25,7 +25,7 @@ def _update_or_create_site_with_sequence(site_model, connection, domain, name):
# greater than the maximum value. # greater than the maximum value.
max_id = site_model.objects.order_by('-id').first().id max_id = site_model.objects.order_by('-id').first().id
with connection.cursor() as cursor: with connection.cursor() as cursor:
{% if cookiecutter.database_engine == 'postgresql' -%} {%- if cookiecutter.database_engine == 'postgresql' %}
cursor.execute("SELECT last_value from django_site_id_seq") cursor.execute("SELECT last_value from django_site_id_seq")
(current_id,) = cursor.fetchone() (current_id,) = cursor.fetchone()
if current_id <= max_id: if current_id <= max_id:
@ -33,7 +33,7 @@ def _update_or_create_site_with_sequence(site_model, connection, domain, name):
"alter sequence django_site_id_seq restart with %s", "alter sequence django_site_id_seq restart with %s",
[max_id + 1], [max_id + 1],
) )
{% elif cookiecutter.database_engine == 'mysql' -%} {%- elif cookiecutter.database_engine == 'mysql' %}
cursor.execute("SELECT MAX(id) FROM django_site") cursor.execute("SELECT MAX(id) FROM django_site")
(current_id,) = cursor.fetchone() (current_id,) = cursor.fetchone()
if current_id <= max_id: if current_id <= max_id:
@ -41,7 +41,7 @@ def _update_or_create_site_with_sequence(site_model, connection, domain, name):
"ALTER TABLE django_site AUTO_INCREMENT=%s", "ALTER TABLE django_site AUTO_INCREMENT=%s",
[max_id + 1], [max_id + 1],
) )
{% endif -%} {%- endif %}
def update_site_forward(apps, schema_editor): def update_site_forward(apps, schema_editor):