GithubHelp home page GithubHelp logo

django-by-example-zh's Issues

第七章>创建目录模板(templates)| 代码错误

第七章

创建目录模板(templates) 下最后一个代码块中:

{% extends "shop/base.html" %}
{% load static %}

{% block title %}
    {% if category %}{{ category.title }}{% else %}Products{% endif %}
{% endblock %}

{% block content %}
    <div class="product-detail">
        ![]({% if product.image %}{{ product.image.url }}{% else %}{% static )
        <h1>{{ product.name }}</h1>
        <h2><a href="{{ product.category.get_absolute_url }}">{{ product.category }}</a></h2>
        <p class="price">${{ product.price }}</p>
            {{ product.description|linebreaks }}
    </div>
{% endblock %}

其中

![]({% if product.image %}{{ product.image.url }}{% else %}{% static )

应该是

<img src="{% if product.image %}{{ product.image.url }}{% else %}{% static "img/no_image.png" %}{% endif %}">

Typo from chapter2

In the code from email part, there is a line
request.build_absolute_url
However,build_absolute_uri() should be the correct API, as far as I'm concerned.

Same part
return render(request, 'blog/post/share.html', {'post': post, 'form': form, 'sent': sent})
only post,form,sent is rendered to template: share.html
but in share.html, "{{ post.title }}" was successfully sent to {{ cd.to }}. also involves cd

关于转载的问题

我可以转载到自己的网站吗?
署名,会贴上原地址。
就是自己看着方便

【Django By Example第一章翻译.md】中字符翻译错误问题

文章五分之四处,字符翻译错误, 原句为:
”只要你喜欢你可以连接许多模板标签(tempalte filters),每一个都会应用到上个输出生成的结果上。“

更正为:
”只要你喜欢你可以连接许多模板标签(template tag),每一个都会应用到上个输出生成的结果上。“

Official Errata on 2017-04-17

Errata

- 12 submitted: last submission 30 Mar 2017

Chapter 1,

Building a Blog Application | Section: Creating objects | Page no: 18 |Errata category: Code

The code given is:

>>> Post.objects.create(title='One more post',
                        slug='one-more-post',
                        body='Post body.',
                        author=user)

It should be as follows:

>>> post = Post(title='One more post',
                    slug='one-more-post',
                    body='Post body.',
                    author=user)

Chapter 2,

Enhancing Your Blog with Advanced Features | Section: Handling ModelForms in views | Page no:47 | Errata category: Technical

The sentence given is:

Edit the models.py file, add imports for the Comment model and the CommentForm form, and modify the post_detail view to make it look like the following:

It should be:

Edit the views.py file, add imports for the Comment model and the CommentForm form, and modify the post_detail view to make it look like the following:

Chapter 2,

Enhancing Your Blog with Advanced Features | Section: Adding comments to the post detail template | Page no: 49 | Errata category: Technical

The sentence given is:

Open the blog_detail.html template and append the following code inside the content block:

It should be:

Open the views_detail.html template and append the following code inside the content block:

Chapter 3:

Extending Your Blog Application | Section: Creating a search view | Page no: 83 | Errata category: Code

The code given is:

def post_search(request):
	form = SearchForm()

	if 'query' in request.GET:
		form = SearchForm(request.GET)

	if form.is_valid():

The code should be:

def post_search(request):
	cd = None
	form = SearchForm()

	if 'query' in request.GET:
		form = SearchForm(request.GET)

	if form.is_valid():

Chapter 3:

Extending Your Blog Application | Section: Creating feeds for your blog posts | Page no: 74 | Errata category: typo

The sentence given is:

Navigate to http://127.0.0.1:8000/blog/feed/ in your browser. You should now see the RSS feedincluding the last five blog posts:

It should be:

Navigate to http://127.0.0.1:8000/blog/feed/ in your browser. You should now see the RSS feed including the last five blog posts:

Errata Type: Technical | Page 49 |

\1. The sentence given is: Now we need to adapt our post_detail.html template to do the following:

It should be: Now we need to adapt our post/detail.html template to do the following:

\2. The sentence given is: Open the blog_detail.html template and append the following code inside the content block:

It should be: Open the post/detail.html template and append the following code inside the content block:

\3. Errata for this mistakes on page https://www.packtpub.com/books/content/support/20895 has mistake Open the views_detail.html template and append the following code inside the content block:

It should be: Open the post/detail.html template and append the following code inside the content block:

On page 364 | Chapter 10 | Under section "Using mixins from django-braces"

Make OwnerCourseMixin inherit LoginRequiredMixin like this:

class OwnerCourseMixin(OwnerMixin, LoginRequiredMixin) :

Should be:

Make OwnerCourseEditMixin inherit LoginRequiredMixin like this:

class OwnerCourseEditMixin(OwnerMixin, LoginRequiredMixin) :

Chapter 1:

Extending Your Blog Application | Section: Using the filter() method | Page no: 18 | Errata category: code

The code given is:

Post.objects.filter(publish__year=2015)\
                   filter(author__username='admin')

It should be:

Post.objects.filter(publish__year=2015)\
                  .filter(author__username='admin')

Chapter 3:

Extending Your Blog Application | Section: Creating a search view | Page no: 84 | Errata category: typo

The sentence given is:

If the form is valid, we use the we use SearchQuerySet to perform a search for It should indexed Post objects whose main content contains the given query.

It should be:

If the form is valid, we use the SearchQuerySet to perform a search for It should indexed Post objects whose main content contains the given query.

Chapter 4:

Building a Social Website | Section: Log in and log out views | Page no: 100 | Errata category: code

The code given is:

Hello {{ request.user.first_name }},

It should be:

Hello {{ request.user.username }},

Chapter 3:

Extending Your Blog Application | Section: Creating custom template tags | Page no: 64-65 | Errata category: Typo

Our template tag will accept an optional count parameter that defaults to 5 and allows us to specify the number of comments we want to display.

The template tag we just created can be used passing the optional number of comments to display like {% show_latest_posts 3 %}.

Now, edit the blog/base.html template and add the new template tag to display the last 3 comments.

The template tag is called passing the number of comments to display and the template is rendered in place with the given context.

They should be:

Our template tag will accept an optional count parameter that defaults to 5 and allows us to specify the number of posts we want to display.

The template tag we just created can be used passing the optional number of posts to display like {% show_latest_posts 3 %}.

Now, edit the blog/base.html template and add the new template tag to display the last 3 posts.

The template tag is called passing the number of posts to display and the template is rendered in place with the given context.

Errata Type: Typo | Chapter 2 | Page 40
This:

request.build_absolute_uri

Should be:

request.build_absolute_url

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.