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
Changing Model of CreateView and form

Hi all, I'd like to be able to have one CreateView that can work for a handful of models I have. Based on this portion of the documentation:

"These generic views will automatically create a `ModelForm`, so long as they can work out which model class to use"

I believe if I pass the right model to a class inheriting CreateView, I'll get a form to use for that model. With this in mind, is it possible to change the model a view references when requested? According to the documentation, I should be able to use get_object() or get the queryset, but both of those take me to SingleObjectMixin, which I don't think is used in CreateView. Am I attempting something impossible, or am I missing a key detail?

/r/django
https://redd.it/1j3hnxi
5 Things You Wish You Knew Before Starting Django



https://preview.redd.it/lmb92qul68ve1.png?width=1280&format=png&auto=webp&s=ccaeeb6b1e2419a9c50744b0d5ad0930da71edc7

After 5 years as a backend developer, here's what I really wish someone told me when I started learning Django 👇

1️⃣ Django is NOT just the Admin panel
Many people think Django is only for quick CRUD apps because of its admin interface. But the real power lies in custom apps, APIs, signals, middleware, and reusable architecture.

2️⃣ Class-Based Views (CBVs) are powerful—but confusing at first
CBVs feel overwhelming initially, but once you master ListView, DetailView, and mixins, they save tons of code.

3️⃣ Use Django REST Framework (DRF) early
If you're building APIs, DRF is your best friend. Master Serializers, ViewSets, and Routers early. It’ll make you a 10x backend dev.

4️⃣ Project structure matters
Splitting apps properly, separating services, utils, and permissions, and planning for scale early saves massive refactoring pain later.

5️⃣ Signals and Middleware are game-changers
Want to trigger actions automatically or customize request/response flow? Learn signals and middleware to level up.

💡 Bonus Tip: Learn Django the right way. Don’t just follow CRUD tutorials—build real-world systems (accounting, HR, booking, dashboards, etc.)

🔥 I’m building a full real-world Django backend course (no repetitive clones, pure architecture + business logic).
Follow me if you're interested 💬

\#django #python

/r/django
https://redd.it/1k0oyxr
Deploying Django on Cpanel

A friend of mine who's new to Django had a rough time trying to deploy his project on cPanel. After struggling for 4 days, he asked me for help. I walked him through the whole process — from setting up the Python app to handling static files in production.

To make it easier for others who might face the same issue, I recorded a step-by-step video
How to Deploy https://youtu.be/6\_HH5k76A2s?si=S4Mgp2OEU8pScMhj
How to serve static files https://youtu.be/qxtDxIJJIFw?si=H43VPtAgZqOLUGaI

Let me know what you think — and feel free to drop any suggestions or improvements!

/r/djangolearning
https://redd.it/1kuedkk