-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blog pages added #70
base: master
Are you sure you want to change the base?
blog pages added #70
Conversation
Hi @Namrata7199, Please don't add files from |
Hi @Namrata7199 , |
e0871a4
to
1700773
Compare
I reset the last commit and added the files again |
Hi @Namrata7199 , |
src/website/models.py
Outdated
|
||
@python_2_unicode_compatible | ||
class Articles(models.Model): | ||
page=models.IntegerField(default=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to have a CHOICE_TYPE rather than integer page numbers?
OK... I'll try changing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits on coding style.
@@ -123,18 +123,19 @@ class Author(models.Model): | |||
blurb = MarkdownField() | |||
|
|||
def __str__(self): | |||
return self.name | |||
return self.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Follow 4 space indents to match the rest of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
||
def __str__(self): | ||
return self.title | ||
TYPE_OF_BLOG=[(1,'travel'),(2,'fineprint'),(3,'literarypage'),(4,'techpost')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Try and put spaces between operators and space out these long lists when possible! Something like the following looks nicer and is easier to add on to in the future.
TYPE_OF_BLOG = [
(1, 'travel'),
(2, 'fineprint'),
(3, 'literarypage'),
(4, 'techpost')
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
def __str__(self): | ||
return self.title | ||
TYPE_OF_BLOG=[(1,'travel'),(2,'fineprint'),(3,'literarypage'),(4,'techpost')] | ||
page=models.IntegerField(default=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: page = mo...
page=models.IntegerField(default=0) | ||
title = models.CharField(max_length=200) | ||
author = models.ForeignKey(Author) | ||
article_pic = models.ImageField(upload_to='article_pics/%Y-%m-%d/',null=True,blank=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: , null = True, blank = True
spaces and maybe break this into multiple lines?
@@ -10,8 +10,11 @@ | |||
url(r'^announce/(?P<id>[0-9]+)/$', views.announcement, name='eachAnnouncement'), | |||
url(r'^contacts/',views.ContactNumbers.as_view(),name='contacts'), | |||
url(r'^nitk_life/', views.NitkLifePage.as_view(), name='nitk_life'), | |||
url(r'^blog/$', views.blogPage, name='blogs'), | |||
url(r'^blog/(?P<num>[0-9]+)/$', views.blogPage, name='eachBlog'), | |||
# url(r'^(P<pagename>["travel"])/$', views.blogPage, name='travel'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments needed?
articles = Articles.objects.all().order_by('-published') | ||
return render(request,'blog.html',{'article':articles}) | ||
|
||
def blogPage(request,pagename="blog"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing - request, p
return render(request,'blog.html',{'article':articles}) | ||
|
||
def blogPage(request,pagename="blog"): | ||
blogtype = pagename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the default page showing all blogs.
|
||
def blogPage(request,pagename="blog"): | ||
blogtype = pagename | ||
if pagename=="travel": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacing nits
articles = Articles.objects.all().order_by('-published') | ||
return render(request,'blog.html',{'article':articles , 'blogtype' : blogtype}) | ||
|
||
def blogIndex(request,num): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacing nits
|
||
def blogIndex(request,num): | ||
article=Articles.objects.get(id=num) | ||
return render(request,'article.html',{'article':article}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add another line below this
No description provided.