Skip to content
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

Changed template folder structure so that mysite is not needed in INSTALLED_APPS #117

Merged
merged 1 commit into from
Aug 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions django_forms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ So once again we will create: a link to the page, a URL, a view and a template.

## Link to a page with the form

It's time to open `mysite/templates/mysite/base.html`. We will add a link in `div` named `page-header`:
It's time to open `blog/templates/blog/base.html`. We will add a link in `div` named `page-header`:

<a href="{% url 'blog.views.post_new' %}" class="top-menu"><span class="glyphicon glyphicon-plus"></span></a>

Expand Down Expand Up @@ -123,7 +123,7 @@ We need to create a file `post_edit.html` in the `blog/templates/blog` directory

Ok, so let's see how the HTML in `post_edit.html` should look:

{% extends 'mysite/base.html' %}
{% extends 'blog/base.html' %}

{% block content %}
<h1>New post</h1>
Expand Down Expand Up @@ -232,7 +232,7 @@ Open `blog/post_detail.html` and add this line:

so that the template will look like:

{% extends 'mysite/base.html' %}
{% extends 'blog/base.html' %}

{% block content %}
<div class="date">
Expand Down
3 changes: 1 addition & 2 deletions django_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ You will notice that a new `blog` directory is created and it contains a number
tests.py
views.py

After creating an application we also need to tell Django that it should use it. We do that in the file `mysite/settings.py`. We need to find `INSTALLED_APPS` and add two lines: `'mysite',` and `'blog',` just above `)`. So the final product should look like this:
After creating an application we also need to tell Django that it should use it. We do that in the file `mysite/settings.py`. We need to find `INSTALLED_APPS` and add a line containing `'blog',` just above `)`. So the final product should look like this:

INSTALLED_APPS = (
'django.contrib.admin',
Expand All @@ -88,7 +88,6 @@ After creating an application we also need to tell Django that it should use it.
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mysite',
'blog',
)

Expand Down
4 changes: 2 additions & 2 deletions extend_your_application/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We already have a `Post` model, so we don't need to add anything to `models.py`.

We will start with adding a link inside `blog/templates/blog/post_list.html` file. So far it should look like:

{% extends 'mysite/base.html' %}
{% extends 'blog/base.html' %}

{% block content %}
{% for post in posts %}
Expand Down Expand Up @@ -121,7 +121,7 @@ We will create a file in `blog/templates/blog` called `post_detail.html`.

It will look like this:

{% extends 'mysite/base.html' %}
{% extends 'blog/base.html' %}

{% block content %}
<div class="date">
Expand Down
15 changes: 8 additions & 7 deletions template_extending/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ This way you don't have to repeat yourself in every file, when you want to use t

A base template is the most basic template that you extend on every page of your website.

Create a `templates/mysite/base.html` file. You also need to create `templates` and `mysite` directories, but you probably have noticed this pattern already :)
Let's create a `base.html` file in `blog/templates/blog/`:

mysite
blog
└───templates
└───mysite
└───base.html
└───blog
base.html
post_list.html

Then open it up and copy everything from `post_list.html` to `base.html` file, like this:

Expand Down Expand Up @@ -83,11 +84,11 @@ Now save it, and open your `blog/templates/blog/post_list.html` again. Delete ev

And now add this line to the beginning of the file:

{% extends 'mysite/base.html' %}
{% extends 'blog/base.html' %}

It means that we're now extending `base.html` template in `post_list.html`. Only one thing left: put everything (except the line we just added) between `{% block content %}` and `{% endblock content %}`. Like this:

{% extends 'mysite/base.html' %}
{% extends 'blog/base.html' %}

{% block content %}
{% for post in posts %}
Expand All @@ -101,4 +102,4 @@ It means that we're now extending `base.html` template in `post_list.html`. Only

That's it! Check if your website is still working properly :)

> If you have an error `TemplateDoesNotExists` that says that there is no `mysite/base.html` file and you have `runserver` running in the console, try to stop it (by pressing Ctrl+C - Control and C buttons together) and restart it by running a `python manage.py runserver` command.
> If you have an error `TemplateDoesNotExists` that says that there is no `blog/base.html` file and you have `runserver` running in the console, try to stop it (by pressing Ctrl+C - Control and C buttons together) and restart it by running a `python manage.py runserver` command.