Setting up Django with uWSGI and nginx - I've been trying to figure this out for 5 days now. Please help...
I'm trying to set up nginx server with my django app and uWSGI, by following this tutorial: https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
I've been able to follow it up until the socket testing. The test itself doesn't produce an error, but localhost:8000 always returns 502 bad gateway error. I have been troubleshooting this for hours but can't figure out what I'm doing wrong.
/etc/nginx/nginx.conf:
```
#user http;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
# load configs
include /etc/nginx/sites-enabled/*;
types_hash_max_size 4096;
server_names_hash_bucket_size 128;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/<userprofile>/Projects/<project-name>/mymoon/journey/templates/journey/; # /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
```
/etc/nginx/sites-available/mymoon.conf
```
# mymoon_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///home/Projects/<project-name>/mymoon/journey/journey.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen
/r/djangolearning
https://redd.it/sc7jt2
I'm trying to set up nginx server with my django app and uWSGI, by following this tutorial: https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
I've been able to follow it up until the socket testing. The test itself doesn't produce an error, but localhost:8000 always returns 502 bad gateway error. I have been troubleshooting this for hours but can't figure out what I'm doing wrong.
/etc/nginx/nginx.conf:
```
#user http;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
# load configs
include /etc/nginx/sites-enabled/*;
types_hash_max_size 4096;
server_names_hash_bucket_size 128;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/<userprofile>/Projects/<project-name>/mymoon/journey/templates/journey/; # /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
```
/etc/nginx/sites-available/mymoon.conf
```
# mymoon_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///home/Projects/<project-name>/mymoon/journey/journey.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen
/r/djangolearning
https://redd.it/sc7jt2
reddit
Setting up Django with uWSGI and nginx - I've been trying to...
I'm trying to set up nginx server with my django app and uWSGI, by following this tutorial:...
i want to Redirect to the same view after delete??
**so after deleting comment i can't back to detailviews of my comments , i need back with the pk of the post**
\#error
`Reverse for 'CommentsBack' not found. 'CommentsBack' is not a valid view function or pattern`
#views
# list all the comments of ever post l
class comment_back (DetailView):
model=Post
template_name='CommentsBack.html'
#delete comment by his primary key
def delete_comment(self,pk):
event=Comment.objects.get(pk=pk)
event.delete()
return redirect('CommentBack')
​
#urls
path('mypost/<int:pk>/commentBack', comment_back.as_view(),name="commentBack"),
path('DeleteComment/<int:pk>/remove', views.delete_comment,name="delete_comment"),
/r/djangolearning
https://redd.it/uplkto
**so after deleting comment i can't back to detailviews of my comments , i need back with the pk of the post**
\#error
`Reverse for 'CommentsBack' not found. 'CommentsBack' is not a valid view function or pattern`
#views
# list all the comments of ever post l
class comment_back (DetailView):
model=Post
template_name='CommentsBack.html'
#delete comment by his primary key
def delete_comment(self,pk):
event=Comment.objects.get(pk=pk)
event.delete()
return redirect('CommentBack')
​
#urls
path('mypost/<int:pk>/commentBack', comment_back.as_view(),name="commentBack"),
path('DeleteComment/<int:pk>/remove', views.delete_comment,name="delete_comment"),
/r/djangolearning
https://redd.it/uplkto
reddit
i want to Redirect to the same view after delete??
**so after deleting comment i can't back to detailviews of my comments , i need back with the pk of the post** \#error `Reverse for...