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.