Umut
I had to change the server, but now when I upload the files to the host, I get an error like this
Umut
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Umut
<system.webServer>
<handlers>
<add name="djhand" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python31\python.exe|C:\Python31\lib\site-packages\wfastcgi.py" resourceType="Unspecified" />
Umut
Is there anyone to help with this?
Hemant
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
Logs
What I am using is
from pathlib import Path
import os
from django_heroku import settings
.
.
.
.
.
settings(locals())
End of file
Hemant
I commented out my SECURITY_KEY variable
Hemant
on google there are some ways mentioned to randomly create a key and then push it to .env file
Hemant
Hemant
but now it's not even building and giving me error for static_root as empty
Hemant
i was using staticfiles_dir = [ BASEDIR / 'app/static'] and it was working fine on local machine but in remote production even static_root isn't working
python manage.py collectstatic
gives
File "/usr/lib/python3.10/posixpath.py", line 378, in abspath
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not tuple
Solved this and answer is number 2
Hemant
Hemant
What approach do you use for using static files in your project?
Hemant
STATICFILES_DIRS = [ BASE_DIR / 'app/static/', ] was working for me locally but in production it doesn't
Refused to apply style from 'https://hemant-to-do.herokuapp.com/static/style/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Juan Arriagada 🇨🇱
What approach do you use for using static files in your project?
django development server serves static files during development (locally), but in production the strategy is diferent
This can help: https://docs.djangoproject.com/en/4.0/howto/static-files/deployment/#serving-static-files-in-production
Juan Arriagada 🇨🇱
what i do, is to serve them using nginx
Juan Arriagada 🇨🇱
hi btw! im a developer from Chile, nice to meet you all.
Hemant
Hemant
and styling is also working even I have not set anything for my 'app/static/style/main.css' file
Juan Arriagada 🇨🇱
are you using the built-in server? (python manage.py runserver)
Hemant
project/settings.py
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
app/template/main.html
<link rel="stylesheet" href="{% static 'style/main.css' %}" />
actual file at
app/static/style/main.css
Hemant
Hemant
am deploying my code on heroku
link: https://hemant-to-do.herokuapp.com
Juan Arriagada 🇨🇱
build-in server does that for you
Hemant
Hemant
I also added
import mimetypes
mimetypes.add_type("text/css", ".css", True)
in settings.py
Juan Arriagada 🇨🇱
DEBUG= ?
Hemant
If add my css code to html file
everything is fine in production
Hemant
DEBUG= ?
DEBUG = os.getenv('DEBUG', False)
(provided no value in heroku)
exported true locally
Juan Arriagada 🇨🇱
try True in heroku
Hemant
Juan Arriagada 🇨🇱
but its because you're using the built-in server... you should use gunicorn or similar. Read the docs.
Juan Arriagada 🇨🇱
https://docs.djangoproject.com/en/3.2/howto/deployment/
Juan Arriagada 🇨🇱
(check the version you're using to match the docs)
Hemant
Hemant
when I removed style from html
Hemant
debug = true is just supressing
Refused to apply style from 'https://hemant-to-do.herokuapp.com/static/style/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
kv
What is this error
The view myproduct.views.Insertrecord didn't return an HttpResponse object.It returned None instead
Charly
Hemant
everything is fine locally but on production it says
403 Forbidden
CSRF verification failed. Request aborted.
Hemant
what could be the issue
I am accessing SECRET_KEY using environment variable
explod
Hemant
Hemant
I have only 4 forms
Hemant
and all have the token
Hemant
maybe I need some rest and then I'll come up with a stupid mistake
Jabed
http://dpaste.org/nE4K
Jabed
http://dpaste.org/nE4K
here I just want to get all objects from forms.py
but error shows that "type object 'request_b' has no attribute 'objects'"
Anonymous
How to show response of generic forigenkey data in serializer ?
Christof
Bot has the fitting right?
mukhil
When we change input box in html that data how can call from view
(Without click submit button)
mukhil
Anyone can help ?👆
Charly
mukhil
😳😭I don't know java
Charly
mukhil
Can you help me sir
mukhil
😒
mukhil
Which function using for this purpose
Charly
mukhil
Ok
इमरान عمران Imran
I'm using s3 bucket to serve static files in django app, but the images are not loading up it's showing "The authorisation mechanism you have provided is not supported...." , plz help me
Lucky
Store image in database in django with dateformat
Yuvraj
Hey I'm new to django thing, how can i get started with?
Sukuna
Learn from YouTube check documentation
Hemant
maybe I need some rest and then I'll come up with a stupid mistake
such a nice thing I noticed
I just can not login with any user from my login template
(shows csrf token mismatch)
If I directly go to the register form and create a new user there... it logs in with that user, the whole app works fine (adding new tasks in to-do app, editing and deleting tasks all works)
Hemant
Hope this describes my situation well https://stackoverflow.com/questions/70890682/csrf-verification-failed-request-aborted-only-for-login-page
Anonymous
How to use generic forigenkey relationship in serializer
Rohit 007
any one help me iam getting this error TypeError: 'function' object is not subscriptable
Rohit 007
Okay thanks
Mirco