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
Is it possible to have more than one of a single form on a single page?

I’ve been working on this flask app that when you’ve logged in as a teacher it displays all of your students in a single neat table. The final entry of each table row I’ve made into a delete button that works of a form that has two fields: userid and submit. I’ve set the values for all the userid parts of the forms to be the right values and I’ve hidden those with some formatting. But for whatever reason whenever I click the delete, the form is not validated in my routes page. I can provide code if necessary. Is the problem that I have two of the same form in the same page or have I made an error somewhere else?

/r/flask
https://redd.it/gsrwsy
Ecommerce cart for nonregistered users

I'm building an ecommerce site with flask and mysql. I want to know how to implement a cart for non registered users.
For registered users I want their cart to be stored in the database. But I do not know how to make a cart for non registered users

/r/flask
https://redd.it/gsql8z
Form Submission with AJAX to SQLite Database - Tutorial

After struggling with Ajax using vanilla JavaScript I decided to upload a YouTube tutorial so it can be an easy reference for those learning Ajax requests in Vanilla JavaScript with Flask as back-end. Here is a link to YouTube tutorial video created and uploaded by me.

​

[https://youtu.be/lUTpjsgcXMQ](https://youtu.be/lUTpjsgcXMQ)

/r/flask
https://redd.it/gsx944
snakeware - a new Linux Distro with a fully Python userspace

snakeware is a new Linux-based operating system with a fully Python userspace. Our window manager is based on pygame\_gui. We do not use X11, we draw directly to the framebuffer. We also do not use systemd or any of the other huge and typical GNU/Linux utilities, because they are very opaque and not fun for recreational programmers to contribute to.

Our distro boots directly into a Python environment, where you can then do whatever you want with your computer. It's being designed based on the spirit of the Commodore 64, which is primarily that computing should be simple and fun. snakeware is still early in development, but we would like to welcome more contributors as the project grows (both in the Python space and in the build/packaging process for the actual distro).

snakeware GitHub: [https://github.com/joshiemoore/snakeware](https://github.com/joshiemoore/snakeware)

YouTube Demo: [https://www.youtube.com/watch?v=Zy8NXuzBPhA](https://www.youtube.com/watch?v=Zy8NXuzBPhA)

Thanks for reading, I'd love to hear what you think!

edit - added a screenshot

https://preview.redd.it/bxqsh4lkop151.png?width=801&format=png&auto=webp&s=b31455342250cd6f7d7f071370498d57cec1f728

/r/Python
https://redd.it/gstn6b
Stripe with Django - are you using just stripe or dj-stripe?

I'm curious about what experienced devs are using for implementing Stripe with Django.

I see there is dj-stripe [https://github.com/dj-stripe/dj-stripe](https://github.com/dj-stripe/dj-stripe)

​

But also stripe has their own, and looks fairly simple, install method: [https://stripe.com/docs/payments/accept-a-payment-charges#web](https://stripe.com/docs/payments/accept-a-payment-charges#web)

​

In this tutorial [https://testdriven.io/blog/django-stripe-tutorial/](https://testdriven.io/blog/django-stripe-tutorial/) they don't use anything to set it up.

​

Ultimately, I will be using Stripe Connect. The flow I will be doing is:

1. authorize payment
2. capture payment (1-7 days later)

Not subscriptions or anything like that.

​

What are your inputs. Is using dj-stripe worth it for what I need or?

/r/django
https://redd.it/gt21py
[P] Star Clustering: A clustering algorithm that automatically determines the number of clusters and doesn't require hyperparameter tuning.

[https://github.com/josephius/star-clustering](https://github.com/josephius/star-clustering)

So, this has been a thing I've been working on a for a while now in my spare time. I realized at work that some of my colleagues were complaining about clustering algorithms being finicky, so I took it upon myself to see if I could somehow come up with something that could handle the issues that were apparent with traditional clustering algorithms. However, as my background was more computer science than statistics, I approached this as an engineering problem rather than trying to ground it in a clear mathematical theory.

The result is what I'm tentatively calling Star Clustering, because the algorithm vaguely resembles and the analogy of star system formation, where particles close to each other clump together (join together the shortest distances first) and some of the clumps are massive enough to reach critical mass and ignite fusion (become the final clusters), while others end up orbiting them (joining the nearest cluster). It's not an exact analogy, but it's the closest I can think of to what the algorithm more or less does.

So, after a lot of trial and error, I got an implementation that seems to work really well on the data I

/r/MachineLearning
https://redd.it/gsu3zm
Fetch API works locally not when deployed to Azure cloud.

I think I need to add some value somewhere but I don't know where.

/r/flask
https://redd.it/gt673s
This media is not supported in your browser
VIEW IN TELEGRAM
A small program to visualize basic Pathfinding/ Search algorithms

/r/Python
https://redd.it/gsu6vo
Fetch API works locally not when deployed to Azure cloud

**Error Fixed- Disregard**

​

I have a index.html and a python flask server.

The goal of this setup is to paste a long URL in a text box and when a button is pressed the long URL should be sent to the flask app via fetch API and the flask app responds with a shorter URL.

Here is the link → [https://uatomeletxyz.azurewebsites.net/](https://uatomeletxyz.azurewebsites.net/)

This works perfectly in local but when I deploy on Azure console shows the following error.

[https://uatomeletxyz.azurewebsites.net/favicon.ico](https://uatomeletxyz.azurewebsites.net/favicon.ico) 500 (INTERNAL SERVER ERROR)

VM62:1 POST [https://uatomeletxyz.azurewebsites.net/](https://uatomeletxyz.azurewebsites.net/) 500 (INTERNAL SERVER ERROR)

[uatomeletxyz.azurewebsites.net/:1](https://uatomeletxyz.azurewebsites.net/:1) Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

/r/flask
https://redd.it/gt6se4
QQ - global-scope variable in views.py?

Long story short, I've got a list of <whatever> I want to randomize and pass in to my template in a few different views.

I obviously don't want to repeat this list in every view. I understand that in this scope if I'm calling \`list.shuffle()\` and throwing it into templates, I'm playing with fire. I know that should be fine, but its probably a bad practice.


I thought of making it a "constant", and then just making sure I do a deep copy before calling shuffle on it and passing it to the templates, but I'm not sure that's ideal either.


What's the cleanest way to do this? The context data is style/css related, so I don't want it with the model.

/r/django
https://redd.it/gt8s7d
This media is not supported in your browser
VIEW IN TELEGRAM
To everyone who is learning python right now, with enough practice you too can create a masterpiece like this.

/r/Python
https://redd.it/gsxzjq
This media is not supported in your browser
VIEW IN TELEGRAM
[R] AutoSweep: Recovering 3D Editable Objects from a Single Photograph

/r/MachineLearning
https://redd.it/gtaq94
Retrieving data from html forms without rendering templates

So we have this homework where we have to retrieve data from an html form, after sending the file as 'send_static_file'. However, we are not supposed to use flask templates at all. Is there any way to do this?

/r/flask
https://redd.it/gt9wmf
Can I use a file server without any software like NGINX?

We have a server that we plan to serve our static files. I want to ask what's the point of using a web server software like NGINX?

Why it is recommended if it is not necesarry?

/r/django
https://redd.it/gtbpn1
Django REST Framework got hacked

DRF's website got hacked with a page displaying a page of African American people got killed by police "I presume". Does anyone know when it will be back?

&#x200B;

&#x200B;

https://preview.redd.it/s631vkjxlx151.png?width=704&format=png&auto=webp&s=e7cad0638da27fc076ca450c38ba9990897ac411

/r/django
https://redd.it/gthakw
Python performance comparison in my project's unittest (via Gitlab CI/CD)

/r/Python
https://redd.it/gtgsot
This media is not supported in your browser
VIEW IN TELEGRAM
Deploy as many Django websites as you want with one simple command

/r/django
https://redd.it/gtguph
Where is the "default project template"?

The Django [docs](https://docs.djangoproject.com/en/3.0/ref/contrib/admin/) for the admin site say

> The admin is enabled in the default project template used by `startproject`.
>
If you’re not using the default project template, here are the requirements: [...]


This "default project template" is not defined. What is the default project template named, and where is it located? Web search and Docs search are turning up nothing.

/r/djangolearning
https://redd.it/gtdvgh
This media is not supported in your browser
VIEW IN TELEGRAM
A Hangman AI that tries to solve words given by the user!

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