Python Practice 102----Create a simple blog (bottom)

Source: Internet
Author: User

continue to change blogThen the previous article continued to change our blog.



The mother tongue is not the English swollen, the blog above English many Ah!

The change is simple.

You can make a quick change to see if the Django Management tool is translated into the language you want. Just add ' django.middleware.locale.LocaleMiddleware ' to middleware_classes settings in settings.py and make sure it's in the ' Django.contrib.sessions.middleware.SessionMiddleware ' and then it's ready.


builtthe front section of the blogCreating TemplatesBuild the index.html file in path C:\mysite\templates. The contents are as follows
Create a ViewModify C:\mysite\blog\views.py
#coding: Utf-8from django.template import loader,contextfrom django.http import Httpresqonsefrom mysite.blog.models Import Blogpostdef Archive (Request):    Posts=blogpost.objects.all ()    t=loader.get_template ("index.html")    C=context ({"Posts":p OSTs})    return HttpResponse (T.render (c))
Create urlconfModify c:\mysite\mysite\urls.py
From Django.conf.urls import patterns, include, urlfrom django.contrib import adminurlpatterns = Patterns ("', # Example S: # URL (r ' ^$ ', ' mysite.views.home ', name= ' home '), #url (R ' ^blog/', include (' Blog.urls ')), url (r ' ^admin/', include (Admin.site.urls)),    URL (r "^blog/", ' blog.views.archive '),)

now we have a simple foreground interface.

Although this homepage is very rubbing, but at least already has the blog homepage most most basic function



Above.



Knowledge pointsThe main point of the simple blog is Django Web site management (Django Admin). The following is a description of Django admin
Django Admin is the site management tool that Django comes with. Our site is not only to have ordinary display page, at the same time, a good experience of the site management interface is essential. For example, a blog backstage, you can write your own blog and publish, a forum, you can manage various permissions, post audit, personnel access and so on. For a content-based site, the admin page is especially important.

But the management interface has a problem: creating it is too cumbersome. Web development is interesting when you develop functionality for the public, but the creation of a management interface is often stereotyped. You have to authenticate users, display and manage tables, validate input validity, and so on. It's tedious and repetitive. Using Django Admin can reduce these problems. Django Admin basic style, management style is the same, Django also provides a rich interface to make developers DIY.
Of course, you can also write your own back-office management that meets the needs of this site without Django Admin, and OpenStack Horizon is a set of open source management backgrounds based on Django.


Source Address: http://download.csdn.net/detail/a359680405/8401353




Previous: Python Practice 101----Create a simple blog (on)

Python Practice 102----Create a simple blog (bottom)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.