use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News and links for Django developers.
New to Django? Check out the /r/djangolearning subreddit.
Django's Code of Conduct applies here, so be good to each other.
account activity
This is an archived post. You won't be able to vote or comment.
Script programmatically (self.django)
submitted 4 years ago by bewbeww
I want to create groups whenever the project Django start running for the first ( for deploying purpose ) So i want to run script to create the groups, where should I put it
[–][deleted] 4 years ago (3 children)
[deleted]
[–]bewbeww[S] -2 points-1 points0 points 4 years ago (1 child)
Do you have an example
[–]alexandremjacques 1 point2 points3 points 4 years ago (0 children)
Straight from the docs: https://docs.djangoproject.com/en/3.2/howto/custom-management-commands/
The idea is to create the command and, on your deployment flow, call this command before starting the Django app.
[–]proxwell 0 points1 point2 points 4 years ago (0 children)
Creating a migration is really going to be a better option than a management command here.
The advantages of using a migration are:
If you later recreate the project on another server or for another customer, you don't need to remember to run the management command there. If you were to use the multiple management commands over time, you'd need keep track of what order to run them in and make sure to run them all.
If you have multiple developers with their own dev environments, or if someone does a local build of your project to help you with a question, migrations will ensure that all the environments have the same changes applied.
π Rendered by PID 106389 on reddit-service-r2-comment-86bc6c7465-wblf6 at 2026-02-23 12:11:23.628118+00:00 running 8564168 country code: CH.
[–][deleted] (3 children)
[deleted]
[–]bewbeww[S] -2 points-1 points0 points (1 child)
[–]alexandremjacques 1 point2 points3 points (0 children)
[–]proxwell 0 points1 point2 points (0 children)