You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating another database with tables not used with DjangoCMS and found a bug in the migration code.
see file .venv/lib/python3.11/site-packages/cms/migrations/0030_auto_20180810_0629.py
On line 29:
def set_page_url(apps, schema_editor):
Page = apps.get_model('cms', 'Page')
PageUrl = apps.get_model('cms', 'PageUrl')
db_alias = schema_editor.connection.alias
create_url = PageUrl.objects.using(db_alias).create
for cms_page in Page.objects.all():
for translation in cms_page.title_set.all():
create_url(
page=cms_page,
slug=translation.slug,
path=translation.path,
managed=not bool(translation.has_url_overwrite),
language=translation.language,
)
Should include the alias for the current database
def set_page_url(apps, schema_editor):
Page = apps.get_model('cms', 'Page')
PageUrl = apps.get_model('cms', 'PageUrl')
db_alias = schema_editor.connection.alias
create_url = PageUrl.objects.using(db_alias).create
for cms_page in Page.objects.using(db_alias).all(): # ADDED .using(db_alias)
for translation in cms_page.title_set.all():
create_url(
page=cms_page,
slug=translation.slug,
path=translation.path,
managed=not bool(translation.has_url_overwrite),
language=translation.language,
)
Steps to reproduce
./manage migrate --database=OTHER_DATABASE
Expected behaviour
The migration should succeed.
Actual behaviour
Screenshots
Additional information (CMS/Python/Django versions)
Django 5.0.1
django-cms 4.1.0
python 3.11
Do you want to help fix this issue?
Ummm, the fix is in the comment above, if someone could put that in, it would be nice.
[ x ] Yes, I want to help fix this issue and I will join #workgroup-pr-review on Slack to confirm with the community that a PR is welcome.
No, I only want to report the issue.
The text was updated successfully, but these errors were encountered:
nzprog
changed the title
[BUG] Migrating with another database (clean of DjangoCMS tables)
[BUG] Migrating with another database other than "default"
Jan 21, 2024
Description
I am creating another database with tables not used with DjangoCMS and found a bug in the migration code.
see file .venv/lib/python3.11/site-packages/cms/migrations/0030_auto_20180810_0629.py
On line 29:
Should include the alias for the current database
Steps to reproduce
./manage migrate --database=OTHER_DATABASE
Expected behaviour
The migration should succeed.
Actual behaviour
Screenshots
Additional information (CMS/Python/Django versions)
Django 5.0.1
django-cms 4.1.0
python 3.11
Do you want to help fix this issue?
Ummm, the fix is in the comment above, if someone could put that in, it would be nice.
I tried to join the community but as per my other post, https://www.django-cms.org/en/sign-up-work-contribution/ catchup isn't working.
The text was updated successfully, but these errors were encountered: