Django write blog 1. One webpage, two forms, submitted separately, djangoform

Source: Internet
Author: User

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

Models

# User class User (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) # image = models. imageField (upload_to = 'static/image/% Y/% m', default = 'static/image/default.jpg ', max_length = 200, # blank = True, null = True, verbose_name = 'user Avatar ') created_dt = models. dateTimeField (auto_now_add = True, db_index = True) def _ unicode _ (self): return self. username # blog Category class Category (models. model): name = models. charField (max_length = 64, blank = True, null = True) def _ unicode _ (self): return self. name # blog label class ArticleTag (models. model): tagname = models. charField (max_length = 48, blank = True, null = True) def _ unicode _ (self): return self. tagname # blog class Article (models. model): subject = models. charField (max_length = 50) summary = models. charField (max_length = 500) content = models. textField () created_dt = models. dateTimeField (auto_now_add = True, db_index = True) modify_dt = models. dateTimeField (auto_now = True, null = True, blank = True) article_type = models. foreignKey (Category) article_tag = models. manyToManyField (ArticleTag) writer = models. foreignKey (User) is_top = models. booleanField (default = False) num_like = models. positiveIntegerField (default = 0) num_click = models. positiveIntegerField (default = 0) def get_absolute_url (self): return reverse ('Article-detail', kwargs = {'pk': self. pk}) def _ unicode _ (self): return self. subject # Comment class Comment (models. model): content = models. textField () created_dt = models. dateTimeField (auto_now_add = True, db_index = True) user = models. foreignKey (User) article = models. foreignKey (Article) num_like = models. positiveIntegerField () num_dislike = models. positiveIntegerField () pid = models. foreignKey ('self ', blank = True, null = True, verbose_name = 'parent comment ')

 

1. Implement the user management function (Display User Information (userinfo), Change User Password (changepwd), and modify user information (changeuserinfo ))

Switch the display of different labels on a page:

1 <div id = "bodynav" class = "nav-tabs"> 2 <ul class = "nav-tabs" role = "tablist"> 3 <li role =" presentation "class =" active "> <a href =" # tab_userinfo "data-toggle =" tab "> User Information </a> </li> 4 <li role =" presentation "> <a href =" # tab_changepwd "data-toggle =" tab "> password modification </a> </li> 5 <li role =" presentation "> 

At the same time, different views are submitted for processing based on different forms.

Related Article

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.