Workaround ALLOWED_HOSTS for a specific route for startup probe?
I am deploying a Django app to a kubernetes cluster. I want it to have a startup probe, which will basically just be a view that checks the database connection and returns a 200 response.
I'm having trouble because kubernetes will make a request directly to the pod IP with the pods hostname. Additionally, the kubernetes config is kind of out of my hands. I'd rather solve the problem by having a looser Django view than monkeying with the infrastructure code.
Is there a way for a single route / view to ignore the hosts whitelist?
/r/django
https://redd.it/1001y06
I am deploying a Django app to a kubernetes cluster. I want it to have a startup probe, which will basically just be a view that checks the database connection and returns a 200 response.
I'm having trouble because kubernetes will make a request directly to the pod IP with the pods hostname. Additionally, the kubernetes config is kind of out of my hands. I'd rather solve the problem by having a looser Django view than monkeying with the infrastructure code.
Is there a way for a single route / view to ignore the hosts whitelist?
/r/django
https://redd.it/1001y06
reddit
Workaround ALLOWED_HOSTS for a specific route for startup probe?
I am deploying a Django app to a kubernetes cluster. I want it to have a startup probe, which will basically just be a view that checks the...
connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "rootuser" does not exist
\`I am trying to connect deploy a django backend with postgres db on digitalocean droplet. but it's giving me this error after after gunicorn and nginx setup:
`connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "rootuser" does not exist`
rootuser is my root username not the db username, my db username is dbadmin
i tried to create db user with name serveroot, it worked but started throwing other errors
`\`relation "django_site" does not exist LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...`
/r/django
https://redd.it/zyze4t
\`I am trying to connect deploy a django backend with postgres db on digitalocean droplet. but it's giving me this error after after gunicorn and nginx setup:
`connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "rootuser" does not exist`
rootuser is my root username not the db username, my db username is dbadmin
i tried to create db user with name serveroot, it worked but started throwing other errors
`\`relation "django_site" does not exist LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...`
/r/django
https://redd.it/zyze4t
reddit
connection to server on socket "/var/run/postgresql/.s.PGSQL.5432"...
\`I am trying to connect deploy a django backend with postgres db on digitalocean droplet. but it's giving me this error after after gunicorn and...
Quick wins in improving your Python codebase health
https://www.rockandnull.com/python-code-formatter/
/r/djangolearning
https://redd.it/zzsjvx
https://www.rockandnull.com/python-code-formatter/
/r/djangolearning
https://redd.it/zzsjvx
Rock and Null
Quick wins in improving your Python codebase health
There are countless ways to keep your Python as tidy and readable as possible. Here, I aim to cover the easiest yet most impactful ways to do that in your Python codebase.
Count the Comment ID over again when created in different Post
Hello!
I would like to know if it possible and if it is, how make the ID of the Comment to start to count over again when created in a different Post.
Thank you!
Models:
class Post(models.Model):
title = models.CharField(max_length=100)
content = models.TextField()
author = models.ForeignKey(User, on_delete=models.CASCADE)
def get_absolute_url(self):
return reverse('post-detail', kwargs={'pk': self.pk })
class Comment(models.Model):
post = models.ForeignKey(Post,related_name='comments', on_delete=models.CASCADE)
content = models.TextField()
author = models.ForeignKey(User, on_delete=models.CASCADE)
/r/djangolearning
https://redd.it/100irg7
Hello!
I would like to know if it possible and if it is, how make the ID of the Comment to start to count over again when created in a different Post.
Thank you!
Models:
class Post(models.Model):
title = models.CharField(max_length=100)
content = models.TextField()
author = models.ForeignKey(User, on_delete=models.CASCADE)
def get_absolute_url(self):
return reverse('post-detail', kwargs={'pk': self.pk })
class Comment(models.Model):
post = models.ForeignKey(Post,related_name='comments', on_delete=models.CASCADE)
content = models.TextField()
author = models.ForeignKey(User, on_delete=models.CASCADE)
/r/djangolearning
https://redd.it/100irg7
reddit
Count the Comment ID over again when created in different Post
Hello! I would like to know if it possible and if it is, how make the ID of the Comment to start to count over again when created in a different...
Monday Daily Thread: Project ideas!
Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, "The Big Book of Small Python Projects" which provides a list of projects and the code to make them work.
/r/Python
https://redd.it/100xk64
Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, "The Big Book of Small Python Projects" which provides a list of projects and the code to make them work.
/r/Python
https://redd.it/100xk64
reddit
Monday Daily Thread: Project ideas!
Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with...
Can you (developers who've worked professionally with Djano) share a Django project Dockerfile and docker-compose files with what you consider best practices?
It'd be helpful for beginners like myself. I'm just starting out and I read conflicting opinions online about things like whether to include a python virtual environment within Docker or not, as well as about whether to create a new non-root user within the Docker environment or to leave it as root.
I'm also not sure about how to handle environment variables. Do I include them in an .env file and add it to .dockerignore and to .gitignore or do I export them to the system's shell and forgo the .env file?
The samples I've found online describe themselves as quick start guides which leaves me unsure about points like what I've mentioned above. My project will include Django (DRF), Postgres, Celery, and Redis.
/r/django
https://redd.it/100qlts
It'd be helpful for beginners like myself. I'm just starting out and I read conflicting opinions online about things like whether to include a python virtual environment within Docker or not, as well as about whether to create a new non-root user within the Docker environment or to leave it as root.
I'm also not sure about how to handle environment variables. Do I include them in an .env file and add it to .dockerignore and to .gitignore or do I export them to the system's shell and forgo the .env file?
The samples I've found online describe themselves as quick start guides which leaves me unsure about points like what I've mentioned above. My project will include Django (DRF), Postgres, Celery, and Redis.
/r/django
https://redd.it/100qlts
reddit
Can you (developers who've worked professionally with Djano) share...
It'd be helpful for beginners like myself. I'm just starting out and I read conflicting opinions online about things like whether to include a...
9 Python Built-In Decorators That Optimize Your Code Significantly
https://medium.com/techtofreedom/9-python-built-in-decorators-that-optimize-your-code-significantly-bc3f661e9017
/r/flask
https://redd.it/100wqao
https://medium.com/techtofreedom/9-python-built-in-decorators-that-optimize-your-code-significantly-bc3f661e9017
/r/flask
https://redd.it/100wqao
Medium
9 Python Built-In Decorators That Optimize Your Code Significantly
Do more by less: leverage the power of decorators
How do I debug a exit-code failure for the specific service for my app?
I'm trying to run a Flask app through Apache and eventually host using EC2. When I run
systemctl list-units --type=service
I see that the unit for this specific app, "SITENAME.service" has failed.
When I run
sudo systemctl status SITENAME.service
I get an error saying:
Loaded: loaded (/etc/systemd/system/SITENAMEenv.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2023-01-01 21:26:25 UTC; 1min 1s ago Process: 787 ExecStart=/home/ubuntu/SITENAME/SITENAMEenv/bin/uwsgi --ini SITENAMEenv.ini (code=exited, status=1/FAILURE) Main PID: 787 (code=exited, status=1/FAILURE) Jan 01 21:26:25 ip-172-31-88-10 systemd1: SITENAME.service: Main process exited, code=exited, status=1/FAILURE Jan 01 21:26:25 ip-172-31-88-10 systemd1: SITENAME.service: Failed with result 'exit-code'.
Where can I get more information on this failure? I can't tell if this is a python issue in the actual application code, or something else.
/r/flask
https://redd.it/100xpkk
I'm trying to run a Flask app through Apache and eventually host using EC2. When I run
systemctl list-units --type=service
I see that the unit for this specific app, "SITENAME.service" has failed.
When I run
sudo systemctl status SITENAME.service
I get an error saying:
Loaded: loaded (/etc/systemd/system/SITENAMEenv.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2023-01-01 21:26:25 UTC; 1min 1s ago Process: 787 ExecStart=/home/ubuntu/SITENAME/SITENAMEenv/bin/uwsgi --ini SITENAMEenv.ini (code=exited, status=1/FAILURE) Main PID: 787 (code=exited, status=1/FAILURE) Jan 01 21:26:25 ip-172-31-88-10 systemd1: SITENAME.service: Main process exited, code=exited, status=1/FAILURE Jan 01 21:26:25 ip-172-31-88-10 systemd1: SITENAME.service: Failed with result 'exit-code'.
Where can I get more information on this failure? I can't tell if this is a python issue in the actual application code, or something else.
/r/flask
https://redd.it/100xpkk
reddit
How do I debug a exit-code failure for the specific service for my...
I'm trying to run a Flask app through Apache and eventually host using EC2. When I run systemctl list-units --type=service I see that the...
A Deep Dive into Heap and Heap Sort in Python: From Beginner to Expert
https://medium.com/techtofreedom/a-deep-dive-into-heap-and-heap-sort-in-python-from-beginner-to-expert-ae44f39a7d14
/r/flask
https://redd.it/100igyo
https://medium.com/techtofreedom/a-deep-dive-into-heap-and-heap-sort-in-python-from-beginner-to-expert-ae44f39a7d14
/r/flask
https://redd.it/100igyo
Medium
A Deep Dive into Heap and Heap Sort in Python: From Beginner to Expert
Master the heap and heap sort and take your Python skills to the next level
5 Uses of Lambda Functions in Python
https://medium.com/p/97c7c1a87244
/r/flask
https://redd.it/100n6lw
https://medium.com/p/97c7c1a87244
/r/flask
https://redd.it/100n6lw
Medium
5 Uses of Lambda Functions in Python
Use lambda functions to write your code elegantly
Nesting Blueprints with Blueprint.registerblueprint() fails
Even though the [Flask Docs](https://flask.palletsprojects.com/en/2.2.x/api/#flask.Blueprint.registerblueprint) state that a Blueprint can register further blueprints, I get the following error:
>AttributeError: 'Blueprint' object has no attribute 'register_blueprint'
Does someone know how I can achieve nesting blueprints?
Code
/r/flask
https://redd.it/100qn8a
Even though the [Flask Docs](https://flask.palletsprojects.com/en/2.2.x/api/#flask.Blueprint.registerblueprint) state that a Blueprint can register further blueprints, I get the following error:
>AttributeError: 'Blueprint' object has no attribute 'register_blueprint'
Does someone know how I can achieve nesting blueprints?
Code
/r/flask
https://redd.it/100qn8a
Django Authentication: The Basics With a Quick Tutorial
https://frontegg.com/django-authentication
/r/Python
https://redd.it/101chp8
https://frontegg.com/django-authentication
/r/Python
https://redd.it/101chp8
Frontegg
Django Authentication: The Basics With a Quick Tutorial | Frontegg
xplore Django's authentication system, including user creation, authentication, and permission setup, with a concise tutorial.
One to one relationship between user and another table.
I want to create another table that we'll call profile to put additional information about the user. I want to automatically create a profile for every user that will be created. That profile will, obviously, be attached to the user. My problem is I have almost no idea how to do that. I've heard that you could do it with signals but I have a feeling there is another, simpler way.
/r/djangolearning
https://redd.it/101od2g
I want to create another table that we'll call profile to put additional information about the user. I want to automatically create a profile for every user that will be created. That profile will, obviously, be attached to the user. My problem is I have almost no idea how to do that. I've heard that you could do it with signals but I have a feeling there is another, simpler way.
/r/djangolearning
https://redd.it/101od2g
reddit
One to one relationship between user and another table.
I want to create another table that we'll call profile to put additional information about the user. I want to automatically create a profile for...
Should you always use DRF when using Django as a backend for mobile apps?
I'm familiar building web apps with Django. I'm currently building a iOS app in Xcode (my first time building a mobile app) and since I know Django very well, I figured it makes sense to use Django as the backend for the iOS app.
I never had the need to use DRF (Django REST Framework) and never understood its uses when building web apps in Django. I just use javascript's Fetch API and ajax calls worked just fine.
After doing some research on using Django as a backend for mobile apps, it seems the general consensus is to use DRF to help build APIs for the mobile app. But I had some questions:
1. How advantageous is it to use DRF when using Django as a backend for iOS apps? Can't the iOS app just make a direct ajax call to a URL on the django server to get/post data?
2. Will using DRF cut down on development time? I'm not familiar with DRF so I will need to learn it first
/r/django
https://redd.it/101of7n
I'm familiar building web apps with Django. I'm currently building a iOS app in Xcode (my first time building a mobile app) and since I know Django very well, I figured it makes sense to use Django as the backend for the iOS app.
I never had the need to use DRF (Django REST Framework) and never understood its uses when building web apps in Django. I just use javascript's Fetch API and ajax calls worked just fine.
After doing some research on using Django as a backend for mobile apps, it seems the general consensus is to use DRF to help build APIs for the mobile app. But I had some questions:
1. How advantageous is it to use DRF when using Django as a backend for iOS apps? Can't the iOS app just make a direct ajax call to a URL on the django server to get/post data?
2. Will using DRF cut down on development time? I'm not familiar with DRF so I will need to learn it first
/r/django
https://redd.it/101of7n
reddit
Should you always use DRF when using Django as a backend for...
I'm familiar building web apps with Django. I'm currently building a iOS app in Xcode (my first time building a mobile app) and since I know...
Tuesday Daily Thread: Advanced questions
Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.
If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.
This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.
/r/Python
https://redd.it/101s3ce
Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.
If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.
This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.
/r/Python
https://redd.it/101s3ce
Discord
Join the Python Discord Server!
We're a large community focused around the Python programming language. We believe that anyone can learn to code. | 412982 members
2,000 free sign ups available for the "Automate the Boring Stuff with Python" online course. (Jan 2023)
If you want to learn to code, I've released 2,000 free sign ups for my course following my Automate the Boring Stuff with Python book (each has 1,000 sign ups, use the other one if one is sold out):
https://udemy.com/course/automate/?couponCode=JAN2023FREE
https://udemy.com/course/automate/?couponCode=JAN2023FREE2
Udemy has changed their promo code and severely limited the number of sign ups I can provide each month, so only sign up if you are reasonably certain you can eventually finish the course. The first 15 of the course's 50 videos are free on YouTube if you want to preview them.
YOU CAN ALSO WATCH THE VIDEOS WITHOUT SIGNING UP FOR THE COURSE. All of the videos on the course webpage have "preview" turned on. Scroll down to find and click "Expand All Sections" and then click the preview link. You won't have access to the forums and other materials, but you can watch the videos.
NOTE: Be sure to BUY the course for $0, and not sign up for Udemy's subscription plan. The subscription plan is free for the first seven days and then they charge you. It's selected by default. If you are on a laptop and can't click the BUY checkbox, try shrinking the browser window. Some have reported
/r/Python
https://redd.it/101p7xy
If you want to learn to code, I've released 2,000 free sign ups for my course following my Automate the Boring Stuff with Python book (each has 1,000 sign ups, use the other one if one is sold out):
https://udemy.com/course/automate/?couponCode=JAN2023FREE
https://udemy.com/course/automate/?couponCode=JAN2023FREE2
Udemy has changed their promo code and severely limited the number of sign ups I can provide each month, so only sign up if you are reasonably certain you can eventually finish the course. The first 15 of the course's 50 videos are free on YouTube if you want to preview them.
YOU CAN ALSO WATCH THE VIDEOS WITHOUT SIGNING UP FOR THE COURSE. All of the videos on the course webpage have "preview" turned on. Scroll down to find and click "Expand All Sections" and then click the preview link. You won't have access to the forums and other materials, but you can watch the videos.
NOTE: Be sure to BUY the course for $0, and not sign up for Udemy's subscription plan. The subscription plan is free for the first seven days and then they charge you. It's selected by default. If you are on a laptop and can't click the BUY checkbox, try shrinking the browser window. Some have reported
/r/Python
https://redd.it/101p7xy
Udemy
Automate the Boring Stuff with Python Programming Course
A practical programming course for office workers, academics, and administrators who want to improve their productivity.
I am still making a video editor in Python. I am still crazy. Please help me(really).
# IF YOU ARE INTERESTED IN WORKING ON THIS PROJECT, ADD ME ON DISCORD Relt#4423
So it has been some time. The project has evolved countless of times, but i finally came up with a road forward.
# What? What editor?
I am making a video editor in Python and its called CZEditor (reason for name is a story LITERALLY TOO LONG TO EXPLAIN WITHOUT CONTEXT. it involves inside jokes, niche communities, and kids being in these niche communities, being cringy as ever). It will be free, open source, yadda yadda, you've heard this before.
Luckily, i got some stuff you have NOT heard before.Mainly:
CZEditor uses "keyframes" instead of clips for sequencing media. Clips are too clunky and take up space. While they might look nice, they are a pain to use. We do not care if a video exists at every frame from 0 to 3519, we care that a video starts at 0, and ends at 3519.
CZEditor ACTUALLY will target content creators. With the stuff that content creators really want, rather than the same corporate bullcrap that has been said by everyone else. CZEditor will support many features and make them easily accessible and accessibly easy. The features include:
1. Stylized/Realistic
/r/Python
https://redd.it/101hu89
# IF YOU ARE INTERESTED IN WORKING ON THIS PROJECT, ADD ME ON DISCORD Relt#4423
So it has been some time. The project has evolved countless of times, but i finally came up with a road forward.
# What? What editor?
I am making a video editor in Python and its called CZEditor (reason for name is a story LITERALLY TOO LONG TO EXPLAIN WITHOUT CONTEXT. it involves inside jokes, niche communities, and kids being in these niche communities, being cringy as ever). It will be free, open source, yadda yadda, you've heard this before.
Luckily, i got some stuff you have NOT heard before.Mainly:
CZEditor uses "keyframes" instead of clips for sequencing media. Clips are too clunky and take up space. While they might look nice, they are a pain to use. We do not care if a video exists at every frame from 0 to 3519, we care that a video starts at 0, and ends at 3519.
CZEditor ACTUALLY will target content creators. With the stuff that content creators really want, rather than the same corporate bullcrap that has been said by everyone else. CZEditor will support many features and make them easily accessible and accessibly easy. The features include:
1. Stylized/Realistic
/r/Python
https://redd.it/101hu89
reddit
I am still making a video editor in Python. I am still crazy....
Posted in r/Python by u/mcp1112 • 26 points and 5 comments
Perf engineering with Python 3.12
https://www.petermcconnell.com/posts/perf_eng_with_py12/
/r/Python
https://redd.it/1019vay
https://www.petermcconnell.com/posts/perf_eng_with_py12/
/r/Python
https://redd.it/1019vay
Peter McConnell :: Ponderings from a Linux Systems engineer
Perf engineering with Python 3.12
Since Python 3.12, the interpreter can run in a special mode that allows Python functions to appear in the output of the perf profiler. When this mode is enabled, the interpreter will interpose a small piece of code compiled on the fly before the execution…
D Simple Questions Thread
Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here instead!
Thread will stay alive until next one so keep posting after the date in the title.
Thanks to everyone for answering questions in the previous thread!
/r/MachineLearning
https://redd.it/100mjlp
Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here instead!
Thread will stay alive until next one so keep posting after the date in the title.
Thanks to everyone for answering questions in the previous thread!
/r/MachineLearning
https://redd.it/100mjlp
reddit
[D] Simple Questions Thread
Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here...
D life advice to relatively late bloomer ML theory researcher.
Hi ML Community out there, I'm 27 M. I'm a machine learning incoming PhD student based out of Germany. I have been trying to get into a PhD program since last 4 years (since 2018). When I gave up and got into a masters instead with 3yoe. Now I'm about to complete my masters thesis and start a PhD.
I already have mixed feelings about my PhD journey now. I have gotten a really good opportunity to do ML theory at University of Saarlandes in Germany. Initially, when I had started, I was really driven to understand maths and underlying concepts of ML. However, more recently I have become more confused about the value of theoretical research and it's "real" impact. Of what skills I would have in my career later that would make me desirable to employers (considering I may not get tenured in academia).
Is it more advisable in long run to stay and get your PhD or just leave and join some ML role in industry that takes Masters guys and get some real world experience on how to use ML to generate business value ?
There is this added fomo of being 27 and just
/r/MachineLearning
https://redd.it/101qbfl
Hi ML Community out there, I'm 27 M. I'm a machine learning incoming PhD student based out of Germany. I have been trying to get into a PhD program since last 4 years (since 2018). When I gave up and got into a masters instead with 3yoe. Now I'm about to complete my masters thesis and start a PhD.
I already have mixed feelings about my PhD journey now. I have gotten a really good opportunity to do ML theory at University of Saarlandes in Germany. Initially, when I had started, I was really driven to understand maths and underlying concepts of ML. However, more recently I have become more confused about the value of theoretical research and it's "real" impact. Of what skills I would have in my career later that would make me desirable to employers (considering I may not get tenured in academia).
Is it more advisable in long run to stay and get your PhD or just leave and join some ML role in industry that takes Masters guys and get some real world experience on how to use ML to generate business value ?
There is this added fomo of being 27 and just
/r/MachineLearning
https://redd.it/101qbfl
reddit
[D] life advice to relatively late bloomer ML theory researcher.
Hi ML Community out there, I'm 27 M. I'm a machine learning incoming PhD student based out of Germany. I have been trying to get into a PhD...