Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.8K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Short Django Reset Password Tutorial

I published a short video earlier today based on a few requests. People have been asking for a tutorial on how to create reset password functionality with Django.

I use the built in functionality from Django, but I override the templates.

If you want to check it out, you can find it here:
https://www.youtube.com/watch?v=ZR8Ymkx30p0

I would love to hear what you think about the content and quality :-)

/r/djangolearning
https://redd.it/lf7d4e
Official Django IRC channels have moved

Relaying a statement sent to the DSF members list, which also now is [on djangoproject.com](https://www.djangoproject.com/weblog/2021/may/26/django-irc-channels-migration-liberachat/):

> At approximately 3 am UTC on May 26, 2021, the operators of the Freenode IRC network assumed control of the #django* channels on that network. This means that representatives of the Django community no longer retain the ability to enforce Django's Code of Conduct on the Freenode IRC network. Additionally, we do not have the ability to set a topic on Django-related IRC channels on this network.
>
> Please join us in #django and #django-dev on [Libera.Chat](https://libera.chat/) for discussion of the usage and development of Django, respectively. Additionally, you may refer to our documentation on [Contributing to Django](https://docs.djangoproject.com/en/dev/internals/contributing/#join-the-django-community) for some of the other options available to you for discussion of the usage and development of Django.

/r/django
https://redd.it/nlmuum
Implementing a wysiwyg editor - Mini tutorial

Hi!
I published a video yesterday where I show you how to implement a wysiwyg editor (CKEditor) to the Django Admin interface and also how to do it in the frontend. Plus, there are possibilities to upload images.

If you want to check it out, you can find it here:
https://www.youtube.com/watch?v=Rh7THG1-THU

It's around 17 minutes.

Feel free to ask questions or give me some feedback if you have any :-D

/r/django
https://redd.it/o5k033
Django - PostHog analytics

Hi guys, I'm adding PostHog to my site I'm wondering what's better, installing PostHog to the Django server or installing it to the JS.

I think the same question would be if I were using Google Analitycs instead of PostHog.

Thanks!

/r/djangolearning
https://redd.it/uy7awd
2022 State of Django Panel @ DjangoCon US

2022 State of Django Panel Topic ideas?
\#Django #News #Events #Releases


\+ Python relationship
\+ hot packages + stack trends
\+ people!
\+ learning
\+ contributions & releases


What do YOU think needs center stage attention? You can use this form to reply anonymously http://forms.microsoft.com/r/n5aKPx3QCw or reply to post.

/r/django
https://redd.it/wwn12e
Prefetchrelated and filtering

I was reading
django documentation about [prefetch related](https://docs.djangoproject.com/en/4.2/ref/models/querysets/#django.db.models.query.QuerySet.prefetchrelated)

And the next lines confused me a bit:

pizzas = Pizza.objects.prefetchrelated('toppings')
[list(pizza.toppings.filter(spicy=True)) for pizza in pizzas]


…then the fact that pizza.toppings.all() has been prefetched will not help you.
The prefetch
related('toppings') implied pizza.toppings.all(), but pizza.toppings.filter() is a new and different query. The prefetched cache can’t help here;

Can anyone explain what is meant by this? Why prefetch cache can't help in such cases?

/r/django
https://redd.it/13232zy
Introducing drf-api-action : Empowering Django REST Framework with Enhanced Functionality

Hi all,

I created a project named drf-api-action which Obtains web framework benefits for making API Python packages

What is drf-api-action?

drf-api-action is an ingenious extension to the popular rest_framework package, introducing a decorator called api_action.
Building upon the foundation of the existing action decorator, this new addition transforms a REST API call in a class view into a straightforward function call.
With this decorator, you can effortlessly create an instance of the view and explicitly invoke its functions.

Key Benefits:

1. Arguments Validation: Ensure the integrity of your API by effortlessly validating arguments.
2. Pagination: Seamlessly implement pagination within your API functions.
3. Clear Separation of Concerns: Enjoy a clean separation between function signature and business logic, enhancing code readability.
4. Database Model Accessibility: Easily access Django DB models in other libraries or web services.

And Many More! : drf-api-action opens the door to many advantages, making DRF even more versatile for your projects.

GitHub Repository: Check out the code on GitHub

Dive Deeper on Medium: Read the in-depth article on Medium

If you find drf-api-action beneficial for your projects, show your support by starring the GitHub repository. Your stars help us grow and motivate us to continue enhancing this powerful tool for the DRF community.

# #Django #RESTFramework

/r/django
https://redd.it/186o89g
So long, Django Migrations! You were good to us.

Hi All,

My name is Rotem, I'm one of the creators of Atlas, an open-source schema migrations tool (GitHub).

We have recently released a "schema loader" plugin for Django, which enables Atlas to seamlessly read Django schemas and manage the database schema for them.

The provider's code on GitHub is available here.

Effectively, this means you can stop using python manage.py migrate and python manage.py makemigration and replace them with Atlas.

But why replace Django Migrations?

Among the many ORMs available in our industry, Django's automatic migration is one of the most powerful and robust. It can handle a wide range of schema changes, including adding new tables and columns, basic indexes, and more. However, having been created in 2014, a very different era in software engineering, it naturally has some limitations.

Some of the limitations of Django's migration system include:

Database Features. Because it was created to provide interoperability across database engines, Django's
migration system is centered around the "lowest common denominator" of database features. More advanced
features such as Triggers, Views, and Stored Procedures have very limited support and require developers to jump through [all kinds of hoops](
https://docs.djangoproject.com/en/5.0/ref/migration-operations/#django.db.migrations.operations.SeparateDatabaseAndState)
to use them.
Ensuring Migration Safety. Migrations are

/r/Python
https://redd.it/1aqhdst
Help designing model for including sem/year

I'm creating models to store questions and syllabus of different courses.

eg. program: Master of Fine Arts (MFA), courses: Sculpture, Visual arts

This is what I have in mind so far:

#django and postgresql
#from django.db import models

class Program(models.Model):
    programid = models.IntegerField(unique=True)
    program
code = models.CharField(maxlength=100)
    program
name = models.CharField(maxlength=100)


class Course(models.Model):
    course
id = models.IntegerField(unique=True)
    coursecode = models.CharField(maxlength=100)
    coursename = models.CharField(maxlength=100)
    coursecredit = models.IntegerField()
    course
icon = models.CharField(maxlength=50)
    program = models.ForeignKey(
        Program, on
delete=models.CASCADE, relatedname="courses"
    )

class Syllabus(models.Model):
    course = models.ForeignKey(Course, on
delete=models.CASCADE, relatedname='syllabus')
    topic = models.CharField(max
length=100)
    content = models.TextField()
    hours = models.IntegerField()
 

/r/django
https://redd.it/1f3robj
Feature Friday: LoginRequiredMiddleware!

The LoginRequiredMiddleware (new in Django 5.1) is great for any Django app that is mostly behind authentication. When enabled, views will require login by default. No more login_required decorators everywhere!

So how do you make a view not require login?

Use the new login_not_required decorator! This works just like the login_required decorator but for the opposite: any view it decorates will bypass the login requirement and be public. Be sure to put it on your login page otherwise you might get caught in redirect loops!

If you're building an app that mostly requires login, using the LoginRequiredMiddleware is a great way to simplify code and prevent accidentally leaking content—by making your app private by default.

Read more in the documentation here: https://docs.djangoproject.com/en/5.1/ref/middleware/#django.contrib.auth.middleware.LoginRequiredMiddleware

/r/django
https://redd.it/1gh51ai
Should I go for Django?

Hey everyone, I am in 2nd Year of My bachelor's degree in Computer Science. I have been using Flask for the past 1 year. Many people have told me that there is no future of Flask. I know that Django is feature rich whereas Flask provides a minimalist approach where you only install what you need. But the problem arises is that I am concerned about my skills in the long run. Is Flask used at the production level? My goal is to crack Big Tech company. Is it really worth the hassle to move towards Django or should I move with Flask?

I hope to hear from the community.


#django #learndjango #python #drf #rest #api

/r/django
https://redd.it/1hsi5cz
Django.Social - Community Hosting Platform

Asking for some help.

I'm getting sick of having to use Meetup.com for hosting the Django.Social community.

I started this group almost 3 years ago for the Django community to try and bring people together regularly. However the last 6 monthly bill we received was over $1,600 and Meetup is proving pretty limited in terms of its functionality and VFM.

Some of our best events have been around Django Conferences getting people to socialise the night before the conference starts.

In all, we have almost 2,000 members across 7 groups in 7 countries and want this to grow further but without having to charge members or the groups having to find sponsors.

We have a discord channel with a handful of users and not much activity which would be an obvious place to host the community and then publicise events using free tools like eventbrite.

Are there any other options out there that people use for their groups/communities?

Please share any suggestions and help us out so we can keep this all going.

#DjangoSocial #DjangoMeetup #DjangoEvent #DjangoCon #DjangoConEurope #Django #DjangoPeople #DjangoCommunity

/r/django
https://redd.it/1iypnzp
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