-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typical place to create app in cookiecutter-django #1876
Comments
I think this has been tried before (See #1725 ). The django startapp, apparently, was not projected to be extended. |
@playma |
Yes, the second level is the right place for your Django apps. # apps.py in your new shiny Django app under the project's root `<project_slug>/` dir
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
class <YourCamelCaseAppName>AppConfig(AppConfig):
name = "<project_slug>.<your_snake_case_app_name>"
verbose_name = _("<Your app brand name>")
def ready(self):
try:
# noinspection PyUnresolvedReferences
from . import signals # noqa F401
except ImportError:
pass And this where you should install your new app: # `base.py`
# ...
LOCAL_APPS = [
# ...
"<project_slug>.<your_snake_case_app_name>.apps.<YourCamelCaseAppName>AppConfig",
# ...
]
# ... Should you need that specific app installed in some specific environment only, provided that environment has an associated settings file like # anywhere else but in `base.py`
# ...
INSTALLED_APPS += ["<project_slug>.<your_snake_case_app_name>.apps.<YourCamelCaseAppName>AppConfig"]
# ... |
Hi, does this mean we don't need to include the new app on the urls.py? |
It depends: if your app contains urls you'd like to expose to the outer world then you gotta include those urls from the root |
Thats weird. I tried to include it but it doesn't recognize my app and returns |
If your app contains models did you install it into |
Yes, I followed the instructions here. 😄 |
Try including the app under a different root, like |
Also, did you specify |
Yes I did. I followed what was here on this comment on this thread. I tried also including |
This is my apps.py from django.apps import AppConfig from django.utils.translation import ugettext_lazy as _ class PagesConfig(AppConfig): name = "icvn.pages" verbose_name = _("Pages") def ready(self): try: from . import signals except ImportError: pass |
Hm, then, I can't say for sure what's wrong without inspecting the code base first. My email is posted on my github profile, feel free to reach out. |
Cool. I just sent an email. |
@reyesvicente I'll get back to you by the end of the weekend. |
Thanks! |
@reyesvicente you don't actually have # icvn/pages/urls.py
app_name = "pages"
urlpatterns = [
] You may also replace the |
It worked! Thank you! |
I have a question.
Startapp creates the app in the first level, the same directory where manage.py is.
Why not create the app in the <project_name>/ level, where also the users app is?
The text was updated successfully, but these errors were encountered: