# Allow project to have management commands?

**URL:** <https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220>\
**Category:** Django Internals\
**Created:** [November 15, 2020, 11:29am UTC](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220 "2020-11-15T11:29:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![michjnich](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/michjnich/32/2424_2.png) [@michjnich](https://forum.djangoproject.com/u/michjnich)\
**Post date:** [November 15, 2020, 11:29am UTC](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/1 "2020-11-15T11:29:50Z")

</div>

I’m just in the process of doing a little refactoring. Part of this has been renaming the project directory to “config” and moving a couple of “fake” apps in there. These are apps that only really exist to provide a little extra functionality across the project (eg. couple of extra abstract models etc.).

There are a couple of management commands that are project level as well really. Previously these have been in an “app” called “initialise”, but that app contains nothing else of value. I figured I’d move them into the project folder and remove an unnecessary app.

No joy of course, as Django looks in the app folders when searching for a management command, so it doesn’t find these commands at all.

Personally, I can see the value in allowing management commands to be defined at the project level, as well as within individual apps. I don’t see any previous discussion or issue related to this, and maybe there’s a good reason not to do it that I’m not thinking of?

Curious as to what other - more experienced - folks think.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 15, 2020, 5:39pm UTC](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/2 "2020-11-15T17:39:58Z")

</div>

First, as a general note, while it _can_ be done, I always recommend that you _never_ rename or delete an application if there are any models associated with it that have been added to your database.  
(See this other thread for more details: [Official CLI's command to rename an app](https://forum.djangoproject.com/t/official-clis-command-to-rename-an-app/4450))

Now, beyond that, _our_ pattern is that we have a “project app” that serves as the project-specific location for entities that don’t belong to any more specific app. That includes management commands. (Side note: I’ve got at least four Django projects in production that never render web pages. They only exist to run management commands, and those management commands exist in that project-app directory.)

---

<div class="post-metadata">

**Author:** ![andrewgodwin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/andrewgodwin/32/2_2.png) [@andrewgodwin](https://forum.djangoproject.com/u/andrewgodwin)\
**Post date:** [November 15, 2020, 8:48pm UTC](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/3 "2020-11-15T20:48:06Z")

</div>

I, too, usually have a project-level app that services these kinds of things - often called `core` or `common` or similar. I find that easier than trying to hack in some different kind of project-level support.

---

<div class="post-metadata">

**Author:** ![michjnich](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/michjnich/32/2424_2.png) [@michjnich](https://forum.djangoproject.com/u/michjnich)\
**Post date:** [November 16, 2020, 9:09am UTC](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/4 "2020-11-16T09:09:44Z")

</div>

This is refactoring of something that has not gone live yet, so the renaming isn’t a big deal in this instance 🙂

It’s not a big deal, and I get that I can add another app that does this kind of stuff, it’s just that pretty much all of the other “config” stuff could be neatly refactored under the project, meaning I end up with the project folder plus another app that share project level stuff between them. Just seemed unnecessary, and was wondering if there was a reason the project folder was not checked by Django for management commands?

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [November 16, 2020, 10:10am UTC](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/5 "2020-11-16T10:10:52Z")

</div>

> [@michjnich](#):
>
> Just seemed unnecessary, and was wondering if there was a reason the project folder was not checked by Django for management commands?

The only reason is that Django has only one abstraction for containing “stuff” - apps. It doesn’t have a concept of your “project” beyond where the settings file is.

I too typically have a “core” app. In fact much of the time these days I tend to stick with only “core” and never split things out.

---

<div class="post-metadata">

**Author:** ![michjnich](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/michjnich/32/2424_2.png) [@michjnich](https://forum.djangoproject.com/u/michjnich)\
**Post date:** [November 16, 2020, 11:09am UTC](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/6 "2020-11-16T11:09:20Z")

</div>

Fair enough, though other “config” stuff does work under the project dir, simply by virtue of it being a module (one example: adding a `TimestampedModel` class to be used across all apps).

Since we’ll be building probably 5 or 6 Django services, with multiple apps in each one to migrate our monolith to, I’ve been trying to come up with a decent template to reuse across services, just for consistency’s sake. Given the feedback, I’ll tweak the current approach a little 🙂

Thanks for the input, everybody!
