Form not appearing using Django/HTML/Python [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am new to Django and web development. I don't know how to describe my problem. No idea what info to provide. I need some hints to debug.
I have two virtual machines. On one machine, I built my Django project, installed the package, and run it on apache2.
On the other machine, I run python manage.py runserver 0.0.0.0:8000 from the source codes.
Browsing the same page, the web page on machine 1 is OK.
But nearly every form disappeared on machine 2.
Checked the source of the two pages, they are the same.
The output on machine 2 seems OK too:
[17/Mar/2016 19:36:40] "GET /myapp/dashboard/reports/new HTTP/1.1" 302 0
[17/Mar/2016 19:36:40] "GET /myapp/dashboard/reports/0 HTTP/1.1" 200 43321
[17/Mar/2016 19:36:40] "GET /myapp/static/dist/css/vendor.css?v=v1.71 HTTP/1.1" 304 0
[17/Mar/2016 19:36:40] "GET /myapp/static/css/main.css?v=v1.71 HTTP/1.1" 304 0
[17/Mar/2016 19:36:40] "GET /myapp/static/css/dashboard.css?v=v1.71 HTTP/1.1" 304 0
[17/Mar/2016 19:36:40] "GET /myapp/static/css/query.css?v=v1.71 HTTP/1.1" 304 0
[17/Mar/2016 19:36:40] "GET /myapp/static/css/report.css?v=v1.71 HTTP/1.1" 304 0
[17/Mar/2016 19:36:40] "GET /myapp/static/dist/js/commons.bundle.js?v=v1.71 HTTP/1.1" 304 0
[17/Mar/2016 19:36:40] "GET /myapp/static/dist/js/analytics.bundle.js?v=v1.71 HTTP/1.1" 304 0
UPDATE
ERROR:
Uncaught TypeError: $(...).daterangepicker is not a functiont.exports.n.View.extend.initialize # analytics.bundle.js?v=v1.71:2e.View # commons.bundle.js?v=v1.71:56n # commons.bundle.js?v=v1.71:56t.exports.n.View.extend.initialize # analytics.bundle.js?v=v1.71:1e.View # commons.bundle.js?v=v1.71:56n # commons.bundle.js?v=v1.71:56(anonymous function) # analytics.bundle.js?v=v1.71:1c # commons.bundle.js?v=v1.71:24h.fireWith # commons.bundle.js?v=v1.71:24vt.extend.ready # commons.bundle.js?v=v1.71:24h # commons.bundle.js?v=v1.71:14
UPDATE
Solved this problem. see the error above. It failed to import some js files, and then the page not shown.

If they're each using separate copies of the database server, it may be that database migrations have not been run yet on machine 2.

Related

Flasgger: Swagger App - http://127.0.0.1:5000/apidocs/ - Fetch errorINTERNAL SERVER ERROR /apispec_1.json

I created a Flasgger/Swagger App in Spyder and got returned:
127.0.0.1 - - [28/Mar/2021 21:49:13] "GET /apispec_1.json HTTP/1.1" 500 -
127.0.0.1 - - [28/Mar/2021 21:49:13] "GET /flasgger_static/favicon-32x32.png HTTP/1.1" 200 -
When trying to visit this app in my Google Chrome browser via http://127.0.0.1:5000/apidocs/ I got back this error:
Fetch error
INTERNAL SERVER ERROR /apispec_1.json
What do I have to change here?

How to add response time in gunicorn access log

I have a gunicorn *config.py and need to add response time to gunicorn access log:
Here's what I have:
...
accesslog = some_path/filename
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
...
gunicorn version 19.7.1
Some more details:
*config.py didn't contain the seting access_log_format before, and I thought adding it might help, but even after I added and restarted the process, the access log contains the same parameters as before:
<ip> - - [16/Aug/2020:14:11:35 XDT] "POST /ws/v1/sessions?userId=<username> HTTP/1.1" 200 537 "-" "python-requests/2.22.0"
<ip> - - [16/Aug/2020:14:11:56 XDT] "DELETE /ws/v1/sessions HTTP/1.1" 200 139 "-" "python-requests/2.22.0"
<ip> - - [17/Aug/2020:04:05:40 XDT] "GET /ws/v1/data-specs HTTP/1.1" 200 35097 "-" "python-requests/2.22.0"
<ip> - - [17/Aug/2020:09:30:31 XDT] "GET /ws/v1/data-specs HTTP/1.1" 200 35097 "-" "python-requests/2.22.0"
I am new to python, gunicorn and web apis. I am unable to figure out how to add response time to the log. What am I doing wrong here? Please help.
From the documentation (https://docs.gunicorn.org/en/stable/settings.html#access-log-format)
The corresponding value for response time miliseconds is %(D)s

Django/Mezzanine: CSS "#import url()" not work properly

I have built the default mezzanine site.
However, in the admin page of the site, only part of the styles are applied to the site.
And I see some error logs
[18/Apr/2017 00:03:47] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 4251
[18/Apr/2017 00:03:47] "GET /static/grappelli/css/base.css/reset.css HTTP/1.1" 4
04 1709
[18/Apr/2017 00:03:47] "GET /static/grappelli/css/base.css/typography.css HTTP/1
.1" 404 1724
[18/Apr/2017 00:03:48] "GET /static/grappelli/css/base.css/modules.css HTTP/1.1"
404 1715
[18/Apr/2017 00:03:48] "GET /static/grappelli/css/base.css/tables.css HTTP/1.1"
404 1712
[18/Apr/2017 00:03:48] "GET /static/grappelli/css/base.css/forms.css HTTP/1.1" 4
04 1709
[18/Apr/2017 00:03:48] "GET /static/grappelli/css/base.css/widgets.css HTTP/1.1"
404 1715
[18/Apr/2017 00:03:48] "GET /static/grappelli/css/base.css/webkit-gradients.css
HTTP/1.1" 404 1742
[18/Apr/2017 00:03:48] "GET /static/grappelli/css/img/grappelli-icon.png HTTP/1.
1" 404 1721
It seems paths of some css files are wrong.
The path shouldn't be /static/grappelli/css/base.css/xxxx.css but /static/grappelli/css/xxxx.css
When I dig into the /static/grappelli/css/base.css file, I see this file imports those wrong path css files like this
...
#import url('reset.css');
#import url('typography.css');
#import url('modules.css');
#import url('tables.css');
#import url('forms.css');
#import url('widgets.css');
...
How to fix it?
I had the same issue on Ubuntu 16.04.3 with python3.5.1. This is an issue that has be noted in mezzanine bugs but I couldn't find a workaround.
I upgraded to ubuntu 17.04 with python3.5.3 and there was no issue, some deep dark magic is happening in grappelli here.

Periodic Django Logs in Terminal

I am new to Django and this question may seem to be easy. In the terminal where "python manage.py runserver" is executed, the following logs periodically appear.
[30/Sep/2015 02:36:02] "GET /messages/check/?_=1443574208652 HTTP/1.1" 200 1
[30/Sep/2015 02:36:08] "GET /notifications/check/?_=1443574208653 HTTP/1.1" 200 1
[30/Sep/2015 02:36:08] "GET /feeds/update/?first_feed=13&last_feed=6&feed_source=all&_=1443574208655 HTTP/1.1" 200 173
[30/Sep/2015 02:36:08] "GET /feeds/check/?last_feed=13&feed_source=all&_=1443574208654 HTTP/1.1" 200 1
[30/Sep/2015 02:36:39] "GET /notifications/check/?_=1443574208656 HTTP/1.1" 200 1
[30/Sep/2015 02:36:39] "GET /feeds/check/?last_feed=13&feed_source=all&_=1443574208658 HTTP/1.1" 200 1
[30/Sep/2015 02:36:39] "GET /feeds/update/?first_feed=13&last_feed=6&feed_source=all&_=1443574208657 HTTP/1.1" 200 173
[30/Sep/2015 02:37:03] "GET /messages/check/?_=1443574208659 HTTP/1.1" 200 1
My Django virtual environment is as follows:
bleach==1.4
dj-database-url==0.3.0
dj-static==0.0.6
Django==1.6.5
gunicorn==19.3.0
html5lib==0.9999999
Markdown==2.4.1
Pillow==2.4.0
psycopg2==2.6.1
python-decouple==2.2
six==1.9.0
South==0.8.4
static3==0.6.1
Unipath==1.0
Questions are:
Why does the logs periodically appear? I guess there is a background task running.But Celery package is not used here.
How to configure the logs, for example, displaying one more logs such as:
/followers/check/?_=9896886900907 HTTP/1.1
What do "?_" and the long string of numbers stand for? I can understand the "?first_feed=13" means the querying parameter in Django request object.
GET /notifications/check/?_=1443574208656
When Django is run in development mode (with runserver) it prints a line for all HTTP requests received to the console.
All of them are coming from the outside, browsers, feed readers...
The parameters you are wondering about are GET query parameters. The ? is the delimiter so, _ is the key of the argument.
In development mode the logging is defined by default. If you want to have logging on your production system or more logging, read https://docs.djangoproject.com/en/1.8/topics/logging/ .

Error getting started with cloud endpoints on GAE

I'm just getting started with cloud endpoints by following the tutorial from
here.
Even when i copy paste the code exactly, I'm unable to look at the custom endpoin methods. When I run the project and type
http://localhost:8080/_ah/api/explorer
I get redirected to a blank api-explorer page. Here are the logs from the App Engine Launcher
INFO 2015-09-22 20:45:52,114 devappserver2.py:763] Skipping SDK update check.
INFO 2015-09-22 20:45:52,661 api_server.py:205] Starting API server at: http://localhost:53371
INFO 2015-09-22 20:45:52,676 dispatcher.py:197] Starting module "default" running at: http://localhost:8080`
INFO 2015-09-22 20:45:52,676 admin_server.py:118] Starting admin server at: http://localhost:8000
INFO 2015-09-22 20:46:08,792 module.py:808] default: "GET /_ah/api/explorer HTTP/1.1" 302 -
INFO 2015-09-22 20:46:12,805 module.py:808] default: "GET /_ah/api/explorer HTTP/1.1" 302 -
INFO 2015-09-22 20:46:17,711 module.py:808] default: "GET /_ah/api/static/proxy.html?jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.z0-pPDgHPQw.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Ft%3Dzcms%2Frs%3DAGLTcCO4-ZDXf1JrE4AXDItAeFdjXKLW8w HTTP/1.1" 200 7690
The app.yaml and python files are exactly as described in the tutorial.
Can someone please tell me what exactly is going on and how to fix it.

Categories