Question

How i can chnage source code of django site with nginx and gunicorn

Posted September 8, 2021 88 views
Django

Hi everyone. i am facing problem while updating source code of my site through filezilla. i made many changes to the source code but these changes dosnt change any thing in my site. please help. i am new here

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

Once you upload your new changes, you might also have to restart the Gunicorn service so that the new changes could be reflected:

sudo systemctl restart gunicorn

Hope that this helps!
Best,
Bobby

  • Thank you bobbyilive.
    It’s work for me.

    But I have another problem I hope u will help me.

    My django admin css not working. I also run the python manage.py collectstatic command but still css not working.

    shahabandmurad@gmail.com Is my email. I will send you some screenshots

    Please help

    • Hello,

      No problem at all!

      Regarding the CSS, have you defined the STATIC_ROOT and STATIC_URL?

      You can find the steps on how to do that here:

      https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-20-04

      Let me know how it goes!
      Regards,
      Bobby

      by Erin Glass
      Django is a powerful web framework that can help you get your Python application or website off the ground. Django includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server is required.
      • I follow the same steps while deploying the site.

        server {
        listen 80;
        servername serverdomainorIP;

        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /home/sammy/myprojectdir;
        }
        

        }

        Basically there is no user in my vps. and my site is inside a directory name “projectdir”.

        So
        root /projectdir/static is the correct path for my static path.??

        • Hello,

          If you are visiting your_ip/projectdir to see your project via your browser, then it should be like this:

          STATIC_URL = '/projectdir/static/'
          import os
          STATIC_ROOT = os.path.join(BASE_DIR, 'projectdir/static/')
          

          As per the tutorial, this needs to be adjusted in the ~/myprojectdir/myproject/settings.py file.

          • Hi sir. My site css worked now.

            But I have another problem. I purchased domain from godaddy. I used that domain for another droplet and now I destroy the droplet. I want to link the domain with another droplet but when I add domain to my new droplet an error is generated.

            Error is. This domain already exists. What I do now.