I read through the tutorial on the Django site for adding custom admin actions and got my custom action to work when viewing a list of items.
The problem is I'd like to add a button to the page where users can edit records that will execute this custom action, but I have no idea how to do this.
Related
I'd like to put a search icon (like magnifiying glass) beside a field in the admin change form to let the users to trigger a script to fill other fields on demand only. I have to avoid triggering any field event (blur, click, change etc) on this field because it has to be triggered under users request, according to their needs.
Django has its own magnifying glass icon/link for raw_field foreign key selection popup. Is it possibble to do something similar, where I would trigger the script upon the magnifying glass click. It will be just a JQuery to call a webservice and return values to be filled up on some other fields.
I found one working solution by putting a custom button as a field, but it is placed far from the field because its label (what seems weird for my purpose).
Let me know if this description is enough or additional information is needed.
example here
Tks.
I am new to Django and I am having some troubles with my first web application.
My idea is to show a template on user first login with some information about the web. The template contains an "accept button" and a "continue to the webpage" button. This template should appear everytime the users login, until they click on the accept button.
I have created a new model with userID, a boolean field (terms_accepted) and a date field (terms_accepted_date) to control if the users have accepted the information, and the date when they have done so. What I want is to update the terms_accepted (from False to True), when the users click on the accept button.
Is there a simply way to modify the model from the template? I have created the correct flow, because If I modify manually the terms_accepted field from the admin site, when I enter to the page I don't see the template with the information. However, I don't know how to update the field automatically on button click.
Thanks
please take a look at this tutorial:
https://docs.djangoproject.com/en/1.10/intro/tutorial04/.
In the example the form is more complicated, but you can see how the model is updated in polls/view.py
I have a django admin action say "refresh", I want to add a refresh button for each row in the admin list view. I can create button using format_html but how can I invoke "refresh" action when it is pressed?
I don't think admin actions are the best fit in this case.
Actions are
simple functions that get called with a list of objects selected on the change list page
With the buttons you describe however, you want to operate on a single row/instance.
Therefore I would simply create a custom url endpoint for your ModelAdmin which is called when you press the button and which handles the desired action.
This article has quite a comprehensive overview how this can be done in detail.
I have created some custom tabs for facebook pages, like when the user clicks on the add custom tabs, im fetching the user pages but how can i make them to install the custom tab to the particular page on which he clicks.
li.innerHTML = "Name: <a href='http://facebook.com/"+page.id+"'>"+page.name+"</a>";
From the above code, i could get only the list of user pages, among them when the user clicks on a particular page (i.e.,page1), it should direct them to their page1 profile by adding the custom tab. How can i make them to install the custom tabs?
If you have the manage_pages permission from the user, you can add your app to their page via the API - see here:
https://developers.facebook.com/docs/reference/api/page/#tabs
There's no other way to automate it, and using static links are you're suggesting above is prone to break if the Facebook web interface ever changes.
I have a custom list created in Sharepoint 2007 and displayed by a content query web part.
I would like to
Show all items to general admin users except those items created by two users.
The two admin users need to see all items in the list.
The first requirement is easily done by adding a filter to the view on the created by field.
The second one is where I need help, is there a way to set the view of a list based on the user logged in to acheive the second requirement?
Or is this achievable another way?
Many Thanks,
Nav
If user has SPBasePermissions.ManageLists permissions, he will have permissions to view all items in the list.
If its not about permissions, but just which view which user sees by default, then it will involve some sort of coding :
Either you create webpart which will switch to desired view for desired user. (Involves coding, building, deploying)
Use content editor web part to switch with javascript - not that nice solution. (Because page would reload when you open it).
In the end I created two pages one called restricted and the other for all users configured the views on each page for each group of users. Then I restricted access to the 'restricted' page to the relevant users.
I used audiencing to display a link to the 'restricted' page to selected users