Django will run the function content twice when using render - django

I am sorry that my English is not good. My problem is that refreshing the page in Google Chrome will cause the function with render to run twice But run it once in the Firefox browser. I don't know if this is a problem with Google Chrome or something else?(I hope to get help, thank you)
def add_teacher(request):
Teacher.objects.create(username='zhangs',avatar='https://static-image.xfz.cn/11.jpg',jobtitle='a',profile='b')
print('==')
return render(request,'course/course_index.html')
Both Google and Firefox run the same content.
Two teachers' data will be created when Google Chrome refreshes the page, But only one piece of data is created when Firefox is running. Pycharm will also print two ‘==’ content when Google runs. Print one on Firefox.

Related

How to wait long enough for Django views results on Firefox?

I'm developing a website with Django 2.2, using :
Centos 7
Mozilla Firefox 60.6.0
Google Chrome 73.0.3683.86
Docker and Docker compose
The first page allows the user to submit data from a formatted file (equivalent to csv) and the second page shows the result of calculations (done row by row) in a datatable.
I have noticed a difference between Mozilla Firefox and Google Chrome:
For big files, on Chrome, the web browser waits long enough to receive and display the results of calculations. Whereas in Firefox, the web browser stops waiting for localhost and the "results" page is not loaded.
As the problem occured when the file exceeded a certain size, I have guessed that the app spent too much calculating time and Firefox stopped waiting for the response before to load the "results" page.
So I changed my view to accelerate calculations. The problem still persists with big files. With files from approximately 3.5Mo the results page os displayed or not (almost randomly).
I tried to raise "dom.max_script_run_time" in my Mozilla settings but this can't be done programatically.
I saw that Celery can be used for long time running calculations, but in my case, calculations can be performed on 1 or 3000 rows. I would like to find a solution without using Celery.
Another solution could be to use JavaScript to set a timeout when Firefox is detected as web browser, the to add a error message, I also would like to avoid this.
I expect my app to work well at least on Mozilla Firefox, Safari, Opera and Google Chrome Web browsers.
Thanks for your help !

Access Webpage With Credentials and Cookies From Command Line

I am trying to access a proprietary website which provides access to a large database. The database is quite large (many billions of entries). Each entry in the database is a link to a webpage that is essentially a flat file containing the information that I need.
I have about 2000 entries from the database and their corresponding webpages in the database. I have two related issues that I am trying to resolve:
How to get wget (or any other similar program) to read cookie data. I downloaded my cookies from google chrome (using: https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg?hl=en) but for some reason the html downloaded by wget still cannot be rendered as a webpage. Similarly, I have not been able to get Google Chrome from the command line to read cookies. These cookies are needed to access the database, since they contain my credentials.
In my context, it would be OK if the webpage was downloaded as a PDF, but I cannot seem to figure out how to download a webpage as a pdf using wget or similar tools. I tried using automate-save-page-as (https://github.com/abiyani/automate-save-page-as) but I continuously get an error of the browser not being in my PATH.
I solved both of these issues:
Problem 1: I switched away from wget, curl and python's requests to simply using the selenium webdriver in python. Using selenium, I did not have to deal with issues such as passing cookies,headers, post and get, since it actually opens a browser. This also has a plus that as I was writing the script to use selenium, I could inspect the page and see what it was doing as it was doing it.
Problem 2: Selenium has a method called page_source, which downloaded the html of the webpage. When I tested it, it rendered the html correctly.

Django when I ran server(manage.py) nothing shows up?

I am working on Django web framework , Its been almost one year.
Today I ran into strange problem. when I run my manage.py runserver command on Django and try to see result in browser nothings shows up page is blank. Till yesterday it was fine. I am absolutely blank what to do.I though Due to Java script problem but even 127.0.0.1:8000/admin page is not showing.
I tried to change the port number ,used private browsing mode on browser both firefox and chrome still it shows nothing.
What is the problme? I tired to google it sstill I couldnot find solution of my problme. Need your help.
Thanks

JQuery html5 Loader not working in internet explorer

I created a site with a background video...
So to avoid page lagging i used a preloader.Works fine on every browser except ie.Can anyone help me this is a link to my site:Link
My site Files
It doesn't work, I've the same problem.
Output $("body").jpreLoader(); if browser != Chrome

ColdFusion pages hang, but only after loading content

We have a Windows server running ColdFusion 8. When I load a CF page from that server in a browser, the page content is displayed almost immediately, but the connection does not close. The browser's "page loading" icon keeps spinning for another ten seconds.
I did a test where I created two files: test.cfm and test.html and loaded them side by side on the server. Each file contains only a single line of text: "This is a test." When I load each page in a browser, both pages display the text immediately, but only the CF page keeps "loading" for another ten seconds.
This behavior is making our AJAX-driven pages unusable. What is causing this behavior, and how I can fix it?
There must be some code in there trying to do something. And it may not be in the page itself, it could be in an include or the application file.
That type of spinning cursor behaviour sounds like some sort of ajax call failing after the initial page load.
One thing that would help is to turn on ColdFusion debugging and post the results here.
ColdFusion and Ajax, out of the box work very well together, and ColdFusion has an almost insanely simple page debugging tool that make it extremely easy to see the execution path of the CFM file and where the page is spending its time.
Have you restarted the CF service? If there are already hung requests or other problems then that will likely be the only way to resolve.