Sunday Daily Thread: What's everyone working on this week?
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/12nnqs3
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/12nnqs3
Reddit
r/Python on Reddit: Sunday Daily Thread: What's everyone working on this week?
Posted by u/Im__Joseph - 1 vote and 2 comments
Pip 23.1 Released - Massive improvement to backtracking
Pip 23.1 was just released a few hours ago. You can check the release announcements here and the change log here.
I would like to highlight the significant improvement in backtracking that is part of the requirement resolver process in Pip. This process involves Pip finding a set of packages that meet your requirements and whose requirements themselves don't conflict.
For example, let's say you require packages A and B. First, the latest versions of A and B are downloaded and Pip checks their requirements, let's say Pip finds that A depends on C==2 and B depends on C==1. These two latest versions of A and B are not compatible, so Pip will try to find an older version of A and/or B where they have compatible dependencies. C in this case is called a transitive dependency because it's a dependency of a dependency.
Prior to Pip 20.3, the default process for Pip would allow conflicting requirements to install if they were transitive dependencies where the last one specified would be the one installed. This was not satisfactory for a lot of projects that had larger set of requirements because it meant package versions that did not work together could be installed
/r/Python
https://redd.it/12n5lai
Pip 23.1 was just released a few hours ago. You can check the release announcements here and the change log here.
I would like to highlight the significant improvement in backtracking that is part of the requirement resolver process in Pip. This process involves Pip finding a set of packages that meet your requirements and whose requirements themselves don't conflict.
For example, let's say you require packages A and B. First, the latest versions of A and B are downloaded and Pip checks their requirements, let's say Pip finds that A depends on C==2 and B depends on C==1. These two latest versions of A and B are not compatible, so Pip will try to find an older version of A and/or B where they have compatible dependencies. C in this case is called a transitive dependency because it's a dependency of a dependency.
Prior to Pip 20.3, the default process for Pip would allow conflicting requirements to install if they were transitive dependencies where the last one specified would be the one installed. This was not satisfactory for a lot of projects that had larger set of requirements because it meant package versions that did not work together could be installed
/r/Python
https://redd.it/12n5lai
Discussions on Python.org
Announcement: pip 23.1 release!
On behalf of the PyPA, I am pleased to announce that the pip team has just released pip 23.1. This is the second release of pip for the year 2023. You can read more about our versioning, deprecation policy, and release process here. Highlights Further…
what is th best practices to implement Stripe payments in a flask app
/r/flask
https://redd.it/12mszdr
/r/flask
https://redd.it/12mszdr
Reddit
r/flask on Reddit: what is th best practices to implement Stripe payments in a flask app
Posted by u/Proud_Pianist_8715 - 15 votes and 1 comment
Google announces the list of 574 Python packages in its new "Assured Open Source Software" service
https://cloud.google.com/assured-open-source-software/docs/supported-packages#python
/r/Python
https://redd.it/12nxsop
https://cloud.google.com/assured-open-source-software/docs/supported-packages#python
/r/Python
https://redd.it/12nxsop
Google Cloud
List of supported Java and Python packages for the Assured Open Source Software free tier | Google Cloud
problem with psycopg
so i am working on some django from a book and trying to do a project. it was working good but when i had to use docker-compose down and docker-compose up -build -d command again so changes would commit now it has some errors.
​
it says psycopg is not intalled but it was working good and i made sure it is installed so i dont understand what can be the problem here. maybe the error is about database, which i changed in the settings but why id this error occuring now?
here is my database settings
https://preview.redd.it/wc365183hvta1.png?width=680&format=png&auto=webp&v=enabled&s=a3d83cc453f13da03d3e452f7da9696f5e587e21
maybe someone had a similar experience and can help me, i would appreciate.
by the way when i run docker-compose up -d --build command it gives me this error
​
https://preview.redd.it/39lvncvthvta1.png?width=1219&format=png&auto=webp&v=enabled&s=74807ec07c2ea82a5a238293a4f10a840c127568
​
thanks for helping
/r/djangolearning
https://redd.it/12m1vq8
so i am working on some django from a book and trying to do a project. it was working good but when i had to use docker-compose down and docker-compose up -build -d command again so changes would commit now it has some errors.
​
it says psycopg is not intalled but it was working good and i made sure it is installed so i dont understand what can be the problem here. maybe the error is about database, which i changed in the settings but why id this error occuring now?
here is my database settings
https://preview.redd.it/wc365183hvta1.png?width=680&format=png&auto=webp&v=enabled&s=a3d83cc453f13da03d3e452f7da9696f5e587e21
maybe someone had a similar experience and can help me, i would appreciate.
by the way when i run docker-compose up -d --build command it gives me this error
​
https://preview.redd.it/39lvncvthvta1.png?width=1219&format=png&auto=webp&v=enabled&s=74807ec07c2ea82a5a238293a4f10a840c127568
​
thanks for helping
/r/djangolearning
https://redd.it/12m1vq8
Flask changing src and PATHS
I've used Flask(__name__, template_folder="mijn_project/templates") for some reason all my PATHS don't work. app.py is stored in / and my project is stored in /mijn_project/. none of my templates can find the images location or bootstrap, css, js etc. but when I run my HTML template it show the CSS, images, lib without errors. what's going wrong? PS. the structure is not my idea, my teacher demands this. and I tried every PATH ../static, /static/, ../../static but nothing works. and its a local test
/r/flask
https://redd.it/12n3w4m
I've used Flask(__name__, template_folder="mijn_project/templates") for some reason all my PATHS don't work. app.py is stored in / and my project is stored in /mijn_project/. none of my templates can find the images location or bootstrap, css, js etc. but when I run my HTML template it show the CSS, images, lib without errors. what's going wrong? PS. the structure is not my idea, my teacher demands this. and I tried every PATH ../static, /static/, ../../static but nothing works. and its a local test
/r/flask
https://redd.it/12n3w4m
How do I get current values from the database in a dropdown form
Hi,
TL:DR: I want to pass the values of a database model into the options in a dropdown menu.
I am building a application with different card types. Each card type has a different color. To keep track of the users preferences I created a database model where for each user I keep track of their color (and also Icon and label).
Basically the user can say:- legend_1 is yellow, I call it "ambition" and I want a thumb up icon.- Legend_2 is blue etc etc
here is the model:
models.py
# Create your models here.
class CardPreferences(models.Model):
<!--Some other stuff not related to question -->
legendlabel1 = models.CharField(blank=False, maxlength=40, default='legend1')
legendhexcolor1 = models.CharField(blank=False, maxlength=6, default='78E7BF')
legendicon1 = models.CharField(blank=False, maxlength=40, default='thumbs-up-solid.svg')
legendlabel2 = models.CharField(blank=False, maxlength=40, default='legend2')
legendhexcolor2 = models.CharField(blank=False, maxlength=6, default='51c1ff')
legendicon2 = models.CharField(blank=False, maxlength=40, default='thumbs-up-solid.svg')
/r/djangolearning
https://redd.it/12o8jow
Hi,
TL:DR: I want to pass the values of a database model into the options in a dropdown menu.
I am building a application with different card types. Each card type has a different color. To keep track of the users preferences I created a database model where for each user I keep track of their color (and also Icon and label).
Basically the user can say:- legend_1 is yellow, I call it "ambition" and I want a thumb up icon.- Legend_2 is blue etc etc
here is the model:
models.py
# Create your models here.
class CardPreferences(models.Model):
<!--Some other stuff not related to question -->
legendlabel1 = models.CharField(blank=False, maxlength=40, default='legend1')
legendhexcolor1 = models.CharField(blank=False, maxlength=6, default='78E7BF')
legendicon1 = models.CharField(blank=False, maxlength=40, default='thumbs-up-solid.svg')
legendlabel2 = models.CharField(blank=False, maxlength=40, default='legend2')
legendhexcolor2 = models.CharField(blank=False, maxlength=6, default='51c1ff')
legendicon2 = models.CharField(blank=False, maxlength=40, default='thumbs-up-solid.svg')
/r/djangolearning
https://redd.it/12o8jow
Reddit
r/djangolearning on Reddit: How do I get current values from the database in a dropdown form
Posted by u/Human-Possession135 - 1 vote and no comments
Database on Local Machine - Still Pulling Heroku Postgres Database
Recently my main computer rig died and I moved onto a new computer.
I am trying to get my local development mode back up and running but am running into trouble, amateur programmer at best, doing this as a fun hobby.
Anyways, in the process of trying to get the website back up and running, I forgot to set my local environment variable of "DEVELOPMENT_MODE" to "True" and ran "python manage.py collectstatic" and "python manage.py runserver" and my local machine points to the postgres database that I have on with Heroku.
I thought this should be a pretty easy fix and change "DEVELOPMENT_MODE" to "True", but the local database is still referencing the postgres database. Any ideas on how to get django to point the the local sqlite3 database?
Code in reference, settings.py:
if DEVELOPMENTMODE is True:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASEDIR, "db.sqlite3"),
/r/djangolearning
https://redd.it/12kb0gg
Recently my main computer rig died and I moved onto a new computer.
I am trying to get my local development mode back up and running but am running into trouble, amateur programmer at best, doing this as a fun hobby.
Anyways, in the process of trying to get the website back up and running, I forgot to set my local environment variable of "DEVELOPMENT_MODE" to "True" and ran "python manage.py collectstatic" and "python manage.py runserver" and my local machine points to the postgres database that I have on with Heroku.
I thought this should be a pretty easy fix and change "DEVELOPMENT_MODE" to "True", but the local database is still referencing the postgres database. Any ideas on how to get django to point the the local sqlite3 database?
Code in reference, settings.py:
if DEVELOPMENTMODE is True:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASEDIR, "db.sqlite3"),
/r/djangolearning
https://redd.it/12kb0gg
Flask Sessions not working with blueprints
I am using flask sessions, i recently changed my code structure to be blueprint based, it has broken sessions. Whevenver i try to access sessions inside a blueprint, it is giving me
This is the code from the main application:
Can anybody tell me what is causing this?
/r/flask
https://redd.it/12oexr1
I am using flask sessions, i recently changed my code structure to be blueprint based, it has broken sessions. Whevenver i try to access sessions inside a blueprint, it is giving me
RuntimeError: The session is unavailable because no secret key was set. Set the secret_key on the application to something unique and secret.
This is the code from the main application:
app = Flask(__name__)
app.register_blueprint(authModule, url_prefix='/auth', cookie_path='/')
app.secret_key = environ.get('secret_key')
app.config['SESSION_COOKIE_PATH'] = '/'
Can anybody tell me what is causing this?
/r/flask
https://redd.it/12oexr1
Reddit
r/flask on Reddit: Flask Sessions not working with blueprints
Posted by u/ivanrj7j - No votes and 1 comment
I want to display a stock market ticker on a HTML page.
Here's the Github link to my code : https://github.com/SachinPrab/microinvestment/blob/81d2e32fcd48d58704ad2668d05164d2f2ad33c0/app.py
I want to display the output of the above code in this HTML page (Github link) : https://github.com/SachinPrab/microinvestment/blob/81d2e32fcd48d58704ad2668d05164d2f2ad33c0/ticker.html
The above page should be opened when the user clicks on the button at the bottom of this page: https://github.com/SachinPrab/microinvestment/blob/81d2e32fcd48d58704ad2668d05164d2f2ad33c0/stocks.html
Can someone please point out the error in the Flask application that I have created? I am able to view only the heading which reads "Stock Market Ticker" upon running the code in PyCharm editor but I'm not able to view the ticker. Thanks in advance.
/r/flask
https://redd.it/12kqncf
Here's the Github link to my code : https://github.com/SachinPrab/microinvestment/blob/81d2e32fcd48d58704ad2668d05164d2f2ad33c0/app.py
I want to display the output of the above code in this HTML page (Github link) : https://github.com/SachinPrab/microinvestment/blob/81d2e32fcd48d58704ad2668d05164d2f2ad33c0/ticker.html
The above page should be opened when the user clicks on the button at the bottom of this page: https://github.com/SachinPrab/microinvestment/blob/81d2e32fcd48d58704ad2668d05164d2f2ad33c0/stocks.html
Can someone please point out the error in the Flask application that I have created? I am able to view only the heading which reads "Stock Market Ticker" upon running the code in PyCharm editor but I'm not able to view the ticker. Thanks in advance.
/r/flask
https://redd.it/12kqncf
GitHub
microinvestment/app.py at 81d2e32fcd48d58704ad2668d05164d2f2ad33c0 · SachinPrab/microinvestment
Website to help users manage their money and make investments on stocks,bonds,mutual funds,etc. - microinvestment/app.py at 81d2e32fcd48d58704ad2668d05164d2f2ad33c0 · SachinPrab/microinvestment
This media is not supported in your browser
VIEW IN TELEGRAM
[P] Chat With Any GitHub Repo - Code Understanding with @LangChainAI & @activeloopai
https://redd.it/12oh07a
@pythondaily
https://redd.it/12oh07a
@pythondaily
Announcing Polyfactory - a powerful mock data generator for dataclasses, Pydantic and more
Hello r/Python!
Today I'd like to formally announce the first stable release of Polyfactory \- a powerful mock data generator built around type hints and support for some of the most popular data modelling solutions such as Pydantic models, dataclasses, typed-dicts and more!
## Once upon a time there was pydantic-factories
Some of you may already know this project as "pydantic-factories"; A name under which it garnered a decent amount of popularity since it's inception. Pydantic-factories and Polyfactory have a lot in common. In fact, Polyfactory is pydantic-factories 2.0. That's why we also decided to continue the version number and release the first version of Polyfactory as
But why the name change?
A main motivator for the 2.0 release was that we wanted to support more than just Pydantic models, something which also required a change to the pydantic-fatories' core architecture. As this library would no longer be directly tied to Pydantic, polyfactory was chosen as a new name to reflect its capabilities; It can generate mock data for dataclasses, typed-dicts, Pydantic, odmantic, and beanie ODM models out of the box.
Polyfactory is all that pydantic-factories was and more!
## So what can it do?
Let's look at a very basic example using dataclasses:
/r/Python
https://redd.it/12o69ld
Hello r/Python!
Today I'd like to formally announce the first stable release of Polyfactory \- a powerful mock data generator built around type hints and support for some of the most popular data modelling solutions such as Pydantic models, dataclasses, typed-dicts and more!
## Once upon a time there was pydantic-factories
Some of you may already know this project as "pydantic-factories"; A name under which it garnered a decent amount of popularity since it's inception. Pydantic-factories and Polyfactory have a lot in common. In fact, Polyfactory is pydantic-factories 2.0. That's why we also decided to continue the version number and release the first version of Polyfactory as
2.0.0.But why the name change?
A main motivator for the 2.0 release was that we wanted to support more than just Pydantic models, something which also required a change to the pydantic-fatories' core architecture. As this library would no longer be directly tied to Pydantic, polyfactory was chosen as a new name to reflect its capabilities; It can generate mock data for dataclasses, typed-dicts, Pydantic, odmantic, and beanie ODM models out of the box.
Polyfactory is all that pydantic-factories was and more!
## So what can it do?
Let's look at a very basic example using dataclasses:
/r/Python
https://redd.it/12o69ld
Reddit
r/Python on Reddit: Announcing Polyfactory - a powerful mock data generator for dataclasses, Pydantic and more
Posted by u/provinzkraut - 48 votes and 11 comments
Fluke v0.3.0 has been released!
Fluke is a Python package that can be used to easily read files that do not reside within the local file system, e.g. on a remote server or on the cloud, as well as transfer them between said locations.
Most changes introduced in version 0.3.0 are focused on reading files, adding functionality regarding reading large files in chunks, partially reading files, and more.
Github: https://github.com/manoss96/fluke
Docs: https://fluke.rtfd.io/
Any feedback is welcome!
/r/Python
https://redd.it/12oef63
Fluke is a Python package that can be used to easily read files that do not reside within the local file system, e.g. on a remote server or on the cloud, as well as transfer them between said locations.
Most changes introduced in version 0.3.0 are focused on reading files, adding functionality regarding reading large files in chunks, partially reading files, and more.
Github: https://github.com/manoss96/fluke
Docs: https://fluke.rtfd.io/
Any feedback is welcome!
/r/Python
https://redd.it/12oef63
GitHub
GitHub - manoss96/fluke: Cloud-agnostic Python API
Cloud-agnostic Python API . Contribute to manoss96/fluke development by creating an account on GitHub.
Trying to implement symmetric encryption in a secure way
Hi friends. Need some guidance here.
I'm creating a Django app which encrypts some fields before storing in Db (using custom fields). I want the server to have little to no knowledge of the contents (not able to get to zero knowledge yet).
So here's what I'm trying to do:
When the user signs in, use the password to generate a key using PBKDF2
Put it in session storage
Use this key to encrypt/decrypt (using AES) any sensitive data they enter
Once they logout, session gets cleared, key gets destroyed, server has no way to decrypt the data
# Q1
Is this a good approach? Or are their better alternatives or packages which already implement this sort of thing?
# Q2
I'm currently using PyCryptodome to generate PBKDF2 key, but it returns byte object which is not JSON serializable, and hence not able to store it as session variable. How do I go about doing that?
/r/django
https://redd.it/12ohklt
Hi friends. Need some guidance here.
I'm creating a Django app which encrypts some fields before storing in Db (using custom fields). I want the server to have little to no knowledge of the contents (not able to get to zero knowledge yet).
So here's what I'm trying to do:
When the user signs in, use the password to generate a key using PBKDF2
Put it in session storage
Use this key to encrypt/decrypt (using AES) any sensitive data they enter
Once they logout, session gets cleared, key gets destroyed, server has no way to decrypt the data
# Q1
Is this a good approach? Or are their better alternatives or packages which already implement this sort of thing?
# Q2
I'm currently using PyCryptodome to generate PBKDF2 key, but it returns byte object which is not JSON serializable, and hence not able to store it as session variable. How do I go about doing that?
/r/django
https://redd.it/12ohklt
Reddit
r/django on Reddit: Trying to implement symmetric encryption in a secure way
Posted by u/magestooge - 16 votes and 15 comments
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/12ou5no
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/12ou5no
Reddit
r/Python on Reddit: Monday Daily Thread: Project ideas!
Posted by u/Im__Joseph - 18 votes and 5 comments
Using first name and last name as username
Building a Django site for my work. I want to make it simple and automatically assign a username based on the users first letter of their first name and then their whole last name.
I’m using Django Forms and following along with a tutorial to set forms up.
Can this still be achieved and how would it be achieved?
/r/djangolearning
https://redd.it/12onqoy
Building a Django site for my work. I want to make it simple and automatically assign a username based on the users first letter of their first name and then their whole last name.
I’m using Django Forms and following along with a tutorial to set forms up.
Can this still be achieved and how would it be achieved?
/r/djangolearning
https://redd.it/12onqoy
Reddit
r/djangolearning on Reddit: Using first name and last name as username
Posted by u/HeadlineINeed - 2 votes and 12 comments
How to implement Push notification in django.
Hello guys I build a django and react native mobile app. Now I want to send push notification from django to my React native app. How should I do that and packages to used for sending push notification. There are very less resources for django push notification. If you guys implemented than let me know the process. Any kind of help would be appreciated. 🙏
/r/django
https://redd.it/12o9lm3
Hello guys I build a django and react native mobile app. Now I want to send push notification from django to my React native app. How should I do that and packages to used for sending push notification. There are very less resources for django push notification. If you guys implemented than let me know the process. Any kind of help would be appreciated. 🙏
/r/django
https://redd.it/12o9lm3
Reddit
r/django on Reddit: How to implement Push notification in django.
Posted by u/Nehatkhan786 - 25 votes and 10 comments
ConnectionAbortedError when the page's loading is canceled by the user (Python3 Quart)
The error
/r/flask
https://redd.it/12oyomm
The error
ConnectionAbortedError is thrown if the page's loading is canceled when using a Python3 Quart webserver. Using @app.errorhandler(ConnectionAbortedError) with an appropriate function is completely ignored. How do I handle this error?/r/flask
https://redd.it/12oyomm
Reddit
r/flask on Reddit: ConnectionAbortedError when the page's loading is canceled by the user (Python3 Quart)
Posted by u/xpoppyseed - 3 votes and 8 comments