Django Novice, currently on and off for one months Django, began to write a blog
Python 2.7.11 Django 1.10.2 Bootstrap 3.3.0 ide:eclipse Pydev
Models
#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)#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):returnSelf.username#Blog CategoriesclassCategory (models. Model): Name= Models. Charfield (max_length=64, Blank=true, null=True)def __unicode__(self):returnSelf.name#Blog TagsclassArticletag (models. Model): tagname= Models. Charfield (max_length=48, Blank=true, null=True)def __unicode__(self):returnSelf.tagname#Blogclassarticle (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)defGet_absolute_url (self):returnReverse'Article-detail', kwargs={'PK': self.pk}) def __unicode__(self):returnSelf.subject#ReviewsclassComment (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')
Implement user management functions (display user information (userinfo), modify user password (changepwd), modify user information (Changeuserinfo))
Change the display of different tabs under one page:
1 <DivID= "Bodynav"class= "Nav nav-tabs">2 <ulclass= "Nav nav-tabs"role= "Tablist">3 <Lirole= "Presentation"class= "Active"><ahref= "#tab_userinfo"Data-toggle= "tab">User Information</a></Li>4 <Lirole= "Presentation"><ahref= "#tab_changepwd"Data-toggle= "tab">Password modification</a></Li>5 <Lirole= "Presentation"><ahref= "#tab_changeuserinfo"Data-toggle= "tab">User Information Modification</a></Li>6 </ul>7 </Div>8 <!--What each tab page corresponds to - 9 <DivID= "Mytabcontent"class= "Tab-content"> Ten <Divclass= "Tab-pane fade in Active"ID= "Tab_userinfo"> One {{Userinfo.username}} A {{Userinfo.email}} - </Div> - the <Divclass= "Tab-pane Fade"ID= "Tab_changepwd"> - <formID= ' Changepwd 'Action= "/changepwd/"Method= "POST"> - <TableBorder=2> - {{changeform.as_table}} + </Table> - <inputtype= "Submit"name= ' Changepwd 'value= "Confirm" > + </form> A </Div> at - <Divclass= "Tab-pane Fade"ID= "Tab_changeuserinfo"> - <formID= ' Changeuserinfo 'Action= "/changeuserinfo/"Method= "POST"> - <TableBorder=2> - {{newuserinfo.as_table}} - </Table> in <inputtype= "Submit"name= ' Changeuserinfo 'value= "Confirm" > - </form> to </Div> + </Div>
At the same time, according to the different forms to submit different views processing
Django writes blog 1. A Web page, two form, submitted separately