question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Canonical location for local apps

See original GitHub issue

Cookiecutter-django defines apps inside project folder, i.e.: red_dwarf/red_dwarf/users. I tried following the convention, but Django complains that it can’t find my module, e.g.:

md red_dwarf/posts
python manage.py startapp red_dwarf/posts

config/settings/common.py

LOCAL_APPS = (
    'ref_dwarf.posts.apps.PostsConfig',
)

ImportError: No module named ‘posts’

I’d have to adjust sys.path to include the APPS_DIR, but then Django complains, burns, and crashes with Model class [...] doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

So my question is, what is the recommended location for local apps? I’ve red the docs back to back, gh issues, and the internets but could not find a meaningful answer.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
carlosfunkcommented, Jul 5, 2018

I’ve just been struggling with this myself, I had the same issue as @ltankey, tried @browniebroke suggestion but it created the files in the project folder. The only way I could create an app using docker-compose was to log in to a shell and create it from within the project folder.

$ docker-compose -f local.yml run --rm django sh
# cd <project>
# python ../manage.py startapp <appname>
6reactions
Sgiathcommented, Nov 29, 2016

As I understand it you should not create your app with startapp command. If you want new app posts just do this in the project root:

mkdir red_dwarf/posts
cd red_dwarf/posts
touch apps.py models.py urls.py views.py

Into your apps.py add this code:

from django.apps import AppConfig


class PostsConfig(AppConfig):
    name = 'red_dwarf.posts'
    verbose_name = 'Posts'

and in config/settings/common.py into LOCAL_APPS add red_dwarf.posts so it will looks like this:

LOCAL_APPS = (
    # custom users app
    'red_dwarf.users.apps.UsersConfig',
    'red_dwarf.posts',
)

And you can start code your app. It works perfectly for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Canonical location for local apps · Issue #881 · cookiecutter ...
The canonical place is inside the the project folder, otherwise the root folder gets littered with too much stuff. You can use startapp...
Read more >
When installing user applications, where do "best practices ...
The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when...
Read more >
URL Canonicalization and the Canonical Tag | Documentation
What is a canonical URL? A canonical URL is the URL of the page that Google thinks is most representative from a set...
Read more >
Canonical Names of Control Panel Items - Win32 apps
As of Windows Vista, Control Panel items included with Windows are given a canonical name that can be used in an API call...
Read more >
App install location - Android Developers
The unique container in which your application is stored is encrypted with a randomly generated key that can be decrypted only by the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found