Skip to content

Snippets

Stéphane Malta e Sousa edited this page Jul 22, 2020 · 11 revisions

Django

Reset migrations and database

python manage.py migrate --fake api zero
..\scripts\0_create_db.ps1

Delete migrations files except __init__.py, then make migrations and migrate:

del .\api\migrations\0*.py
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser --username admin

Translations

Make messages

django-admin makemessages -l fr

Reset sequences

SELECT SETVAL('geoshop.auth_group_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.auth_group;
SELECT SETVAL('geoshop.auth_group_permissions_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.auth_group_permissions;
SELECT SETVAL('geoshop.auth_permission_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.auth_permission;
SELECT SETVAL('geoshop.identity_groups_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.identity_groups;
SELECT SETVAL('geoshop.identity_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.identity;
SELECT SETVAL('geoshop.identity_user_permissions_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.identity_user_permissions;
SELECT SETVAL('geoshop.copyright_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.copyright;
SELECT SETVAL('geoshop.django_admin_log_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.django_admin_log;
SELECT SETVAL('geoshop.django_content_type_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.django_content_type;
SELECT SETVAL('geoshop.django_migrations_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.django_migrations;
SELECT SETVAL('geoshop.document_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.document;
SELECT SETVAL('geoshop.format_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.format;
SELECT SETVAL('geoshop.metadata_contact_persons_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.metadata_contact_persons;
SELECT SETVAL('geoshop.metadata_documents_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.metadata_documents;
SELECT SETVAL('geoshop.metadata_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.metadata;
SELECT SETVAL('geoshop.order_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop."order";
SELECT SETVAL('geoshop.order_item_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.order_item;
SELECT SETVAL('geoshop.order_type_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.order_type;
SELECT SETVAL('geoshop.pricing_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.pricing;
SELECT SETVAL('geoshop.product_field_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.product_field;
SELECT SETVAL('geoshop.product_id_seq', COALESCE(MAX(id), 1) ) FROM geoshop.product;
Clone this wiki locally