1. New Django Project
Select SQLite Database
2. Create blog Module app
3. Test the new module is normal
4. Edit Code
4.1 Modification blog.models.py
From django.db import models to
django.contrib import Admin
# Create your models here.
Class blogpost (models. Model):
title = models. Charfield (max_length=150) Body
= models. TextField ()
timestamp = models. Datetimefield ()
, '100 bytes ', etc.) {value | filesizeformat }# if value = datetime. datetime. now () {value | date: "Y-m-d" }}# slice {value | slice: "2:-1" }}# truncation string. The truncated string ends with a translated ellipsis. {Value | truncatechars: 9} # truncation word. The truncated word will be translated into a ellipsis ("... ") at the end of {value | truncatewords: 2} ''' the Django template automatically es
1. Install the Python 2.x version and add the environment variables2. Install the VIRTUALEVN tool to isolate the system into virtual Docker reference: Https://pypi.python.org/pypi/virtualenv2.1 mkdir a folder with Virtualenv folder name, virtual a Python environment with tools such as Setuptools2.2 Install Django using the tool pip in the bin directory./pip install django==1.9.6 Reference: https://docs.djan
# static resource file Staticfiles _dirs = (Os.path.join (base_dir, "statics"),) # Now add the configuration, here is the tuple, note the commaTemplates/base.htmlTemplates/order.html{% extends "base.html"%} {# This inherits the base class and must be placed in the first row #{% block content%} {# Fill in the new content according to the name of the Block #} Templates/shopping.html{% extends "base.html"%} {# This inherits the base class and must be placed in the first line #} {% blo
Use the Mako template type: technology-related-posted at: 2010/07/27 23: 53 tags: Python Django Mako in django1.2
After reading the Mako document, I thought about changing the template to Mako. By the way, I am familiar with the syntax of Mako.In django1.2 officially added support for third-party templates (see: http://docs.djangoproject.com/en/dev/ref/t
This article is about how to use the Django framework to implement a blog system, you can manage the blog in the background.One, create the projectdjango-admin.py startproject mysiteAs shown in the following:After you run the command, a directory is created under the current directory MySiteTwo, test the development serverGo to the MySite directory, and then run
Describes how to use context in the Django framework to parse the template, djangocontext
You need a context to parse the template. Generally, this is an example of django. template. Context. However, you can use a special subclass Djang
The previous section says how to create and run a project using Django, which says how to add a blog app.The relationship between a project and its applicationBefore adding an app, let's look at what's different between the project and the app.A project is a combination of configurations and their applications that are related to a particular Web site. A project can contain multiple apps.An app is a WEB app
server, Gateway Interface), a Web server and a Web service program, or a framework.Two run server MySite (previous layer) directory execution command: Python manager.py runserverIf an error occurs:XxxYou have unapplied migrations; Your app properly until they is applied. Run ' python manage.py migrate ' to apply them.XxxIt's obvious that we've been told what to do, so execute it: Python manage.py migrateWhat does this migrate do? It allows us to reconstruct the table structure without affecting
A few days ago, a netizen suggested that I add RSS subscriptions to the blog, feel good, so I took the time to see how to add RSS in Django, found that the use of Django syndication feed framework is easy to achieve.
The implementation steps and code are as follows:
1, Feed class
#-*-Coding:utf-8-*-from django.conf Import settings from django.contrib.syndi
Django write blog 1. One webpage, two forms, submitted separately, djangoform
New to Django. I have been studying Django for a month and started to write a blog.
Python 2.7.11 Django 1.10.2 Bootstrap 3.3.0 IDE: eclipse Pydev
Model
': content_value, 13 'blog _ id': blog_id14}, 15 success: function (data) {// callback function 16 loadnewcontents () 17 $ ("# content_value "). val (""); 18} 19}); 20 return false; // do not click New Page 21}); 22 });
JavaScript code that reads all comments from the server and displays them
1 // load the latest comments 2 function loadnewcontents () 3 {4 var lstcontent =$ ("# lstcontents"); 5 // lstcontent.html (""); 6 7 var blog_id = $ ("# blog_id
#1 blog data table Design#2 Development Version Management#3 add, delete, modify, and query a blog#4 blog homepage Layout#5 view the page layout of a blog entry#6 pagination of a blog#7 blog classification Design#8. Batch deletion
Django Novice, currently on and off for one months Django, began to write a blogPython 2.7.11 Django 1.10.2 Bootstrap 3.3.0 ide:eclipse PydevModels#UserclassUser (models. Model): Username= Models. Charfield (max_length=50, unique=True) Email= Models. Emailfield (unique=True) Password= Models. Charfield (max_length=50) Admin= Models. Booleanfield (default=False)#i
Whether you're writing a custom label or a filter, the first thing to do is create a template library (the basic structure that Django can import).
Creating a template Library is a two-step walk:
First, decide which Django application the template Library should be placed i
: raise Http404 return render_to_response ("blog_show.html", {"blog": Blog})View CodeModify the blog directory below the urls.py, add the following contentURL (r'^blog/(? p','blog_show', name=' Detailblog'),Modify Blog_list.html H3 > {{Blog.caption}} H3 >Change it to H3 > href= "{% url ' detailblog ' b
1. The text {person_name} enclosed by two braces is called the variable 2 file surrounded by braces and semicolons ({% if ordered_warranty % }) is Template tag 3. The filter uses the same pipe character (|) as the Unix pipe character. 4. Once you create a Template object, you can use context to pass data to it. A context is a collection of variables and their values. The
1. Django Structure2, the site blog under the creation of Templates folder, specifically for storing template files3. Create the index.html file under the Templates folder#index. htmlDOCTYPE HTML>HTMLLang= "en">Head> MetaCharSet= "UTF-8"> title>First template filetitle>Head>Body> H1>
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.