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
Building Flask App - How to seed Postgres DB with data from JSONplaceholder API...

Good day community

I am busy building a Flask App (blog) as beginner. In short what I would like to know is how can I seed my postgres db with the data from JSON Placeholder API (https://jsonplaceholder.typicode.com/posts).. as always I would be using SQLAlchemy as the ORM of choice.

Any tutorials or resources would be welcome. Thanks in advance...yours in reddit..

/r/flask
https://redd.it/kt0zxz
Why Django? Im confused.

Hi! I've recently been watching "Fireship" on youtube. https://www.youtube.com/channel/UCsBjURrPoezykLs9EqgamOA

Thing is, he shows all of these different technologies that are being released. And I can't help but think: why learn all that when you can focus on a single language like python (specially having things such as Django!).

I'm most certainly missing and misunderstanding something here.

Why would you put the extra effort with Javascript and its thousands of frameworks or learn flutter when you can do all those things in django???

/r/django
https://redd.it/kt7ojj
Importing an Mp3 File

Hello everyone,

I am using jupyter notebooks to create a speech to translation program. However, whenever I upload an mp3 file I always get an error. Can anyone please give me some insight on why this is happening.

Thanks

​

https://preview.redd.it/ajt8ctnux4a61.png?width=960&format=png&auto=webp&s=43bd5257c1836a80552acb95c93f442b98da905a

​

https://preview.redd.it/526au2twx4a61.png?width=960&format=png&auto=webp&s=ec50317694570af2ee787a02771820fb875fc7e6

​

​

​

https://preview.redd.it/9adfh5pyx4a61.png?width=960&format=png&auto=webp&s=b550a6bb8e07a2ac57572075b9d534399e7eae2f

/r/JupyterNotebooks
https://redd.it/kt5x3b
Saturday Daily Thread: 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/ktfa01
Heroku deployment



Hi guys so i tried to deploy on heroku and it didn't work so I tried again and this time i used the "heroku create [name\] to create another app. And then ran git push heroku master after commiting changes but the error i got was

( ! [remote rejected\] master -> master (pre-receive hook declined)

error: failed to push some refs to 'old appname'.

So I wanted to know why it pushed to the old one and not the new one and how to fix it

Also another different question, do you guys have two settings like "local_settings.py and settings.py" or only one.

/r/django
https://redd.it/ktf7t0
Confusion regarding django channels

I recently is thinking about making asynchronous apps , I know about django channels but I feel they are not production ready.I have not known any company use django channels.What are your opinions about django channels?

/r/django
https://redd.it/ktimi5
How do you bind a file (not uploaded but internally generated) to a model's FileField after the model has been saved?

I have a model that takes, among other fields, a video as a `models.FileField()`, two text files as `models.FileField()` and an image as a `models.ImageField()`. Now, of these four fields, only the video and one text file are uploaded by the user, the other text file and the image are generated internally and—I think, so far—need to be bound to model fields. The image needs to be displayed in a page and the text file will be available for download. I still don't know how to offer this download, but I'm trying to have it as a model field.

Something like this ([`models.py`](https://models.py)):

class Project(models.Model):
project_name = models.CharField(unique=True, max_length=80)
video_file = models.FileField(upload_to=user_directory_path)
original_text_file = models.FileField(
blank=True,
upload_to=user_directory_path
)
generated_text_file = models.FileField(blank=True)
# This image is generated with

/r/django
https://redd.it/ktk9iq
Good Django libraries to read to really understand class-based views?

Are there any Django libraries that make extensive use of class-based views that I might study if I want to gain an in-depth understanding of how to use them? The Django documentation is OK at explaining what they are and how they work but most of the examples are very trivial in nature. I'd like to become a "power user" and for that I need lots of code to study. I've looked at the Classy Class-Based Views examples but they seem too "meta" to me to shed any real light on how to use them in practice. Thanks.

/r/djangolearning
https://redd.it/ktbx5i
I automated a full time full before it could be advertised

Thought this was funny. I work as an Accountant and last week my Manager let me know that due to a Government audit we would be required to fully itemise our government funding client statements.

The problem is that our client statement involve charges from third party companies who are paid from this government funding and all these invoices are held on a third party website.

The third party website said they couldn't help and it was determined that due to how slow the website is as well as other factors (the invoices are all listed as individual download links, some invoices are password protected pdf's, some are jpg's, the website layout is terrible) that it would require 160-180 hours of manual work and therefore a new admin person would need to be hired.

So I wrote something in Python that opens a headless browser, grabs all client names, then goes through each clients account and downloads every invoice, skips any client with no invoices, converts all jpg's to pdf's and resizes them so they fit correctly on the page and merges all invoices into one file per client to form our new statement file.

It takes about about an hour to

/r/Python
https://redd.it/ktj4jq
Application data flow between browser, Nuxt and Django for simple CRUD app with session authentication (repo, article & diagram in comments)

/r/django
https://redd.it/kts9xw
This media is not supported in your browser
VIEW IN TELEGRAM
[P] [D] ML algorithm that can morph any two images without reference points.

https://redd.it/ktnwcv
@pythondaily
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/ku2q3e
As a thank you to the community, here is my new book: Slither into Data Structures and Algorithms

Hi everyone!

A couple of years ago I released "Slither into Python" for free online which was an introduction to Python for complete beginners. I released it for free as a thank you to the Python community in general. You can view that here.

The feedback was amazing (thank you all, I'm delighted you enjoyed it!). It inspired me to write another book that I felt was the natural extension to it - focusing on data structures and algorithms. In fact, I had a lot of requests for it after the last two chapters of that book so that inspired me even more to write this.

I had started on it a while back but work became super busy and last year happened so I kind of forgot about it. However I recently came across the files and decided to pick it back up.

It's now complete: "Slither into Data Structures and Algorithms: A concise guide to the backbone of the digital world through Python" and you can check it out here: slitherintoalgorithms.com.

The chapter on Graphs is up and free to read on the site! Again, I'd like to thank everyone on this subreddit that gave such amazing feedback and improvements for my last

/r/Python
https://redd.it/ku09n3
D Color coding equations

I've seen this done in a few places and wanted to give it a try - where you color code parts of mathematical equations so that it's easier to follow them around, or to group them.

At a glance it seems easier to follow around and see some relationships. Wonder whether it can be a distraction when reading the text. What are your opinions on it?

Example: (screenshot from https://lab-ml.com/labml\_nn/transformers/relative\_mha.html)

https://preview.redd.it/ir7zouvns8a61.png?width=1062&format=png&auto=webp&s=c603bb1681a83efbbbacf382ccf8e511c51efafb

/r/MachineLearning
https://redd.it/ktkuay
Sane: Makefile for Humans

Despite being a great and flexible tool (proof of which is how long it's been around for!), I've always been a little frustrated by Make in two aspects:

1. How cumbersome and opaque the grammar of Make is ($* $< $@?!)
2. How hard it is to keep state (which usually ends up in having a recipe be a single long bash line with a lot of \s --- and that's ugly and hard to read.)

`Sane` (`sane-build` in PyPI) is an attempt to create an alternative that incorporates the ideas of Make, but provides the full flexibility of Python in terms of writing logic.

From the project's README:

> - Recipes are python functions with recipe/file/hook dependencies.
> - If a recipe A depends on recipe B, recipe B is checked. If B is ran, then A is ran afterwards.
> - Recipes are ran if its dependency files are newer than its target files (or if either cannot be found).
> - Recipes with no dependencies are always ran.
> - Hooks are a way to tag dependencies. Recipes depending on a hook depend on all recipes with that hook.
> - Everything else is standard Python.

Like its name indicates, sane tries to be as uncomplicated as possible

/r/Python
https://redd.it/ktxk80
A list of tutorials for beginners

I have been working on a series of videos to show the basics of Python Programming to beginners. If you are new to the language, programming in general, or would like a quick reference to some basic concepts, this will hopefully be a good resource for you!

[Introduction](https://youtu.be/eJt-leDZqls)
Creating, Using, and Manipulating Variables
[Working with Arrays and Dictionaries](https://youtu.be/BsgfRXaVTik)
Controlling Program Flow with Loops
[Recycling Code with Functions](https://youtu.be/Dwkb2rcoT2U)
Creating Abstract Objects through Classes
[Relating Objects to One Another with Inheritance](https://youtu.be/POkIYB1vlcA)
Replacing Parent Methods by Overriding Functions
[Utilizing Static and Class Variables](https://youtu.be/u55vEYcMWko)
Creating Virtual Environments

The tutorials follow a long-term series where I build bigger projects, so the list will grow over time. I would love to hear suggestions for more videos to make!

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