1
0
mirror of https://github.com/django/django.git synced 2025-04-01 12:06:43 +00:00

[5.1.x] Fixed #35502 -- Removed duplication of "mysite" directory name in intro docs.

Reorganized intro docs when explaining `django-admin startproject` to prevent
confusion when using "mysite" as both the top-level directory and the Django
project directory name.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
Co-authored-by: Carlton Gibson <carlton@noumenal.es>

Backport of d2c74cfb48a3d29159732fb98e3c28a53572067f from main.
This commit is contained in:
Meta 2024-08-07 16:07:22 -03:00 committed by Natalia
parent e2551b30ad
commit 2bd546957d
6 changed files with 37 additions and 34 deletions

View File

@ -26,7 +26,7 @@ representing your models -- so far, it's been solving many years' worth of
database-schema problems. Here's a quick example: database-schema problems. Here's a quick example:
.. code-block:: python .. code-block:: python
:caption: ``mysite/news/models.py`` :caption: ``news/models.py``
from django.db import models from django.db import models
@ -151,7 +151,7 @@ a website that lets authenticated users add, change and delete objects. The
only step required is to register your model in the admin site: only step required is to register your model in the admin site:
.. code-block:: python .. code-block:: python
:caption: ``mysite/news/models.py`` :caption: ``news/models.py``
from django.db import models from django.db import models
@ -163,7 +163,7 @@ only step required is to register your model in the admin site:
reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE) reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE)
.. code-block:: python .. code-block:: python
:caption: ``mysite/news/admin.py`` :caption: ``news/admin.py``
from django.contrib import admin from django.contrib import admin
@ -195,7 +195,7 @@ Here's what a URLconf might look like for the ``Reporter``/``Article``
example above: example above:
.. code-block:: python .. code-block:: python
:caption: ``mysite/news/urls.py`` :caption: ``news/urls.py``
from django.urls import path from django.urls import path
@ -235,7 +235,7 @@ and renders the template with the retrieved data. Here's an example view for
``year_archive`` from above: ``year_archive`` from above:
.. code-block:: python .. code-block:: python
:caption: ``mysite/news/views.py`` :caption: ``news/views.py``
from django.shortcuts import render from django.shortcuts import render
@ -265,7 +265,7 @@ Let's say the ``news/year_archive.html`` template was found. Here's what that
might look like: might look like:
.. code-block:: html+django .. code-block:: html+django
:caption: ``mysite/news/templates/news/year_archive.html`` :caption: ``news/templates/news/year_archive.html``
{% extends "base.html" %} {% extends "base.html" %}
@ -306,7 +306,7 @@ Here's what the "base.html" template, including the use of :doc:`static files
</howto/static-files/index>`, might look like: </howto/static-files/index>`, might look like:
.. code-block:: html+django .. code-block:: html+django
:caption: ``mysite/templates/base.html`` :caption: ``templates/base.html``
{% load static %} {% load static %}
<html> <html>

View File

@ -57,7 +57,7 @@ After the previous tutorials, our project should look like this:
.. code-block:: text .. code-block:: text
mysite/ djangotutorial/
manage.py manage.py
mysite/ mysite/
__init__.py __init__.py
@ -90,12 +90,12 @@ After the previous tutorials, our project should look like this:
admin/ admin/
base_site.html base_site.html
You created ``mysite/templates`` in :doc:`Tutorial 7 </intro/tutorial07>`, You created ``djangotutorial/templates`` in :doc:`Tutorial 7
and ``polls/templates`` in :doc:`Tutorial 3 </intro/tutorial03>`. Now perhaps </intro/tutorial07>`, and ``polls/templates`` in
it is clearer why we chose to have separate template directories for the :doc:`Tutorial 3 </intro/tutorial03>`. Now perhaps it is clearer why we chose
project and application: everything that is part of the polls application is in to have separate template directories for the project and application:
``polls``. It makes the application self-contained and easier to drop into a everything that is part of the polls application is in ``polls``. It makes the
new project. application self-contained and easier to drop into a new project.
The ``polls`` directory could now be copied into a new Django project and The ``polls`` directory could now be copied into a new Django project and
immediately reused. It's not quite ready to be published though. For that, we immediately reused. It's not quite ready to be published though. For that, we

View File

@ -48,14 +48,21 @@ including database configuration, Django-specific options and
application-specific settings. application-specific settings.
From the command line, ``cd`` into a directory where you'd like to store your From the command line, ``cd`` into a directory where you'd like to store your
code, then run the following command: code and create a new directory named ``djangotutorial``. (This directory name
doesn't matter to Django; you can rename it to anything you like.)
.. console:: .. console::
$ django-admin startproject mysite $ mkdir djangotutorial
This will create a ``mysite`` directory in your current directory. If it didn't Then, run the following command to bootstrap a new Django project:
work, see :ref:`troubleshooting-django-admin`.
.. console::
$ django-admin startproject mysite djangotutorial
This will create a project called ``mysite`` inside the ``djangotutorial``
directory. If it didn't work, see :ref:`troubleshooting-django-admin`.
.. note:: .. note::
@ -68,7 +75,7 @@ Let's look at what :djadmin:`startproject` created:
.. code-block:: text .. code-block:: text
mysite/ djangotutorial/
manage.py manage.py
mysite/ mysite/
__init__.py __init__.py
@ -79,14 +86,11 @@ Let's look at what :djadmin:`startproject` created:
These files are: These files are:
* The outer :file:`mysite/` root directory is a container for your project. Its
name doesn't matter to Django; you can rename it to anything you like.
* :file:`manage.py`: A command-line utility that lets you interact with this * :file:`manage.py`: A command-line utility that lets you interact with this
Django project in various ways. You can read all the details about Django project in various ways. You can read all the details about
:file:`manage.py` in :doc:`/ref/django-admin`. :file:`manage.py` in :doc:`/ref/django-admin`.
* The inner :file:`mysite/` directory is the actual Python package for your * :file:`mysite/`: A directory that is the actual Python package for your
project. Its name is the Python package name you'll need to use to import project. Its name is the Python package name you'll need to use to import
anything inside it (e.g. ``mysite.urls``). anything inside it (e.g. ``mysite.urls``).
@ -111,8 +115,8 @@ These files are:
The development server The development server
====================== ======================
Let's verify your Django project works. Change into the outer :file:`mysite` directory, if Let's verify your Django project works. Change into the :file:`djangotutorial`
you haven't already, and run the following commands: directory, if you haven't already, and run the following commands:
.. console:: .. console::
@ -179,10 +183,8 @@ rather than creating directories.
configuration and apps for a particular website. A project can contain configuration and apps for a particular website. A project can contain
multiple apps. An app can be in multiple projects. multiple apps. An app can be in multiple projects.
Your apps can live anywhere on your :ref:`Python path <tut-searchpath>`. In Your apps can live anywhere in your :ref:`Python path <tut-searchpath>`. In
this tutorial, we'll create our poll app in the same directory as your this tutorial, we'll create our poll app inside the ``djangotutorial`` folder.
:file:`manage.py` file so that it can be imported as its own top-level module,
rather than a submodule of ``mysite``.
To create your app, make sure you're in the same directory as :file:`manage.py` To create your app, make sure you're in the same directory as :file:`manage.py`
and type this command: and type this command:

View File

@ -216,7 +216,7 @@ and you'll see something like:
FAIL: test_was_published_recently_with_future_question (polls.tests.QuestionModelTests) FAIL: test_was_published_recently_with_future_question (polls.tests.QuestionModelTests)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Traceback (most recent call last): Traceback (most recent call last):
File "/path/to/mysite/polls/tests.py", line 16, in test_was_published_recently_with_future_question File "/path/to/djangotutorial/polls/tests.py", line 16, in test_was_published_recently_with_future_question
self.assertIs(future_question.was_published_recently(), False) self.assertIs(future_question.was_published_recently(), False)
AssertionError: True is not False AssertionError: True is not False

View File

@ -306,10 +306,10 @@ powered by Django itself, and its interfaces use Django's own template system.
Customizing your *project's* templates Customizing your *project's* templates
-------------------------------------- --------------------------------------
Create a ``templates`` directory in your project directory (the one that Create a ``templates`` directory in your ``djangotutorial`` directory.
contains ``manage.py``). Templates can live anywhere on your filesystem that Templates can live anywhere on your filesystem that Django can access. (Django
Django can access. (Django runs as whatever user your server runs.) However, runs as whatever user your server runs.) However, keeping your templates within
keeping your templates within the project is a good convention to follow. the project is a good convention to follow.
Open your settings file (:file:`mysite/settings.py`, remember) and add a Open your settings file (:file:`mysite/settings.py`, remember) and add a
:setting:`DIRS <TEMPLATES-DIRS>` option in the :setting:`TEMPLATES` setting: :setting:`DIRS <TEMPLATES-DIRS>` option in the :setting:`TEMPLATES` setting:

View File

@ -141,6 +141,7 @@ Disqus
distro distro
django django
djangoproject djangoproject
djangotutorial
dm dm
docstring docstring
docstrings docstrings