divio / aldryn-search

Haystack 2.0 search index for django CMS
Other
48 stars 77 forks source link

Searched result's link is outdated when page moved or parent's slug changed. #94

Closed air-hand closed 2 years ago

air-hand commented 5 years ago

I'm using aldryn_search.signal_processor.RealTimeSignalProcessor.

When moved a page and search, result.url is not updated. because a index is updated when only publishing or unpublishing.

{% for result in page_obj.object_list %}
{{ result.url }} {# result.url is broken. 404 Error occured. #}

And, change a page's slug(or overwrite_url) is need publish, but descendants's url are not changed.

I tried implement update all descendant's indexes when a page moved, but the process is too slowly. Also no effect in case of slug changed.

I think that there is no other way than access page object, as described below... Any ideas?

load_all = True
{{ result.object.page.get_absolute_url }}
MalikRumi commented 2 years ago
  1. I see this is three years old already, and
  2. . This is my first time here, I came to investigate using Django CMS, I know nothing about the feature set yet, so I am no expert, BUT...
  3. Your post doesn't say anything about a redirect. Did you use one? If so, what happened? If not, why? This is what redirects are for!
  4. Your problem comes from making the change in the first place. You have to plan out your url patterns ahead of time, for exactly this reason! Now granted, things happen, and you may have to change something - which is why there are redirects.
  5. It has LONG (maybe always, from the very beginning?) been Django mantra that "Cool urls don't change". You have violated this foundational principle, and given no evidence that you are familiar with even the most basic, well known solutions. I'm guessing that's why in 3 years, I'm the first one to even bother giving you an answer.
  6. So then, why did I answer? To help someone else who may be coming along in the future.
air-hand commented 2 years ago

I resolved this issue, implement DjangoCMS page permalink view by myself and rebuild all indices to insert the link.

By the way, DjangoCMS is not Django, just a package of it. IMO, Django is just a framework, so its rules don't compatible with all its package use cases. DjangoCMS supports move pages and change slugs by design. no more and no less.