in Education by
I have deployed a Django project on Ubuntu 16.04 with Nginx and Gunicorn. I have gotten everything, including the static files but my media files will not serve properly. settings.py MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') models.py resume_upload = models.FileField(blank=False, upload_to='resumes', null=True, validators=[FileExtensionValidator(allowed_extensions=['pdf']), validate_file_size]) What I have listed in /etc/nginx/sites-available/ is server { listen 80; server_name website.com www.website.com ; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/syed/btawebsite; } location = /media/ { root /home/syed/btawebsite; } location / { include proxy_params; proxy_pass http://unix:/home/syed/myproject.sock; } } I would like go on the admin, click on the uploaded file and be able to view the file in the browser. Anyone have any ideas on how I can achieve this? I have verified through using the terminal and looking through the directories that the files are in fact adding to ~btawebsite/media/resumes but I am unable to view them when I click the admin url. When I click on that url I get an error: Not Found The requested resource was not found on this server. Update: I have changed settings.py to STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static/'), ) STATIC_ROOT = os.path.join(BASE_DIR, 'static/') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') And nginx settings to location /static/ { alias /home/syed/btawebsite/static/; } location = /media/ { alias /home/syed/btawebsite/media/; } Static is still working, however, media is not. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
For nginx configuration, the "=" sign after location means this is the exact location match. So change your settings to location /media/ { root /home/syed/btawebsite; } and same for /static/. It's correct for the favicon. For more about the nginx location directive, check this.

Related questions

0 votes
    After a bit of a struggle to set up AWS Route53 IPv6 and my DSN (Ionos) I've managed to set up ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    My Django app is unable to see MEDIA directory. When I run one of my views I need to open a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I have nginx installed with PHP-FPM on a CentOS 5 box, but am struggling to get it to serve any ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    The below image shows my question in detail: it works when client version is changed to 5 beta but ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I want to merge two branches that have been separated for a while and wanted to know which files have been modified ... I missed... Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    I have a very long forms.py and I'd like to split it to smaller parts with as few as possible ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    How to configure static files in Django?...
asked Jul 1, 2021 in Technology by JackTerrance
0 votes
    Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    I am trying to look at a cone in 3D, for which I used gluLookAt. I draw a cone in the middle ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I am trying to inflate one of my fragments. However, the fragment does not show up in the autosuggest ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I am trying to look at a cone in 3D, for which I used gluLookAt. I draw a cone in the middle ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    Hi I'm having some issues showing lists in my embed correctly. I'm trying to get my roles to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I am trying to implement the Hateoas using spring boot. In my UserController class i have used the below ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    Every now and then, variables just stop showing up in the Workspace pane. who and whos show that there ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
...