7 Critical Django Production Server Settings to Configure Before Going Live

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ม.ค. 2025

ความคิดเห็น • 112

  • @EvaLindner-v7v
    @EvaLindner-v7v 10 หลายเดือนก่อน +3

    Clear, concise, competent and to the point. Thank you!

    • @TonyTeachesTech
      @TonyTeachesTech  10 หลายเดือนก่อน

      You're welcome! Subscribe for more :)

  • @markwollert565
    @markwollert565 3 ปีที่แล้ว +8

    Dude, I'm so grateful to you for the work you've done on all of your videos

  • @madanielmadaniel
    @madanielmadaniel 3 ปีที่แล้ว +9

    1:32 - As for the secret key, also recommended to check the module 'decouple'. It does the same thing but in more elegant way.

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว +1

      Thanks for the tip Daniel

    • @ChiragVora
      @ChiragVora 3 หลายเดือนก่อน

      Or dotenv.
      Modules like these also help to hide other credentials like database name password and username etc

    • @campbuzz-n8j
      @campbuzz-n8j 15 วันที่ผ่านมา

      what perms do you set for the file that stored the secret key?

  • @anselsolomon6270
    @anselsolomon6270 3 ปีที่แล้ว +3

    This is the first time am actually seeing someone on TH-cam shows with detail how to configure settings for Django production environment....i really appreciate you much on this....please can you make a video on how to deployment django with ability to send emails?? And with postgresql as the database???.....Thanks alot

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      Probably not postgres but I will consider a Django email tutorial :)

  • @arnauadell4824
    @arnauadell4824 ปีที่แล้ว

    Fucking amazing how quickly and concisely you could share all this information. And with very clear pronunciation too! Coming here in the future for any other django information I need.

  • @krzysztofszumko9080
    @krzysztofszumko9080 4 ปีที่แล้ว +5

    Great Video! Straight to the point, no time wasted just awesome :). Keep up the good work.

  • @jvoynar5826
    @jvoynar5826 ปีที่แล้ว +1

    Very nice, thank you!

  • @cheesecakelover2078
    @cheesecakelover2078 3 ปีที่แล้ว +1

    This was an amazing video, learnt quite a lot of things which turned out to be very important! Thank you so much :)

  • @KenoAlordiah
    @KenoAlordiah 3 ปีที่แล้ว

    Thank you so much for helping me figure this out. There were quite a number of settings I skipped on my production site settings.py file. Thanks once again.

  • @vectoralphaSec
    @vectoralphaSec 10 หลายเดือนก่อน +1

    Have you made a video about deploying a Django site to a PaaS?? I feel IaaS is too hard and complicated for beginners like me. I don't feel i need all that control and setup a full Linux server from scratch for a simple portfolio website.

  • @TheLolcheater
    @TheLolcheater 3 ปีที่แล้ว

    Best Tutorial i have ever seen! Your Awsome!

  • @johnsolly
    @johnsolly 2 ปีที่แล้ว

    What a solid video. Thanks! I just implemented these changes on my site!

  • @pabloxD75
    @pabloxD75 3 ปีที่แล้ว +1

    What a great video with a great recommendations, thank you

  • @NoajmIsMyName
    @NoajmIsMyName ปีที่แล้ว

    Tony. Tony. Tony. You are awesome!

  • @jcmbisa4241
    @jcmbisa4241 2 ปีที่แล้ว

    handsome, smart, and well rich too, man many thanks 😀😀

  • @joemusya2529
    @joemusya2529 2 ปีที่แล้ว

    Found this video in the right time💯💯🤗😊

  • @Slickjitz
    @Slickjitz 3 ปีที่แล้ว

    Wow this was super helpful, thanks!

  • @MadaMediaproduction
    @MadaMediaproduction 2 ปีที่แล้ว

    Great video thank you , i have issue with deploying project with Django corntab its works normally in local but in after production its not working anymore any hint to fix this issue

  • @anindyabhattacharya4878
    @anindyabhattacharya4878 4 ปีที่แล้ว

    precise content man.. good job.

  • @rsnor1425
    @rsnor1425 3 หลายเดือนก่อน

    Good work!
    Please, make a tutorial to full deploy in Namecheap hosting... they have an strange way to serve static files for Admin panel

  • @ingermanpaez8449
    @ingermanpaez8449 4 ปีที่แล้ว

    I am so grateful. God bless you son.

  • @shivamdubey4783
    @shivamdubey4783 2 ปีที่แล้ว

    Great tutorial sir do we have to change the file upload settings also

  • @mukibulhasan
    @mukibulhasan 3 ปีที่แล้ว

    nice information bro

  • @ethanroman6883
    @ethanroman6883 4 ปีที่แล้ว

    Great video, keep going

  • @andresdemillos01
    @andresdemillos01 2 ปีที่แล้ว

    Un muy buen video felicitaciones por tu trabajo es un canal muy vacano de seguir (Y)

  • @jayeshkarkare9334
    @jayeshkarkare9334 4 ปีที่แล้ว

    Grt work bro,thnx a lot

  • @campbuzz-n8j
    @campbuzz-n8j 15 วันที่ผ่านมา

    what perms do you set for the file that stored the secret key?

  • @truefugazi
    @truefugazi 8 หลายเดือนก่อน

    So I am having issue, I hosted my project with render with a DB SQLite and when ever I update a listing in my admin after a few hours it resets/removes my listing I can’t seem to find my way around this please help

  • @agresiv0
    @agresiv0 2 ปีที่แล้ว

    Is it best practice to use the same database for development and production?

  • @nitensapkota8606
    @nitensapkota8606 2 ปีที่แล้ว

    Subscribed 🙌 can please make a video on how to access static files if you're hosting static files in digital ocean spaces ...i have hosted my static files in digital ocean spaces and I am not able to change anything on those files ..i have search online about it but they says AWS S3 is not mutable i have to download the files and edit the hosted file and then re-upload it which is not convenient ..

  • @thebewerter5730
    @thebewerter5730 4 ปีที่แล้ว

    Cool, thanks!

  • @daniellloyd5584
    @daniellloyd5584 3 ปีที่แล้ว

    Thank you!

  • @codepen2035
    @codepen2035 2 ปีที่แล้ว

    Brother when I enable debug=False Static file not working? Please help me. I am using VPS hosing with centos 7

  • @enriqueuzcategui6057
    @enriqueuzcategui6057 2 ปีที่แล้ว

    Hey Tony! Thanks for the video! I have a problem with a Django deployment, how can I hide the "Server" header? It's something i am being asked to do but I don't seem to find a way to hide/remove it. Thank you!

  • @mahdidaoud
    @mahdidaoud 3 ปีที่แล้ว

    Can you please explain the SECURE_PROXY_SSL_HEADER setting what it does for the django project and how to set it

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      I have not used this one before, but here is the docs on it docs.djangoproject.com/en/3.2/ref/settings/#secure-proxy-ssl-header

  • @MrSiamtea
    @MrSiamtea 3 ปีที่แล้ว +1

    I have a problem in reading env variables from ubuntu server. I can hide the credentials to environment just fine in devlopment as well as production. But the trick is my django app cannot retrieve that env keys in production. I'm missing something. I am searching for solutions, still searching for it. I'm not a great programmer, but I don't think this is hiding the secret key. It just relocate the key to a text file which is in the same directory as the app itself. How is that hiding? I'm confused.

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      Hmm, I'm not sure how to help you with this.

  • @joelmiruni8660
    @joelmiruni8660 3 ปีที่แล้ว

    Brief and Straight to the point. Thanks. How could i solve this error: [Errno 99] Cannot assign requested address while registering users via email confirmation. Everything seems to work fine in development.

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      Hi Joel, I'm not familiar with that error. Sorry

  • @ricosun
    @ricosun 3 ปีที่แล้ว

    I was wondering what is the purpose of the secure key and why we need to hide it. Also what about the database connection string? Should we hide that as well ?

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      You can see the official documentation for these values here docs.djangoproject.com/en/3.2/ref/settings/#secret-key

    • @ricosun
      @ricosun 3 ปีที่แล้ว

      @@TonyTeachesTech Cool Thx

  • @navidazimi7816
    @navidazimi7816 3 ปีที่แล้ว

    Thank you so much this was so useful 🙏🏻
    Btw,I’m trying to serve my media files from a file hosting service that is connected to my main domain as a sub domain.
    I don’t know how should i tell Django to upload video files(inside media) to the other host..
    Any help will be appreciated🙏🏻
    Thank you so much🙏🏻

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      Thanks! Sorry I don't have experience with Django uploads

  • @bronaxcorps4243
    @bronaxcorps4243 ปีที่แล้ว

    Hey how can I separate my development database from my production database??

  • @G-3-A-R-Z
    @G-3-A-R-Z 3 ปีที่แล้ว

    Why not a secret key in an .env? Coming from the JS world just a few weeks ago. Noticed they used a similar system.

  • @Alex-hp9no
    @Alex-hp9no 2 ปีที่แล้ว

    hi, Im having trouble with media files, when I turn debug=True, then all of user added images shows on the page, and when i turn it False, it says the image is not found..
    usual configurations in settings.py:
    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, "static/")
    MEDIA_URL = "/media/"
    MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
    and also urls:
    url.. = [
    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    pls help me out here

    • @TonyTeachesTech
      @TonyTeachesTech  2 ปีที่แล้ว

      Appreciate the code snippet. I would look at the URL of the image that's not found and compare that to the path on your filesystem

  • @dscreats
    @dscreats 4 ปีที่แล้ว

    i got this error how to resolve with open (os.path.join(BASE_DIR, 'SECRET_KEY.text')) as f: SECRET_KEY = f.red().strip()
    AttributeError: '_io.TextIOWrapper' object has no attribute 'red'

    • @TonyTeachesTech
      @TonyTeachesTech  4 ปีที่แล้ว

      No attribute 'red'? That would be a syntax error... red -> read

  • @toluwanimiadeyemo8099
    @toluwanimiadeyemo8099 3 ปีที่แล้ว

    Great video! Thanks
    But how do I hide my database details, email details
    What about using .env file?

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว +1

      Yes you can use an env file that's above of the root of your website

  • @Goodforyouliving
    @Goodforyouliving 3 ปีที่แล้ว

    When I change DEBUG=False all my media files (images) are not showing up? What is the correct way to make this work ?

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      I don't know why that is happening

    • @BlueBrendan2000
      @BlueBrendan2000 3 ปีที่แล้ว

      You've probably figured this out by now but I'll just leave this for anyone who may stumble upon this. I ran into this issue and spent hours looking for a fix
      1. I wrote the src attribute for all my image elements with a hardcoded path (src="/images/somewhere/something.png"). In the official docs, it says to use the static template tag {% static "image path" %}. The static module can contain EITHER a string or a template variable but NOT both, so if you need that functionality then you'll have to create a custom template filter to append the strings together (the add filter didn't work for me). If you don't, then you can skip to step 2. There's an answer describing how this is done on stackoverflow (appending template variable in static TAG). An example of this is if the directory you need is /static/images/files/filename.png, and filename.png is stored in template variable {{ filename }}, the code you'll need in your html file will look like this
      {% with 'images/files/'|customfiltername:filename as variable_name %}
      {% endwith %}
      customfiltername is what performs the concatenation of 'images/files' with the contents of filename (again, this filter does not exist and needs to be written by you). As a note, make sure you include {% load static %} and {% load *name of the file that contains your custom template filter %} at the top of each file that contains an image
      2. I messed up the static paths in my settings dot py file: there's STATIC_URL (the directory of the main static folder), STATICFILES_DIR (provides directory for static files in individual apps that are outside the main static folder), and STATIC_ROOT (used only when DEBUG=False). STATIC_ROOT exists because in production, Django doesn't serve static files from individual apps the way it does in production, so it bundles them all together in a single location. STATICFILES_DIR and STATIC_ROOT can't have the same name, so I used a folder called staticfiles to be used solely for production (static is the name of my main static folder used in development). To set your STATIC_ROOT directory, choose a directory name (I chose staticfiles), add the setting to your settings file, create an empty folder of the name you chose in the root folder of your project, and run the command "python manage dot py collectstatic". This will automatically traverse all the static files in your project and add them to the folder you chose in STATIC_ROOT
      Once I made these changes (added STATIC_ROOT to the settings, created the corresponding folder, ran the collectstatic command to populate it with files, and changed the source of all images in my project to use the {% static %} template tag), the images finally showed up as expected with DEBUG=False. I really hope this helps!

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      @@BlueBrendan2000 This will surely be helpful for others. Thanks!

  • @manuponot5093
    @manuponot5093 3 ปีที่แล้ว

    Hello I have my website on production on Digital Ocean. My settings.py file has the Debug = False. I ran systemclt restart gunicorn command but nothing changed. However, I see the the page as if it was in Debug Mode. Please, how I can fix this issue ?

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      Could this be a browser caching issue? Have you tried incognito or a guest window?

    • @manuponot5093
      @manuponot5093 3 ปีที่แล้ว

      @@TonyTeachesTech My problem is solved thanks

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      @@manuponot5093 What that the issue?

    • @manuponot5093
      @manuponot5093 3 ปีที่แล้ว

      ​@@TonyTeachesTech It was my fault I have created a config file local_settings.py and didn't remeber that it exists and it was Debug = True inside

  • @kunalkashyap100
    @kunalkashyap100 3 ปีที่แล้ว

    If I make these changes while my website is running on the server, do I need to restart the uwsgi service after making these changes or not?

  • @viveksharmapec7637
    @viveksharmapec7637 4 ปีที่แล้ว +1

    thanks bdy

  • @raveena.sharma
    @raveena.sharma หลายเดือนก่อน

    What about DB, since on production MySQL or Postgre is there.

  • @rounakchourasia2030
    @rounakchourasia2030 3 ปีที่แล้ว

    That intro after that calm voice! I was on 80% volume! :(

  • @saudzubedi
    @saudzubedi 3 ปีที่แล้ว

    My site just doesn't work after adding SECURE_SSL_REDIRECT=True, this is the error: "You're accessing the development server over HTTPS, but it only supports HTTP." Some help would be nice :)

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว +1

      Are you launching your site using the runserver command? If so, that's your problem. These settings are for production servers th-cam.com/video/ZpR1W-NWnp4/w-d-xo.html

  • @xpert9001
    @xpert9001 4 ปีที่แล้ว

    Nice.

  • @alexi_space
    @alexi_space 2 ปีที่แล้ว

    after set SECURE_SSL_REDIRECT = True I always get: True page isnt redirecting properly ...

  • @enzopascucci9933
    @enzopascucci9933 4 ปีที่แล้ว

    After setting hsts setting i couldn't been able to run on localhost to changes anything

    • @TonyTeachesTech
      @TonyTeachesTech  4 ปีที่แล้ว

      You'll need to clear HSTS settings for your website from your browser really-simple-ssl.com/knowledge-base/clear-hsts-browser/

    • @enzopascucci9933
      @enzopascucci9933 4 ปีที่แล้ว

      @@TonyTeachesTech it didn't worked, but worked with the package django-sslserver

  • @henrim9348
    @henrim9348 4 ปีที่แล้ว

    Great video. Thanks a lot. What production environment do you deploy to? GCP?AWS?

  • @YadavDheeraj2000
    @YadavDheeraj2000 2 ปีที่แล้ว

    Abe Bhai kya bta rha

  • @SamSam-e5c
    @SamSam-e5c 8 หลายเดือนก่อน

    horrible sizer inducing intro. more so at 2x speed. video content is good though.

  • @BikiniGyat
    @BikiniGyat 3 ปีที่แล้ว

    Awesome! Thanks a lot!

  • @balajishetty
    @balajishetty 2 ปีที่แล้ว

    Excellent tutorial. Can you give expert lectures in our college on Django . Whatsapp Me

  • @jvsydroyrakotonomenjanahar8324
    @jvsydroyrakotonomenjanahar8324 ปีที่แล้ว

    Thank you!