Now I understand your question, you ask for a variable to be added in
settings, for to the search url, something like this:
*...mezzanine/core/defaults.py*
register_setting(
name="SEARCH_FORM_URL",
label=_("Search form url"),
description=_("Value for the action attribute in the search form of the
"
"website, and name of the corresponding pattern in the
file urls."),
editable=True,
default="search",
)
impressive, I made the test and Mezzanine has rendered it automatically as
shown in the image, has created a fieldset expressly for Search
configurations
<https://lh3.googleusercontent.com/-UoP_KmY8lGc/WcFzyXlnX3I/AAAAAAAAAeg/bqCZpWB0VmYwSJoIhXToWgN5sPHRCS8XwCLcBGAs/s1600/Schermata%2B2017-09-19%2Balle%2B21.44.28.png>
Then the action for the form would be like this:
*...mezzanine/core/templates/includes/search_form.html*
<form action="{% url settings.SEARCH_FORM_URL %}" class="navbar-form
navbar-right" role="search">
and the pattern would be like this:
*project_name/project_name/urls.py*
url("^%s/$" % settings.SEARCH_FORM_URL, search, name=settings.
SEARCH_FORM_URL),
url("^", include("mezzanine.urls")),
I did the test and everything worked well, but only the Mezzanine
developers can make this change for everyone.
Il giorno martedì 5 settembre 2017 12:20:28 UTC+2, [email protected] ha scritto:
>
> Hi, I’m wondering whether there is any smart way to customize the URL
> used for the built-in Mezzanine search view besides the methods
> mentioned below.
>
> Say that you want to change the search URL from the default `search`
> to `my-search`. A first attempt might be:
>
> url("^my-search/$", search, name="search"),
> url("^", include("mezzanine.urls")),
>
> Now you get a search page at `my-search`, but the search view still
> redirects to Mezzanine’s `search` since that one is registered later.
>
> This will fix it, but it doesn’t feel optimal:
>
> url("^(?!my-search/)", include("mezzanine.urls")),
> url("^my-search/$", search, name="search"),
>
> Another approach is to give `my-search` another name, copying
> `search_form.html` from Mezzanine and changing `{% url "search" %}` to
> use the new name. This works fine, but it feels a bit wasteful unless
> you’d like to customize the template some more, and it creates more
> work if you’d like to receive updates to `search_form.html` from
> future Mezzanine versions.
>
> Could a cure for all of this be to add a setting for the search URL,
> defaulting to `search`?
>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.