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
Why '&' changes to '&amp' when it gets to frontend? (FLASK-REACT)

I am working on a project with Flask backend and React frontend.

I send data like this

`auth_url = '`[`https://abc.com/tr/authorize?client_id=abc&response_type=code&`](https://accounts.spotify.com/tr/authorize?client_id=a2a038c0cf9f4fb08c36873347d16858&response_type=code&redirect_uri=http:%2F%2F127.0.0.1:5000&scope=playlist-modify-private%20user-read-currently-playing&show_dialog=True)`'`

`return render_template('index.html', auth_url=auth_url, page_name='sign_in')`

When I call this url from React, it changes '&' to '&amp', why it does it make this change.

I did some googling most of the responses says it is due to security reasons.

/r/flask
https://redd.it/iz3gbi
What is the correct way to create Virtual Environment for a project.

I 've seen several ways to create "Virtual Environment" in tutorials. Can someone tell me what the correct way is or better way. I'm pretty new to Django and Web-Dev, and my first Django tutorial was using this command: python -m venv project_env (new environment name). This works without any issue, but I would like to know if this is proper way. Any help will be greatly appreciated. Thank you.

/r/django
https://redd.it/iz1ogt
Data Science (Decision trees) - Please help! DM Me if you can for venmo/paypal/cashapp

Python help $$$$

Need help with this project looking for a pro thats affordable.

/r/JupyterNotebooks
https://redd.it/izcidj
Automated My Job for the First Time

So this just happened today. I've been learning Python on and off for a long time. I had to take a couple of classes for my undergrad a couple years back, and after that, I never really needed to apply it in my job.

Fast forward to today, my manager was complaining about how many requests for test data the business team was giving him. He tasked me with helping him generate the data using Excel and advanced SQL logic.

I decided to dust off my rusty Python scripting knowledge and created a script that automated the entire process. It took many hours, a lot of googling and 2 mugs of coffee, but I accomplished what I set out to do. My script was able to generate nearly 5000 queries in less than a minute.

Needless to say, my boss was impressed by my initiative, and I've found out first hand how useful knowing Python is. I want to thank this subreddit for being so supportive and always promoting new learning resources. Automate the Boring Stuff is a gold mine of info and I am more motivated than ever before to expand my skills and knowledge!

/r/Python
https://redd.it/izdclm
Pytest API endpoints that do Sqlite DB CRUD

I have a simple page that has a couple routes to do CURD into a SQLITE3 database. That's working fine. But I need to add tests with Pytest to verify their functionality.

Ideally I need to create a new database and somehow make each test use the endpoints in my website but instead of adding and delete data into the normal db, they should use the db created for testing purposes.

After tests conclude this database gets destroyed, in fact each test should spin it's own database so they are all isolated.

I know about fixtures and that I can create a new db and pass it to the tests but I don't know how to make the endpoints to point to this new database only while testing. If anybody have any ideas or point me in the right direction it'd be appreciated.

/r/flask
https://redd.it/izcv0h
Dyno reset in heroku deleting SQLAlchemy db

Hi guys, I am a beginner in FLASK and deployed a basic CRUD application on heroku. But what I noticed was after every 2-3 hrs the data entered after deployment gets deleted. I am assuming this is because of the Dyno getting reset.


I am using Flask, SQLite, gunicorn.


Can anyone pls help me out with this and what I should do.

Thanks in advance ❤️

/r/flask
https://redd.it/izeuk7
Flask with ReactJS form library - React Bare Forms

If you're using React on your Flask projects either as a front in your flask views or as a separate single page app, then take a look at React Bare forms [https://github.com/joegasewicz/react-bare-forms](https://github.com/joegasewicz/react-bare-forms)

It's designed to be the easiest form library to use in the world for ReactJS.

I would be really grateful for any feedback and your thoughts on the project!

​

Thanks

/r/flask
https://redd.it/izhwkd
Model field constraint based on other field value?

Is it somehow possible to add predefined values or constraint (former preferred), based on another field value?

E.g. based on a item transaction type \`RENTAL\` or \`PURCHASE\`, a field indicating \`RENEWAL\` becomes either active or inactive. (meaning when it's active a value is required and when it's inactive, no value is required)

Is it also possible to reflect that logic on forms?

/r/django
https://redd.it/izhcyc
The Jupyter Ecosystem seems vast and overwhelming -- is there a good website or book that distills it?


+ Hosting at Google
+ Hosting at Azure
+ Hosting at Amazon
+ Hosting at MyBinder

-----

If I want to create a series of notebooks that form the basis of an app / website or website / app, but I'd like the website itself to be a static site with the notebooks hosted live elsewhere, what are my options?

/r/JupyterNotebooks
https://redd.it/izh771
I created my First Python package on PyPI : jupyter_timetracker : Time management in a pythonic way.

# Purpose of making
I had always obsessed about saving each and every second of my time in my life. More than just saving, I was more concerned about being able to look at where my time is going throughout the day. The led me to install so many time management app on my mobile, after a lot of trial and error, I found atimelogger the best. It has all the capability what I was looking for. However, later it started to provide only basic features in free version and asking to pay to upgrade to have full features. Also, it has no desktop app. I found helpless in situations, where I am on desktop and away from my mobile. That led me to search for more productive and free apps that were both for mobile and desktop. Then i got to know about toggl and timecamp. However, these sites also provide very minimal features for free and require to pay for all features.

As an introvert guy, I want to know deeply about myself ( self-introspection ). So apart from just logging time and having timesheet, I want to

/r/Python
https://redd.it/izop7a
flask sqlalchecmy db.relationship column is not created

hello everyone, when i execute `db.create_all()` all columns gets created just fine except for one column:

products = db.relationship('Product', backref='owner', lazy=True)

here is the models

class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
city = db.Column(db.String(20), nullable=False)
branch = db.Column(db.String(20), nullable=False)
username = db.Column(db.String(20), unique=True, nullable=False)
products = db.relationship('Product', backref='owner', lazy=True)


class Product(db.Model):
id = db.Column(db.Integer, primary_key=True)
productName = db.Column(db.String(50))
productCode = db.Column(db.String(200))
productDescription = db.Column(db.String(50))
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

it was working just fine i don't know what went wrong

here is how i created the tables

>>from root import db, create_app
>>db.create_all(app=create_app())

i also tried:

>>from root import db, create_app
>>from root.users.models import User
>>from root.api.models import Product


/r/flask
https://redd.it/izjahf
Im starting a job in django

Hey guys!

In one week i will start mi first job as a dev with django + angular/react.

I just learn the django basics, can anyone give me some noobie advice?

thanks a lot!

/r/django
https://redd.it/izir65
[P] The Last Machine & Deep-Learning Compendium You’ll Ever Need

**TL;DR –** [Go to The Compendium](https://towardsdatascience.com/the-last-machine-deep-learning-compendium-youll-ever-need-dc973643c4e1) – This is a curated ***\~330*** page document, with resources on almost any Data Science and ML topic you can probably imagine.

***Disclaimer:*** This is not my project, but a friend's.

I know medium posts are not exactly projects – but this one should count as one.

It is an incredible resource created over a very long period of time – it has literally hundreds of pages with links and summaries on almost any topic in DS, ML, DL you can think of (using CTRL+F is a huge pleasure). It is still being maintained, by someone that has real life experience in the industry and academic research....also, if you want [you can go directly to the Google Doc itself](https://docs.google.com/document/d/1wvtcwc8LOb3PZI9huQOD7UjqUoY98N5r3aQsWKNAlzk/edit?usp=sharing).

I think this would be a great resource for many people in the community, and this might be a good place to share additional awesome curated resources.

/r/MachineLearning
https://redd.it/izh8a7
Question regarding nested serializers

I'm building an API for a web application that I'm working on where I'm using a nested relationship for a create end point like the one here in the DRF framework

​

[https://www.django-rest-framework.org/api-guide/relations/#nested-relationships](https://www.django-rest-framework.org/api-guide/relations/#nested-relationships)

​

I want to use the serializer for updating, so I'm using a code like this:

def update(self, instance, validated_data):
tracks_data = validated_data.pop('tracks')
tracks = instance.tracks.all()
tracks = list(tracks)
instance.album_name = validated_data.get('album_name', instance.album_name)
instance.artist = validated_data.get('artist', instance.artist)
instance.save()

for track_data in tracks_data:
track = tracks.pop(0)
track.order = track_data.get('order', track.order)
track.title = track_data.get('title', track.title)
track.duration = track_data.get('duration', track.duration)
track.save()


/r/django
https://redd.it/izozan
My open-source website built with Flask. You can convert audio and video files to another format, or download YouTube videos.

https://free-av-tools.com

Source code can be found on my GitHub page, GitHub.com/BassThatHertz

Feedback is welcome, whether it's regarding the website itself or the code. I'm not a Python expert, it was my first programming language which I started learning around Jan 2019 and I've been using it on-and-off since then. I had to learn Flask and JavaScript to make this website.

/r/flask
https://redd.it/izv8gd
Saturday megathread: Share your resources!

Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?

Use this thread to chat about and share Python resources!

/r/Python
https://redd.it/izv3tl