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
I made a game with Pygame in 10 Hours!

I made a game with Pygame in 10 hours! The game contains shaders created a a module called pygame\_shaders as well as procedural generation! The download and source code is available here

​

https://i.redd.it/b0wybty877aa1.gif

/r/Python
https://redd.it/103vc07
Kernel restart

Whenever I run a code for CartPole game in Jupyter notebook or spyder after render() th kernel dies and restart .. An solution?

/r/JupyterNotebooks
https://redd.it/1025cy5
🚨New Django Project Alert 🚨 Effortlessly Combine Your iCalendar Feeds with Calmerge: The Open-Source Django Webap

Hi Django developers,

I just launched calmerge, an open-source Django webapp that allows you to merge multiple iCalendar feeds into a single feed. With calmerge, you can easily keep track of events from multiple sources in one place. Simply add your iCalendar feeds to your calmerge account, and then subscribe to the merged feed using your calendar client (e.g. Google Calendar).

As a first-time Django developer, I'm excited to share my project with the community and receive feedback on the code.

Calmerge was built with Python Django and utilizes Htmx. It's deployed on AWS and the source code is available on GitHub at github.com/abe-101/calmerge.

If you have experience with Django development, I would greatly appreciate any feedback or suggestions you may have on the code. Additionally, if you're interested in using calmerge to manage your own iCalendar feeds, you can access the webapp at calmerge.habet.dev.

Thank you for your time and I look forward to hearing your thoughts on calmerge!

/r/django
https://redd.it/1045zgp
The way I build new FastAPI projects

Some people were searching my GitHub profile for project examples after reading the article on FastAPI best practices.

Unfortunately, I didn't have useful public repositories, only my old proof-of-concept projects.

Hence, I have decided to fix that and show how I start projects nowadays, after getting some real-world experience. This repo is kind of a template I use when starting up new FastAPI projects:
- production-ready
- gunicorn with dynamic workers configuration (stolen from @tiangolo)
- Dockerfile optimized for small size and fast builds with a non-root user
- JSON logs
- sentry for deployed envs
- easy local development
- environment with configured postgres and redis
- script to lint code with black, autoflake, isort (also stolen from @tiangolo)
- configured pytest with async-asgi-testclient, pytest-env, pytest-asyncio
- fully typed to comply with mypy
- SQLAlchemy with slightly configured alembic
- async db calls with asyncpg
- set up sqlalchemy2-stubs
- migrations set in easy to sort format (YYYY-MM-DD_slug)
- pre-installed JWT authorization
- short-lived access token
- long-lived refresh token which is stored in http-only cookies
- salted password storage with bcrypt
- global pydantic model with
- orjson


/r/Python
https://redd.it/1047tdb
Just released my much-improved YouTube archiver as v1.2 🎉🎉

I've been working hard for the last week and a bit to polish and finish off my new youtube archiver software for its first solid release and I'm really happy with the outcome:

The viewer in dark mode

It has a cool offline viewer for all the videos it downloads and everything is managed through the cli. Behind the scenes I'm using yt-dlp to quickly archive content with about 1.5k lines of python to make the whole thing work. There's still a long way to go until this project is finished, but I'd consider it "stable" enough now :)

You can find the repository here with a couple more images of it in action. Any feedback is appreciated (especially with code quality/structuring), not done a proper python project in ages

/r/Python
https://redd.it/1045ug4
Check if user exist in login system Django

I'm struggling trying to figure out how to display the error message, but i don't know what else to try :(

It keeps showing the next error message: "Error al registrarse" instead of the one above.

​

views.py
def registroView(request):
if request.method == "POST":
form = CrearUsuarioForm(request.POST)
if form.isvalid():
user =
form.save(commit=False)
if Usuario.objects.filter(
username=form.cleaned
data.get("username")
).exists():
messages.error(request, "Nombre de usuario ya utilizado!")
return redirect("registro")


/r/djangolearning
https://redd.it/104w69t
Hot Reloading on Django Templates using ViteJS?

Is this possible? Laravel has a dedicated plugin to directly integrate ViteJS into your workflow.

/r/django
https://redd.it/1053a2c
Trying to create an app that allows users (businesses) to be able to find other users (businesses) that are around them

Ive created an address model (fields for address, city, state, and zip) that will be linked to my user model via a one-to-one relationship. Are there any packages that would help me find the users in my DB nearby both by using either my address stored or via current location?

/r/djangolearning
https://redd.it/10532l3
10k files in my repository I used the django admin command.

/r/django
https://redd.it/1050rw0
Just showcasing this Flask app. Any feedback is appreciated!
https://www.fleetcardeal.com/

/r/flask
https://redd.it/1051elg
How do I make another model a required field for abstractbaseuser model?

Here's a basic outline of what I've got

class Address(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
primary_key=True,
)
address = models.CharField(
max_length=200,
)
city = models.CharField(
max_length=100,
)
state = USStateField()
zipcode = USZipCodeField

class CustomUser(AbstractBaseUser):
...
required_fields = [
#How would I structure this to make the fields in Address required when


/r/django
https://redd.it/1055y71
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

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/1059w5c
Call a view and pass form fields from a pagination button

I have a template that shows a question and multiple choice answers.
I have pagination on the template and show one question at a time.
How can I call a view that will save the users answers each time the next button is clicked. I can’t submit the form because that will end the quiz and calculate the score.
I have not been able to get this working, does anyone have a solution?

/r/django
https://redd.it/105ckyc
How do you all document websocket urls in django

I know how to document django views, but how do I document websocket urls and the consumer events. Or should I write down a document literally and give it to the frontend guy ?

/r/django
https://redd.it/1052180
My celery-beat works locally but not in production?

my task:

@shared_task
def my_test():
# Executes every 2 minutes

UserStatisticStatus.objects.filter(id=1).update(loot_boxes=+234)

print('Hello from celery')



app.conf.beat_schedule = {
'my-task-every-10-seconds': {
'task': 'user_statistic_status.tasks.my_test',
'schedule': timedelta(seconds=10)
}
}

my settings:

if 'RDS_DB_NAME' in os.environ:
CELERY_BROKER_URL = 'redis://<myurl>/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_BROKER_TRANSPORT_OPTIONS = {
'region': 'eu-central-1',
'polling_interval': 20,


/r/django
https://redd.it/104pw7q
How to ensure password is hashed when saving User in model?

I'm using Djangos built in BaseUser and Abstract* for this, but when I create user on the model side using

u = User(... password="fsdfsd324")
u.fullclean()
u.save()

The DB still stores it in plain text. I've tried overriding clean and clean\
password within the model as I would in forms, but this doesn't work.

What's the cleanest way to do this without Forms/ModelForms? Thanks

/r/django
https://redd.it/104shkm
Cargo Shipping (Export/Import) in Django

Hello good day. i have this project i'm developing and its about exporting and importing like usps/dhl/ups. i have a feature that i want to add but i'm having an issue combining how it will work.
what i want is that i want a user to be able to track the list of items in their order like when a user has taken the items to be sent to another country, to usps, a shipping record should be created with tracking number on it, and once a user clicks on that record on their dashboard, it should display all the items of that shipping on another page. and how can one add multiple items to an order using django forms because the list of items would be added using forms and once saved, a shipping (import or export) history would be created in which users can view on their dashboard, click on any and see the lists of items on their shipping history including payment and all that. thats the issue i have and need clarity on. i'm using mvt.

/r/django
https://redd.it/104r65g
Free Copilot-like autocomplete for Jupyter notebooks

Hey everyone! I'm Anshul from the Codeium team, where we are building free AI-powered code autocomplete tooling, and today we are launching our integration on Jupyter notebooks, which has been the biggest ask from data scientists on our Discord since originally launching on VSCode and JetBrains. Currently no other major alternative (Github Copilot, Tabnine, Replit Ghostwriter, etc) supports standalone Jupyter notebooks. Hope you enjoy!

&#x200B;

https://reddit.com/link/105diit/video/5ppcv2tzajaa1/player

/r/JupyterNotebooks
https://redd.it/105diit