Skip to content
This repository was archived by the owner on May 23, 2020. It is now read-only.

Commit 6d4594a

Browse files
committed
Fixed some issue before release v3.5
1 parent 6c8638d commit 6d4594a

File tree

10 files changed

+43
-12
lines changed

10 files changed

+43
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Added Page for tranding posts by visit.
1010
* Added Feature export and import using [Django Import Export](https://github.com/django-import-export/django-import-export)
1111
* Changed Gallery Upload to only once attachment field.
12-
* Added custom template for Error page, and much more...
12+
* Added custom template for Error page, Maintenance mode, and much more...
1313

1414
### v.3.4
1515

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $ git clone [email protected]:agusmakmun/Django-Blog-Python-Learning.git
4444
> If you getting an error, `error: command 'i686-linux-gnu-gcc' failed with exit status 1`
4545
> please install first the python3-dev
4646
> using command `sudo apt-get install python3-dev` for all-deb, or use different method.
47-
> This probelm specialy for `pip3 install psycopg2`
47+
> This probelm specialy for `pip3 install psycopg2`.
4848
> For more, please checkout this answer: http://stackoverflow.com/a/11094752/6396981
4949
5050
```
@@ -108,4 +108,4 @@ $ ./manage.py runserver
108108

109109
### License
110110

111-
* [MIT](LICENSE)
111+
* [GPL-2.0](LICENSE)

blog/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.utils.translation import ugettext_lazy as _
66
from django.utils.text import capfirst
77

8-
# Integrating model `Post` to can import and export the data.
8+
# Integrating the model to can import and export the data via admin dashboard.
99
# See this docs: https://goo.gl/QR3Qqp
1010
from import_export import resources
1111
from import_export.admin import ImportExportModelAdmin

blog/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __str__(self):
4444

4545
@property
4646
def get_total_posts(self):
47-
return Packet.objects.filter(tags__pk=self.pk).count()
47+
return Post.objects.filter(tags__pk=self.pk).count()
4848

4949
class Meta:
5050
verbose_name = 'Detail Tag'

blog/templates/includes/menu.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<li><a href="{% url 'contact_page' %}">Contact</a></li>
2121
<li><a href="/resource/">Resource</a></li>
2222
<li><a href="{% url 'sitemap_page' %}">Sitemap</a></li>
23-
<li><a href="/trending/">Trending</a></li>
23+
<li><a href="{% url 'trending_posts_page' %}">Trending</a></li>
2424
<li>
2525
<a class="btn btn-default btn-outline btn-circle collapsed cst__btn__search__outline" data-toggle="collapse" href="#nav-collapse3" aria-expanded="false" aria-controls="nav-collapse3">Search</a>
2626
</li>

blog/templates/maintenance.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<title>Python Learning</title>
4+
<style>
5+
body { text-align: center; padding: 150px; }
6+
h1 { font-size: 50px; }
7+
body { font: 20px Helvetica, sans-serif; color: #333; }
8+
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
9+
a { color: #dc8100; text-decoration: none; }
10+
a:hover { color: #333; text-decoration: none; }
11+
</style>
12+
13+
<article>
14+
<h1>We&rsquo;ll be back soon!</h1>
15+
<div>
16+
<p>Sorry for the inconvenience but we&rsquo;re performing some maintenance at the moment. If you need to you can always <a href="mailto:#">contact us</a>, otherwise we&rsquo;ll be back online shortly!</p>
17+
<p>&mdash; The Team</p>
18+
</div>
19+
</article>
20+
</html>

blog/templatetags/globaltags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ def populartags():
3535
@register.assignment_tag
3636
def recentposts():
3737
posts = Post.objects.published()
38-
return posts
38+
return posts[:5]

blog/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
# thanks to: http://stackoverflow.com/a/30271379/6396981
2020

2121
urlpatterns = [
22+
# Handler for Maintenance mode.
23+
# url(r'^$', TemplateView.as_view(template_name='maintenance.html', content_type='text/html')),
24+
2225
url(r'^$', HomepageView.as_view(), name='homepage'),
2326
url(r'^blog/(?P<slug>[\w\-]+)/$', DetailPostView.as_view(), name='detail_post_page'),
2427
url(r'^search/$', SearchPostsView.as_view(), name='search_posts_page'),

blog/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def handler500(request):
4646
class HomepageView(generic.ListView):
4747
queryset = Post.objects.published()
4848
template_name = 'blog/blog_home.html'
49-
paginate_by = 7
49+
paginate_by = 10
5050

5151
def get_context_data(self, **kwargs):
5252
context_data = super(HomepageView, self).get_context_data(**kwargs)
@@ -77,7 +77,7 @@ def visitorCounter(self):
7777
dns = str(socket.getfqdn(self.request.META['REMOTE_ADDR'])).split('.')[-1]
7878
try:
7979
# trying for localhost: str(dns) == 'localhost',
80-
# trying for productions: int(dns)
80+
# trying for production: int(dns)
8181
if str(dns) == 'localhost':
8282
visitor = Visitor(
8383
post=self.object,

blogproject/settings.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@
123123
}
124124
"""
125125

126+
# Config with postgresql - psql (9.5.4, server 9.3.14)
127+
# $ sudo su - postgres
128+
# $ psql
129+
# postgres=# CREATE DATABASE database_nme;
130+
# postgres=# CREATE USER database_user WITH PASSWORD 'password_user';
131+
# postgres=# GRANT ALL PRIVILEGES ON DATABASE database_nme TO database_user;
132+
# See this docs for more; https://goo.gl/9ONJKX
133+
126134
DATABASES = {
127135
'default': {
128136
'ENGINE': 'django.db.backends.postgresql_psycopg2',
@@ -168,14 +176,14 @@
168176
# https://docs.djangoproject.com/en/1.9/howto/static-files/
169177
STATICFILES_DIRS = (
170178
os.path.join(BASE_DIR, "static"),
171-
'/home/path/to/yourenv/blogproject/static',
179+
'/path/to/yourenv/blogproject/static',
172180
)
173181

174182
STATIC_URL = '/static/'
175-
#STATIC_ROOT = '/home/path/to/yourenv/blogproject/static'
183+
#STATIC_ROOT = '/path/to/yourenv/blogproject/static'
176184

177185
MEDIA_URL = '/media/'
178-
MEDIA_ROOT = '/home/path/to/yourenv/blogproject/media'
186+
MEDIA_ROOT = '/path/to/yourenv/blogproject/media'
179187

180188
# Editor Redactor
181189
import time

0 commit comments

Comments
 (0)