How to open django admin edit object page? - python

I need to make such feature: when user clicks "edit" button, the Django should open admin page for editing this object. I have made something like this:
<a onclick="window.open('/admin/posts/post/{{post.pk}}/', 'newwindow', 'width=auto, height=auto'); return false;">
And this will open window for editing this post. But when I click on "Save" button - object saves and nothing happens else. The window stays white...
But I need to close automatically window after "Save" button and refresh page from which user clicks "edit" button.
We can also see such window, when clicking on the icon "Change selected objectname", near foreign key in Django admin page.
Do you understand what I need? What should I do?
Thanks a lot.

Related

How to change Log out icon in jazzmin django theme?

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?

How to find a form in a URL code and send it with submit()

I have a URL with different items. Every item has an associated button_item and when this button_item is clicked on, a pop-up window appears with a marked default option and a submit button. This pop-up window is apparently the same for all items in the source window but actually it isn't because the server knows which button_item you clicked on (we know this).
How can I implement in python/selenium the action of this submit button without having to click on it, not even opening the corresponding popup window?
I am guessing I would have to find in the HTLM code the form or information corresponding to that popup window and then apply a submit() method. My idea was to find the form through the ID of the particular item which is a string specific for every item and I guess it's the element used by the server to know which item you cliked on exactly.
Something like:
driver.find_element_by_???("itemID").submit()
I don't know which method to use after "driver." for finding the right form and submitting it.
Thanks

How to create a function for a pop up in OpenERP

I have created a button in debugging mode of OpenERP and want to display a message on click of that button.
This is the button Ex. then How to write an action on click of this button mainly the popup and message is required
You can write a small wizard to do so.refer to openerp documentation for how to.

Is there any simple way to check radio buttons when page loads, based on the what is checked before the page submit?

I am using django.
My webpage works like this, If i check the radio button and click on submit. it redirects to the same page with jobs redefined on the basis of which radiobuttons were checked. My problem is after loading the page none of the radio buttons are checked.
so I would like to know is there any method so that when redirect the same page(ie form action="") the previous selected radio buttons(ie before submit) are selected in this page too?
Since requests are stateless, you will have to somehow "save" the state of your radio buttons. One option would be to use sessions, the other would be to use a form and instantiate it with the submitted data.

Using python to download a file after clicking the generate icon

I am working on a project. Each day I need to login to a website. Navigate to a report page. After entering the require information, and clicking on the "gererate report" icon, there's a pop up windown asking me to save the file. I want to do it automatically by python.
I search the internet for a couple of days, and now I can do it by Autoit, but can't find a way in python.
By using urllib2, I can process up to clicking the "generate report" icon. But how can I get the name and location of the file and download it?
I want to make clear that the "generate report" button is actuary the submit button of a form. There is no Href associate with the generate button. After submitting the form, a file-save dialog popup asking me where to save the file.
thanks in advance!
If it's a save file dialog from Fx it probably means that it directly links to a file. If you manage to fill all the information and click the generate_report icon, can't you check which href has the generate_button assigned to it?
import urlib
urlfile = "Href of the generate_button"
urllib.urlretrieve(urlfile,"filename")

Categories