Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
For some reason everything seems to be working but the email is not being sent.

For some reason everything seems to be working but the email is not being sent.

Could someone help me figure out what is causing the bug?

I just want to add I am not getting an error anywhere. The email is just not being sent.

To run the email I am using EMAIL_USERNAME which is equal to gmail username and EMAIL_PASSWORD is equal to the app password.

I get to the route in /registration_verification_code/<username_db> by redirecting after registering and logging in assuming registration_confirmation_email is False.

(Here is where the error occurs.)

email_login_confirmation/routes.py https://pastebin.com/baHPsdN9

registration_verification_code.html (uses bootstrap) https://pastebin.com/5QH3ab39

renderform.html (uses bootstrap) *https://pastebin.com/U4uruBAV*

*models.py*
*https://pastebin.com/Qj4vyVgt*

*config.py*

*https://pastebin.com/7RDUBEBQ*

\_\_init\_\_.py
https://pastebin.com/P4xN1G4w

app.py (code below for app.py)

from app import createapp
app = create
app()

To run the code in powershell in vsc for windows I type after starting the env.

$env:FLASKDEBUG='True
$env:FLASK
ENV='dev'
flask run

 I can add requirements.txt if anyone wants.

Thank you for the help.



I may have solved this I will update if I have.

/r/flask
https://redd.it/1ds5rbo
Confused about how to structure my RESTful APIs

I am building an Inventory Management System with Django Rest Framework. Two of the models I have are: Inventory and Product.

The tutorials/courses that I watched only show basic views/viewsets: list and detail. But now working on the frontend Dashboard page, I realized I have to show:

Count of:
Total Products
Total stock value
Low stock items
Table of:
Top 5 products by quantity
Top 5 products by value

These are not the typical views that I've worked with. My questions:

1. Do I create separate views (or viewset actions) for these specific queries
2. On the frontend make multiple API calls to these routes, i.e.,
/api/inventory/low_stock_items_count
`/api/inventory/total_stock_value_count`
/api/inventory/total_products_count etc. etc.

What is the actual approach to doing this? Because when I was writing regular Django with templates, I had one context dictionary for the dashboard view that contains all my data.

/r/django
https://redd.it/1dtfmv8
Deploying flask application on IONOS Server


Hello everyone,

I'm having trouble deploying my Flask application on my IONOS web hosting server (SFTP) and hoping someone here has experience with this and can help me out.

This is the first time I've put something I've built online, so please don't assume I have much background knowledge.

Problem Summary:
I have a Flask web application that runs perfectly on my local computer using Visual Studio Code and the command `python app.py`. I have uploaded the entire project structure to my IONOS server, but I am encountering various issues with the configuration and execution of the application.

Current Configuration:
- Server: IONOS Web Hosting
- Project Directory: `/ProjectFile`
- Virtual Environment: `venv` in the project directory
- Uploaded Files:
- `app.py` (main Flask application file)
- `requirements.txt` (list of dependencies)
- `dispatch.fcgi` (FastCGI script)
- `.htaccess` (Apache configuration file)
- `wsgi.py` (WSGI entry point)

Error Messages:
When accessing the domain, I get a `500 Internal Server Error` message. Here are the steps I have taken so far:

1. Set up the virtual environment and install dependencies:
```bash
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```

2. Created `dispatch.fcgi`:
```python
#!/usr/bin/env

/r/flask
https://redd.it/1dtjvr0
can anybody tell me whats the diff? indentation?

/r/django
https://redd.it/1dtpxtm
VS Code setup for Django/Jinja2 templates??

Hey guys, seeking some tips on how to property setup auto completion/intellisense and formatting in VS Code. I tried q couple of extensions and changed a few settings, but it never get in a good state IMO, either formatting sucks or I don't have the proper auto completes...

What is your setup, any insight you be great 🔥

/r/django
https://redd.it/1dtrc58
Best tool to minimize html?

I am using django-webpack-loader to bundle and minimize my css and js. What should I use to minimize my html?

/r/django
https://redd.it/1dtoh6l
Need help with s3 and django-storages

Hello everyone, this is my first time working with any cloud storage. I am following this tutorial here from Michael Herman, and there were a few discrepancies right from the beginning.

First, when I tried running the collectstatic command, I got this error:

botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied

I looked up a bit, and apparently you have to set AWS_DEFAULT_ACL = None and doing that fixed it.

So now my static files were being uploaded to the s3 bucket when I ran collectstatic.

But when I visited the webpages, the static images and stylesheets were not getting fetched as expected.

I tried many different things at this point, but none of them worked. I typed the s3 object url in the browser and this was the error I was getting:

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>419CX01JK1CAKYCS</RequestId>
<HostId>
rB7y8qLl5a5G0I1LVx2lexUbJpcvnrdKIMZ3AVq69C81B3j4BRWZwLq5THNLINwSv6q5HFSAednN1yq2tRCQ6THuxEn+S/Kj
</HostId>
</Error>

Now the next logical thing I did was to make all the bucket objects as public. The tutorial doesn't do this and I'm not sure if its a bad thing or not? Anyone

/r/django
https://redd.it/1dtnhtd
PyCon US 2024 | All recorded content now available!

All sessions on the Main Stage at PyCon US 2024 are now posted for your viewing pleasure as well as:

* Our amazing Keynote speakers [u/kjaymiller](https://fosstodon.org/@kjaymiller@mastodon.social), Kate Chapman, [@brainwane](https://fosstodon.org/@brainwane@social.coop), and [@simon](https://fosstodon.org/@simon@simonwillison.net) ️
* Lightning talks
* The Python Steering Council
* Tutorials
* Sponsor Presentations

Check it out on the official PyCon US YouTube channel:

* [https://www.youtube.com/@PyConUS](https://www.youtube.com/@PyConUS)
* Full Playlist: [https://www.youtube.com/watch?v=OH3C5a2uAWA&list=PL2Uw4\_HvXqvYhjub9bw4uDAmNtprgAvlJ](https://www.youtube.com/watch?v=OH3C5a2uAWA&list=PL2Uw4_HvXqvYhjub9bw4uDAmNtprgAvlJ)

/r/Python
https://redd.it/1dtxqph
ORM is hard

First project ever. Spent a couple of weeks finalising the model. Getting complex queries right is such a pain. Keep getting lost in the syntax. Joins don't work. Column names are strings sometimes, sometimes not. The syntax is maddening. I get things right in my mind though.

I'm pulling data out of querysets into lists so that I can use normal string methods instead of annotating querysets and getting stuck. How much of a performance penalty is that in the real world?

/r/djangolearning
https://redd.it/1dtw2p2
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/1ds3fbp
How can I enable connection pooling in Django REST Framework with PostgreSQL without using PgBouncer?

I do not want to use PgBouncer because there are no proper articles on how to enable it. Could you please share articles on how to do this without using PgBouncer

/r/django
https://redd.it/1du7h8k
Looking for Internship

Hello. I am a 2nd year student in Computer Science, and self learned in Django with proficiency in Django Authentication, CRUD, API Integration and Solid grasp on database management. I am looking for remote internship that will help me more to learn about backend web development. I can't find good internships to gain more skills. Everybody is mostly demanding for a last year student, also applied in Internshala but couldn't get any internship offer. kindly recommend me remote internships that will help me gain skills. And also recommend me if internship is helpful or not, and other tips to utilize my summers.

/r/djangolearning
https://redd.it/1dtlnfj
Have 2 different Add User Pages in Django Admin

Is it possible to have 2 Different Add User Pages in Django Admin and have that info save to the same Custom User Model? What we want is to have another Add User Page that has different fields that the default Add User. so far, I managed to override the template and add a "Add Personnel Button", but it has not functionality as of yet.

Example we have 2 Users: User and Personnel
User have username, passwords + address and a File Upload Fields(required field).
Personnel only have the username, passwords + address fields

The default Add Button directs to the Add User page of User.
I want the Add Personnel Button to redirect me to an Add User Page to add Personnel Users. How can I do this?


https://preview.redd.it/hje0fm5kr9ad1.png?width=1856&format=png&auto=webp&s=49be6eed73c35d68e4884d61dfa116433a9a86f8



/r/django
https://redd.it/1du9xd7
What change in Python 3.12 is so hard for deep learning frameworks to support?

I noticed that both Pytorch and Tensorflow don't support Python 3.12 yet. It's obviously not a big deal, but I'm curious. What changed in 3.12 that is so difficult to support? Should we expect this sort of n-1 issue at every point release?

/r/Python
https://redd.it/1du7myj
How do you male sure you have a robust architecture for your App ?

Hey guys,

I managed to deploy an app on an EC2 instance with Cron jobs and a webhook. I know that the architecture is poor, this is why I am asking for pieces of advice to help me on deploying a solid architecture on AWS for an app that would need lot of syncs with third party APIs.

Thanks in advance for the help :)

/r/djangolearning
https://redd.it/1ducrkw
I made a game it's a rouge like inspired by balatro

I made a game it's a rouge like inspired by balatro my target audience is balatro/rouge like gamers it is the first of its developers so fist Comparison or another edition. https://github.com/FurtiveThomas/FurtiveCards-v0.3.2 its the first public release.

/r/Python
https://redd.it/1duf1g2
Difficult to decide on node vs django

Can someone please help me choosing one framework between these two?
Requirement:
- Must be highly scalable
- API should be fast working
- Should not take time for development

And please mention why to choose that framework.

/r/django
https://redd.it/1duhw4f
ecommerce characteristics side bar

So I am a beginner when it comes to Django and web development, and I need to make a sidebar containing characteristics to filter the products by characteristic (color, RAM, storage, ...). I have the characteristics stored as a JSON object, and I don't know how to make use of that (I am open to changing the storage method if needed). I use PostgreSQL for the DB. Any advice is appreciated, and if possible, please use simpler technical terms as English is not my first language.
here is refrence of an example from amazon that i want to follow.
as for the type of products, the website contains a wide range of products from tech stuff to perfumes and clothes.

/r/django
https://redd.it/1dujd8e