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
add a custom form to Django allauth signup page

hi guys I have a form that I wanna display when signing up but I need a conditional depending on which account type how can I pass the information to a function that will return the appropriate form?

/r/django
https://redd.it/kw1kxj
Python newbie here trying to learn Flask. Need advice.

Hello all! I'm a newbie trying to learn Flask. Would really appreciate some advice on learning.

I chose to learn Flask because I spent around 2 weeks learning Python from zero, and wrote my first program with has only 35 lines of code. I wanna turn this into a web app and after googling for a while, I feel like Flask is the way to go.

I spent last weekend trying to follow the Flaks official tutorial . The setup part was smooth, but now I'm stuck at the database part since I have no idea what is that. Also I'm learning very slow, since I literally have to google everything in the tutorial to figure out what that means.

Am I learning in the right way? Is there anything I need to learn before diving into this official tutorial, giving that I'm still super new to Python and only learned it for 2 weeks?

Thanks all! Any suggestion is welcome :D

/r/flask
https://redd.it/kw5sy5
Wednesday Daily Thread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/kw47c7
Giant IPKernelApp Error Using Hydrogen in Atom

Starting a few days ago, after months without issue, I began having a giant error box keep popping up when editing my code in Atom. I believe it is from the Hydrogen plugin, the weird thing is even with this error the code still runs and does what I want it too.

I even created a new conda environment, installing only what I needed (pandas, geopandas, descartes, jupyter) and even when using the new environment I am getting this issue. I've tried upgrading ipykernel but it is already the most recent version.

I'm about to lose my mind having this giant red error box keep popping up 10 seconds after I exit it out. Apologies if this is not the right subreddit to post this, but if it isn't please point me in the right direction.

Error Message: "IPKernelApp ERROR | Exception in message handler: Traceback (most recent call last): File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 268, in dispatchshell yield gen.maybefuture(handler(stream, idents, msg)) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/tornado/gen.py", line 762, in run value = future.result() File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/tornado/gen.py", line 234, in wrapper yielded = ctxrun(next, result) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 583, in completerequest matches = yield gen.maybefuture(self.docomplete(code, cursorpos)) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 360, in docomplete return self.experimentaldocomplete(code, cursorpos) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/ipykernel/ipkernel.py", line

/r/IPython
https://redd.it/kw34bp
sqlalchemy filtering on relationship

Want to check if a value is present in a relationship using sqlalchemy. Have a customer table set up as --

class Customer(Base):
Approvers = relationship("AuthUser", secondary=links.LinkCustomerUser, cascade="all, delete")

so, a query as

session.query(Customer).filter(Customer.Uuid == <somevalue>).first()

would give me a list of approvers.

Is there a way, I can check if a value AuthUser.Id is present in the list of approvers in the query itself?

In short, I want to check if given **AuthUser.Id** is present in LinkCustomerUser or not.

/r/flask
https://redd.it/kw98rs
Python changed the way I think

I started to learn python during the beginning stages of pandemic. One thing i learned during the journey with python is that mistakes are part and parcel of learning. Do you agree with me that getting bugs while running a program teaches you a lot than a tutorial video? Someday while we debugging our code and spent whole day but still can't figure out the bug and next day within 15 minutes you figure out that you have forget to put collon :)

Don't give up! But Sometimes its ok to take rest when everything is going against you and comeback later.

So guys what is your life lesson which you have learned during the journey with python. I would love to hear that.

/r/Python
https://redd.it/kwalp2
I made a decentralised, secure and anonymous networking backend...

Holy shit this project took a while
This is my pride and joy
My way of paying back the community
A decentralised, secure and anonymous networking backend.
https://github.com/Footsiefat/Tiresias_Backend
Give the demo app linked in there a shot and give me some feedback please.

/r/Python
https://redd.it/kw7qr5
VSCode users: why do you prefer it over PyCharm?

Do you prefer VSCode over PyCharm? Why?

Is it the price? Or the versatility (handling more than just Python)? Or something else?

I can't live without my PyCharm (Pro), trying to understand how other devs manage without it. :D

/r/Python
https://redd.it/kwbck9
django question answer field match

I have a question answer quiz. I have 2 models **Question** and **Answer**. I want to have 2 pages. On the first page there will be a **Question** model where the user will write the question and the answer to that question. On the second page I will display these questions and accordingly the **Answer** model where the customer enters the answer and then check if it is equal to the \*\* answer\_question \*\* of the Question. But I could not do that so call each question **Answer** and show it in html.

&#x200B;

**models.py** \-->

&#x200B;

from django.db import models

# Create your models here.
class Question(models.Model):
question=models.CharField(max_length=100)
answer_question=models.CharField(max_length=100, default=None)

def __str__(self):
return self.question


class Answer(models.Model):
questin=models.ForeignKey(Question, on_delete=models.CASCADE)
answer=models.CharField(max_length=100,blank=True)


/r/djangolearning
https://redd.it/kwfei9
Mozart: An optical music recognition system. Converts sheet music to a machine-readable version.

The aim of this project is to develop a sheet music reader. This is called Optical Music Recognition (OMR). Its objective is to convert sheet music to a machine-readable version. We take a simplified version where we convert an image of sheet music to a textual representation that can be further processed to produce midi files or audio files like wav or mp3.

GitHub: https://github.com/aashrafh/Mozart

/r/Python
https://redd.it/kwhsaa
I submitted my first bug report and it was fixed within days

I am learning to use python and pygame to mess around with fluid simulations, and came across a strange bug. Stack overflow said it was a problem with python, the python bug tracker said it was a probably pygame, and the pygame contributors identified and fixed the problem within a day.

I think it is amazing how quick this community is to fix bugs and just wanted thank everyone who makes using python so easy and fun to learn.

: I know maybe not the best language for performance, but I was just looking for a fun project

/r/Python
https://redd.it/kwgv0x
Free Getting Started With Django Course

Hey everyone.

I've just posted a 9-hour long course on getting started with Django. It's specifically for beginners. In the course, you build a basic CRM application while learning all the fundamentals of Django. You also deploy the project using the Digital Ocean App Platform.

I'd love for you to check it out and let me know what your thoughts are!

Here is a link to the course: https://youtu.be/fOukA4Qh9QA

/r/django
https://redd.it/kwjq3l
Thursday Daily Thread: Python careers!

Discussion of using Python in a professional environment, getting jobs in Python and more!

This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.

/r/Python
https://redd.it/kwtjgw
An idle race game with pygame

Here is a youtube video(could be loud) and source code.

My first game and also it was my python learning project. I learned a lot of things how should/should not to do but at the end of this, there is unlimited improvements and at some point so I must go for another projects with good management and plans. There are shortcomings in the project and I had things in mind that wanted to add, but I didn't want to spend more time only one beginner project.

Anyway, thanks for your time. Stay safe.

/r/Python
https://redd.it/kws3xs
What if?

What if 100,000 users should send a request to my flask app simultaneously? How will the app behave in such conditions? What if my sqlalchemy db table was filled with 100,000 rows, how long would db queries take?

I am new to flask (2 months), built 2 projects but have never had so many persons visit my web apps. Anyone with these experience should please share

/r/flask
https://redd.it/kwkez1
Multi-vendor Ecommerce Website Using Django | Pre-Release

In this video I'll tell you a little bit about my free upcoming Django course. The project we're going to build in this video series will be called Interiorshop. This is a multi-vendor ecommerce website where people can sign up and sell products on your webshop.

The website will be built using these technologies:
\-Django
\-Bulma CSS
\-Stripe (Payment gateway)
\-Sendgrid (for sending e-mails)

Here is a 4 min introduction to the course if you want to see a little demo:
https://www.youtube.com/watch?v=jmc0gV6\_NE0

The course will be split into three parts and I will try to publish them as soon as possible. If you want notification when I publish the parts, you need to subscribe and click the bell to get e-mail notifications :-)

/r/djangolearning
https://redd.it/kx224b
One-to-many relationship in Todo App

Hi, this is my first flask project. In my todo program, I'm trying to create a one-to-many relationship, such that, each user has many tasks. The issue I am facing is that every user is accessing every task in the table and I'm not sure how to fix that.

**The tables:**

class Users(db.Model):
id = db.Column(db.Integer, primary_key=True, nullable=False)
username = db.Column(db.String(20), unique=True, nullable=False)
password = db.Column(db.String(50), nullable=False)
tasks = db.relationship('Todo', backref='owner')

class Todo(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100), nullable=False)
owner_id = db.Column(db.Integer, db.ForeignKey('users.id'))

**Todo routes:**

@app.route("/tasks", methods=["GET"])
@login_required
def tasks():
"""User tasks"""
# show all todos
todo_list = Todo.query.all()


/r/flask
https://redd.it/kx2kpb