Determine where the app or project templates are. Use django.__path__[0] as the default because the Django install directory isn't known.
(self, template, subdir)
| 234 | run_formatters([top_dir], **formatter_paths, stderr=self.stderr) |
| 235 | |
| 236 | def handle_template(self, template, subdir): |
| 237 | """ |
| 238 | Determine where the app or project templates are. |
| 239 | Use django.__path__[0] as the default because the Django install |
| 240 | directory isn't known. |
| 241 | """ |
| 242 | if template is None: |
| 243 | return os.path.join(django.__path__[0], "conf", subdir) |
| 244 | else: |
| 245 | template = template.removeprefix("file://") |
| 246 | expanded_template = os.path.expanduser(template) |
| 247 | expanded_template = os.path.normpath(expanded_template) |
| 248 | if os.path.isdir(expanded_template): |
| 249 | return expanded_template |
| 250 | if self.is_url(template): |
| 251 | # downloads the file and returns the path |
| 252 | absolute_path = self.download(template) |
| 253 | else: |
| 254 | absolute_path = os.path.abspath(expanded_template) |
| 255 | if os.path.exists(absolute_path): |
| 256 | return self.extract(absolute_path) |
| 257 | |
| 258 | raise CommandError( |
| 259 | "couldn't handle %s template %s." % (self.app_or_project, template) |
| 260 | ) |
| 261 | |
| 262 | def validate_name(self, name, name_or_dir="name"): |
| 263 | if name is None: |