Django admin CSS missing, after collecting static, with python manage.py runserver - python

I run django project on django 1.8.0, with "django manage.py runserver".
It is to be noted that the admin page worked perfectly with CSS a few months ago. However without any change in any file in the project directory (checked with git), the django admin page is missing now its CSS files.
I've noticed that many have had similar problems but I have been unable to solve the problem with their solution. e.g. running manage.py collectstatic.
[13/Dec/2015 00:35:00]"GET /admin/login/?next=/admin/ HTTP/1.1" 200 1931
[13/Dec/2015 00:35:00]"GET /static/admin/css/base.css HTTP/1.1" 200 1591
[13/Dec/2015 00:35:00]"GET /static/admin/css/login.css HTTP/1.1" 200 1591
As you can see the css file is accessed normally according to the log, but the css file received by the browser is empty.
Your help would be very appreciated. Thanks.
UDPATE:
All the files are given the read access as you can see below!

You need to enable DEBUG and enable staticfiles app. If you do not want to enable DEBUG, you may run runserver with --insecure commandline parameter.
https://docs.djangoproject.com/en/1.9/ref/contrib/staticfiles/

[I answer since I cannot comment]
You should check the permissions on these files. Make sure that read access is given to all users !
You can give read access to all with this command
chmod a+r static_file

Related

How to fix "Unable to fetch link_token" with Plaid API?

I followed the instructions here: https://dashboard.plaid.com/overview/sandbox.
I have everything setup the way it should, my .env looks like this:
PLAID_CLIENT_ID=myclientid
PLAID_SECRET=mysandboxsecret
PLAID_ENV=sandbox
PLAID_PRODUCTS=auth,transactions
PLAID_COUNTRY_CODES=US,CA
PLAID_REDIRECT_URI='http://localhost:3000/'
I did try leaving URI blank as well - made no difference.
For some reason, I continue to get this error when I visit http://localhost:3000 after running npm start
Unable to fetch link_token: please make sure your backend server is running and that your .env file has been configured correctly.
The error code, error type, and error message are all blank.
Here are the terminal outputs for ./start.sh & npm start
./start.sh
* Serving Flask app "server" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)
127.0.0.1 - - [22/Feb/2022 20:05:45] "POST /api/info HTTP/1.1" 200 -
127.0.0.1 - - [22/Feb/2022 20:05:45] "POST /api/create_link_token HTTP/1.1" 200 -
npm start
> plaid_react_quickstart#0.1.0 start
> react-scripts start
[HPM] Proxy created: / -> http://localhost:8000
ℹ 「wds」: Project is running at http://192.168.1.45/
ℹ 「wds」: webpack output is served from
ℹ 「wds」: Content not from webpack is served from /Users/user/plaid/quickstart/frontend/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...
Compiled with warnings.
src/dataUtilities.ts
Line 11:3: 'AssetReportGetResponse' is defined but never used #typescript-eslint/no-unused-vars
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
Does anyone familiar with Plaid API know how to fix this?
It feels like the API/quickstart process has changed a bit since those postings.
EDIT:
I re-cloned the repo and started from step 1 and re-did everything. It all works now. I traced the issue back to an extra digit at the end of my SECRET. Thank you Alex for the help, but it was all a silly mistake. Cheers!
You can always get more data about what went wrong by looking at the activity log at https://dashboard.plaid.com/activity/logs. That said, the most common causes of this issue are the following:
Specifying a REDIRECT_URI in the .env file but not adding it to "allowed redirect uris" at https://dashboard.plaid.com/team/api
Being on Windows and not cloning the repo in a manner that preserves symlinks, which you can do like this:
git clone -c core.symlinks=true https://github.com/plaid/quickstart
try this answer as well, seems like python3.9 certificates are missing for mac os
https://stackoverflow.com/a/68595419/6013354

502 Bad Gateway: Registered endpoint failed to handle the request. : Python

I'm trying to deploy an app developed using python and flask on ibm cloud.
The app is pushed and starts as well, but when i visit the link I get the error:
502 Bad Gateway: Registered endpoint failed to handle the request
My manifest file looks like this:
applications:
- name: people
memory: 256M
command: python main.py
random-route: true
services:
- eapenDB2
My procfile looks like this:
web: people
What the console looks like after pushing the app:
These are the logs I have. I hope they're helpful:
Sorry about the long post. But really hoping you can help me.
Python requires __init__.py in every folder if we modularize the code into multiple folders. In our case we had run.py in the root and rest of the code inside multiple folders in "src" folder.
A good article on that:
https://damyanon.net/post/flask-series-structure/

How can I debug Openstack Dashboard?

I'm running the Openstack Cloud System. I installed and deployed the kilo version on the server successful, but this is only the default version of Openstack. So that, I want to have some modifies on this openstack source and add more features to it.
I started to change something with the Openstack Dashboard. However, there are some problems happened. Therefore, I have debugged this django web application. All everything I have configured is the same as the official tutorials on the openstack website (http://docs.openstack.org).
So, I have search on my server and find out 2 places that have the sources:
The first one is /usr/share/openstack-dashboard/
The second one is /usr/lib/python2.7/dist-packages/horizon/
And the config file is /etc/openstack-dashboard/local_settings.py
I set the option Debug = True in local_settings.py file.
On the server I typed these commands:
cd /usr/share/openstack-dashboard/
python manage.py runserver
Here is the output:
RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
WARNING:py.warnings:RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
WARNING:py.warnings:RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
Performing system checks...
System check identified no issues (0 silenced).
August 05, 2015 - 09:28:50
Django version 1.7.6, using settings 'openstack_dashboard.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
But in the browser, it shows the error:
And then, on the console, it shows:
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Aug/2015 10:21:29] "GET / HTTP/1.1" 302 0
Not Found: /horizon/auth/login/
[05/Aug/2015 10:21:29] "GET /horizon/auth/login/?next=/ HTTP/1.1" 404 4237
Not Found: /favicon.ico
[05/Aug/2015 10:21:29] "GET /favicon.ico HTTP/1.1" 404 4206
Please help me to get out of this problems. And how can to debug Openstack Django Website properly.Thank you very much !
As you run server by runserver command you should go to the root url like
127.0.0.1:8000/
not
127.0.0.1:8000/horizon
The difference is in running method.
When you installed openstack_dashboard there is apache config that listen to address http://host/horizon look in to /etc/apache2/conf/sites-available/
The directories
/usr/lib/python2.7/dist-packages/horizon/
Is like the framework for all dashboards
/usr/share/openstack-dashboard/
Is the default dashboard for openstack
/etc/openstack-dashboard/local_settings.py
The config file for dashboard. Here you can apply changes for default dash, for example attach your project that modifies or extends default dash
So, your problem will be solved if you follow that link http://127.0.0.1:8000/
For debugging use
pdb or ide with integrated debugger
Follow this link.
http://docs.openstack.org/developer/horizon/quickstart.html
Once this is done, add pdb statements to your code that you wish to debug.Go into the horizon folder and run the following command
./run_tests.sh --runserver 127.0.0.1:port_number
Instead of local host you can put in the IP address where horizon is running
I have written the OpenStack documentation for debugging dashboards using PyCharm.
(It is good for any Openstack Dashboard including Horizon)
http://docs.openstack.org/developer/mistral/developer/troubleshooting.html

Django and Gunicorn: 403 Forbidden

I have a django application inside /home//my_app that I am trying to deploy using gunicorn:
sudo gunicorn --workers=2 -b :8081 tutorial.wsgi:application
After deploying the application with the command above, I log into another ssh instance (on the same server) and run the following command:
wget 127.0.0.1:8081
This returns a 403 FORBIDDEN.
Things I have tried:
1. Tried to chmod 755, and even 777, in app directory (Did not work)
2. Tried to move app directory to /etc/www/myapp (Did not work)
3. Tried to run all commands using root access (Did not work)
It is worth noting that I am not that familiar with linux and that this error is literally driving me crazy.
SOLVED IT:
after downloading cURL, in order to see the http header, it turned out that the service worked, but returned a 403 because a missing token authorization. Oops.
Please make sure you have coded views.py and urls.py to server GET requeat at /.

Running Django with gunicorn: Bad Request (400)

I am following this tutorial to set up a Django application and serve it with Gunicorn on a Debian DigitalOcean server: http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
I have got as far as the section starting "Now that you have gunicorn, you can test whether it can serve your Django application by running the following command". Now I'm stuck.
In other words, I can successfully run the application using python manage.py runserver, but not by using gunicorn.
I've successfully accessed my app with:
$ python manage.py runserver xx.xx.xx.xx:8000
Now from the same directory, I'm trying to run:
$ gunicorn my_django.wsgi:application --bind xx.xx.xx.xx:8001
It appears to start OK, but when I go to http://xx.xx.xx.xx:8001, I see:
Bad Request (400)
I'm not sure how to debug this: there's nothing in /var/log/gunicorn/.
I have set ALLOWED_HOSTS=['xx.xx.xx.xx'] in my settings file.
UPDATE: Being an idiot: gunicorn was looking in production settings file, not local settings file. Setting the ALLOWED_HOSTS in production settings fixed it.
I'd still really like to know how to debug problems like this though.
The answer: gunicorn was looking in production settings file, not local settings file. Setting the ALLOWED_HOSTS in production settings fixed it.

Categories