Unverified Kaydet (Commit) f47a9f0b authored tarafından Uğur Özyılmazel's avatar Uğur Özyılmazel

Fix name argument for create_app management command

üst 3505b876
[![Build Status](https://travis-ci.org/vigo/django2-project-template.svg?branch=master)](https://travis-ci.org/vigo/django2-project-template)
![Python](https://img.shields.io/badge/django-3.7.0-green.svg)
![Django](https://img.shields.io/badge/django-2.1.7-green.svg)
![Version](https://img.shields.io/badge/version-1.3.0-yellow.svg)
![Version](https://img.shields.io/badge/version-1.3.1-yellow.svg)
# Django Project Starter Template
......@@ -137,7 +137,7 @@ $ rake new:application[blog]
- Do not forget to add your `blog` to `INSTALLED_APPS` under `config/settings/base.py`:
INSTALLED_APPS += [
'blog',
'blog.apps.BlogConfig',
]
- Do not forget to fix your `config/settings/urls.py`:
......@@ -162,7 +162,7 @@ Fix your `config/settings/base.py`, add this newly created app to your `INSTALLE
AUTH_USER_MODEL = 'baseapp.User'
INSTALLED_APPS += [
'blog',
'blog.apps.BlogConfig',
]
```
......
import errno
import os
import time
import re
from importlib import import_module
from django.conf import settings
......@@ -76,7 +77,7 @@ USER_REMINDER = """
- Do not forget to add your `{app_name}` to `INSTALLED_APPS` under `config/settings/base.py`:
INSTALLED_APPS += [
'{app_name}',
'{app_name}.apps.{inital_caps_appname}Config',
]
- Do not forget to fix your `config/settings/urls.py`:
......@@ -105,6 +106,9 @@ class Command(CustomBaseCommand):
def handle(self, *args, **options):
app_name = options.pop('name')[0]
inital_caps_appname = ''.join(
map(lambda t: t.title(), re.split('[^a-zA-Z0-9]', app_name))
)
try:
import_module(app_name)
......@@ -152,7 +156,13 @@ class Command(CustomBaseCommand):
self.stdout.write(
self.style.SUCCESS('"{0}" application created.'.format(app_name))
)
self.stdout.write(self.style.NOTICE(USER_REMINDER.format(app_name=app_name)))
self.stdout.write(
self.style.NOTICE(
USER_REMINDER.format(
app_name=app_name, inital_caps_appname=inital_caps_appname
)
)
)
def generate_files(self, files_list, root_path, render_params):
for single_file in files_list:
......
......@@ -3,6 +3,7 @@ TEMPLATE_URLS = """from django.urls import path
from .views import {app_name_title}View
app_name = '{app_name}'
# fmt: off
urlpatterns = [
path('', view={app_name_title}View.as_view(), name='{app_name}_index'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment