-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
looks like parler's documentation is a future dream; not sure how to make it work for existing models References: https://django-parler.readthedocs.io/en/stable/advanced/migrating.html django-parler/django-parler#254
- Loading branch information
Showing
8 changed files
with
236 additions
and
40 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
apis_ontology/migrations/0031_alter_person_options_alter_versionperson_options_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Generated by Django 5.1.3 on 2024-11-15 21:53 | ||
|
||
import django.db.models.deletion | ||
import parler.fields | ||
import parler.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("apis_ontology", "0030_alter_versioninstance_options_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="person", | ||
options={}, | ||
), | ||
migrations.AlterModelOptions( | ||
name="versionperson", | ||
options={ | ||
"get_latest_by": ("history_date", "history_id"), | ||
"ordering": ("-history_date", "-history_id"), | ||
"verbose_name": "historical person", | ||
"verbose_name_plural": "historical persons", | ||
}, | ||
), | ||
migrations.RemoveField( | ||
model_name="person", | ||
name="name", | ||
), | ||
migrations.RemoveField( | ||
model_name="versionperson", | ||
name="name", | ||
), | ||
migrations.AddField( | ||
model_name="person", | ||
name="name_latin", | ||
field=models.CharField( | ||
blank=True, | ||
default="", | ||
editable=False, | ||
max_length=255, | ||
verbose_name="Name", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="versionperson", | ||
name="name_latin", | ||
field=models.CharField( | ||
blank=True, | ||
default="", | ||
editable=False, | ||
max_length=255, | ||
verbose_name="Name", | ||
), | ||
), | ||
migrations.CreateModel( | ||
name="PersonTranslation", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"language_code", | ||
models.CharField( | ||
db_index=True, max_length=15, verbose_name="Language" | ||
), | ||
), | ||
( | ||
"name", | ||
models.CharField( | ||
blank=True, default="", max_length=255, verbose_name="Name" | ||
), | ||
), | ||
( | ||
"master", | ||
parler.fields.TranslationsForeignKey( | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="translations", | ||
to="apis_ontology.person", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "person Translation", | ||
"db_table": "apis_ontology_person_translation", | ||
"db_tablespace": "", | ||
"managed": True, | ||
"default_permissions": (), | ||
"unique_together": {("language_code", "master")}, | ||
}, | ||
bases=(parler.models.TranslatableModel, models.Model), | ||
), | ||
migrations.RunSQL( | ||
"INSERT INTO apis_ontology_person_translation(language_code, name , master_id) SELECT 'en', name_latin, rootobject_ptr_id FROM apis_ontology_person;" | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
from apis_ontology.views import ExcerptsView | ||
from apis_ontology.views import ExcerptsView, language_switcher | ||
from django.contrib import admin | ||
from django.urls import include, path | ||
from django.views.generic import TemplateView | ||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns | ||
from django.conf.urls.i18n import i18n_patterns | ||
|
||
from apis_core.apis_entities.api_views import GetEntityGeneric | ||
|
||
|
||
urlpatterns = [ | ||
path("admin/", admin.site.urls), | ||
path("apis/", include("apis_core.urls", namespace="apis")), | ||
path("apis/collections/", include("apis_core.collections.urls")), | ||
path("accounts/", include("django.contrib.auth.urls")), | ||
path("apis/collections/", include("apis_core.collections.urls")), | ||
path("entity/<int:pk>/", GetEntityGeneric.as_view(), name="GetEntityGenericRoot"), | ||
path("", TemplateView.as_view(template_name="base.html")), | ||
path( | ||
"apis/excerpts/<str:xml_id>/<str:render_style>/", | ||
ExcerptsView.as_view(), | ||
name="excerpts_view", | ||
), | ||
path( | ||
"switch_language/<str:language_code>/", | ||
language_switcher, | ||
name="language_switcher", | ||
), | ||
] | ||
|
||
# Language-aware URL patterns (wrapped in `i18n_patterns`) | ||
urlpatterns += i18n_patterns( | ||
path("apis/", include("apis_core.urls", namespace="apis")), | ||
) | ||
|
||
# Static files and other patterns | ||
urlpatterns += staticfiles_urlpatterns() | ||
urlpatterns += [ | ||
path("", include("django_acdhch_functions.urls")), | ||
] | ||
|
||
# Additional URLs | ||
urlpatterns += [ | ||
path("", include("django_acdhch_functions.urls")), | ||
path("select2/", include("django_select2.urls")), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.