django-cms / djangocms-alias

Other
8 stars 23 forks source link

alias autocreation doesnt add SITE_ID? #174

Closed svandeneertwegh closed 6 months ago

svandeneertwegh commented 1 year ago

When djangocms-alias autocreated the aliasses it leaves SITE field empty. Is is possible to auto set it with SITE_ID?

If you want to add the same alias in a cms page with CMSplugin it doesnt find it because SITE is empty...?

Or is there a reason for?

Aiky30 commented 1 year ago

You can provide the site to the template tag: https://github.com/django-cms/djangocms-alias/blob/301c067d6303712370cd4eaae8bdb5103b09f976/djangocms_alias/templatetags/djangocms_alias_tags.py#L63

The reason that the site is optional is that you could have a global alias that is used on the entire site, and other alias instances that are limited to just a single site.

svandeneertwegh commented 1 year ago

Maybe whe can make it configurable in the settings?

kwassholm-work commented 10 months ago

Is this Alias plugin also affected by this issue https://github.com/django-cms/django-cms/issues/3921 ?

I.e. if "site" is not used with "static_placeholder" templatetag there's a chance it will create duplicate entries which leads to MultipleObjectsReturned exception.

Aiky30 commented 10 months ago

@kwassholm-work Interesting find. The Static Alias code was a port of the core django cms static placeholder code. I'll create a unit test to see if it is related.

Aiky30 commented 10 months ago

@kwassholm-work This error should not occur, the code has a custom get or create, it shouldn't be able to create the same tag twice: https://github.com/django-cms/djangocms-alias/blob/b116098abbcfcc9fc6dd0992f6664191dd8ac6ab/djangocms_alias/templatetags/djangocms_alias_tags.py#L104