I have created a menu using django cms, there is a menu item named 'News'. There is a page linked to this menu item News, when there is no article in it, this menu item has to hide from the menu otherwise it has to visible. The problem is when all the articles are deleted in the News page the menu item still appears in the menu until or unless the server is not restarted. Can any one help me to figure this out?
Did you read the django cms caching documents? There is a discussion about the caching in the django cms. Have a look at this
There is also an option to use the cache plugin.
Also check this note in the documentation;
If you disable a plugin cache be sure to restart the server and clear the cache afterwards.
Related
I have django project with jazzmin theme library I use, I've change icon for sidebar with:
"icons:{...}"
and I want to change the user menu icons, the logout menu:
what I know is, we can use this line:
"usermenu_links" : {}
But I don't quite understand how to pointing for the log out button, any idea?
I am a beginner in Django and I want to display page-y when the user refreshes the page-x
this event not related to django if you want to do that you should trigger refresh page event using JavaScript
and when this event happen you can make JavaScript function run and make this function navigate user to new page or open new window
check this article to better understanding what I mean
best of luck
Pure HTML/ Django answer. Reload in a Web browser will do another GET for the page. If the Django server remembers the context of the last GET, it can choose to do a redirect rather than show the same again. So for example, if it's something in the user's profile:
if request.user.profile.whatever:
return redirect( 'myapp:anotherpage' )
I am trying to customize a settings page so it has a button that I will assign to a certain action. (Let's assume for now I just want to log something into the console).
Ideally it would be of something like this:
#register_setting
class ActionTriggeringSetting(BaseSetting):
button = models.ButtonField(
action=myLoggingFunc,
help_text='Click here to log "Hello World" to the console'
)
I tried looking into the site settings but found nothing really helpful there.
Does anybody know if something of the sort exists?
Thank you
Depending on where in the admin UI you want you button to be, there is a way using the register-admin-menu-item or register-settings-menu-item Wagtail hook
See: https://docs.wagtail.io/en/v2.10.1/reference/hooks.html#register-admin-menu-item
and
https://docs.wagtail.io/en/v2.10.1/reference/hooks.html#register-settings-menu-item
The approaches above will add a button to the Wagtail Admin menu or the settings submenu, respectively. Clicking on the button will trigger a custom view that you also need to add - this is also loosely covered in the linked docs.
I hava a new site that I am working on. The site will have prior agreement with eCommerce sites to include add-ons on their website.
Consider the following example:
My website, ABC.com is targeting ecommerce sites.
For every ecommerce site that sells product X, I want them to include an add-on that gives buyers the option to purchase service Z if they so desire.
ABC.com will be communicating with the ecommerce sites through a REST API.
My challenge is how to integrate my service as an add-on into the external ecommerce sites. This I assume will be in the form of a widget, HTML code, or a bit of javascript. Something similar to the attached image from Amazon.com. I'm aiming to make a simple integration with the external sites to avoid having them do too much on their end.
Is there a best practice on how to handle this?
See an example from Amazon:
There are a number of ways but the two most common are:
iframe
You create a small page containing only the controls and logic you need which will be embedded in the site using an iframe. The parent site would communicate relevant details, such as product name and product SKU, with the child iframe via URL parameters in the iframe's src attribute. In this case, you wouldn't know if the user actually submitted the parent form.
Javascript widget
You create a small self-contained javascript widget that can be loaded from a CDN. The widget would then target a specific element, or elements, on the page and add your additional form fields. It could then listen for form submit events (or other types of events) and could be responsible for doing AJAX calls directly to your API.
Examples of this are widgets like Stripe which generate buy buttons on a page.
I tried web.seeother("link"), but this does not open it in a new tab. Now I can generate a link with a _blank tag, but then the user has to click on the link separately that is separate button for generating the link and another button to follow that link. I want to perform both with a single click. A server side method to do this would be best.
I am using the web.py framework.
As the document says web.seeother() is used for redirecting a user to another page. So a more clear way for asking your question is: "how to make web.seeother() open a link in a new tab"?
As I have observed the documents, There is no way to do that on server-side.
Not a web.py issue. Cannot be done from server-side by any python or non-python framework, must be done in the Client.
From the client, you can set target="_blank" in the HTML, or use javascript with something like window.open(url). Javascript will allow you to set size and position of second window.