Contact
8 | {% if success %} 9 | 10 |{{ success }}
11 | {% else %} 12 |13 | { If this form can not work, contact me at Facebook Chat }
├── blog ├── __init__.py ├── utils │ ├── __init__.py │ └── paginator.py ├── management │ ├── __init__.py │ └── commands │ │ ├── __init__.py │ │ └── autobackup.py ├── migrations │ ├── __init__.py │ ├── .gitignore │ └── 0001_initial.py ├── .gitignore ├── templatetags │ ├── __init__.py │ └── globaltags.py ├── apps.py ├── templates │ ├── robots.txt │ ├── blog │ │ ├── blog_search.html │ │ ├── blog_posts_tag.html │ │ ├── blog_posts_author.html │ │ ├── blog_contact.html │ │ ├── blog_sitemap.html │ │ ├── blog_page.html │ │ ├── blog_trending_posts.html │ │ ├── blog_home.html │ │ └── blog_detail.html │ ├── maintenance.html │ ├── includes │ │ ├── menu.html │ │ └── sidebar.html │ ├── error_page.html │ └── base.html ├── forms.py ├── feed.py ├── urls.py ├── admin.py ├── models.py └── views.py ├── blogproject ├── __init__.py ├── .gitignore ├── wsgi.py ├── urls.py └── settings.py ├── media ├── .gitignore └── gallery │ └── .gitignore ├── .gitignore ├── autobackupjsondb └── .gitignore ├── static ├── .gitignore └── assets │ ├── icons │ ├── avatar.jpeg │ ├── favicon.ico │ └── file-icon.png │ ├── images │ └── avatar.jpg │ ├── css │ ├── app.css │ ├── highlight.css │ ├── blog.css │ ├── style.css │ └── bootstrap-theme.min.css │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ └── js │ ├── docs.min.js │ └── bootstrap.min.js ├── __screenshot ├── 3_admin.png ├── 1_homepage.png ├── 2_detail_post.png ├── 4_admin_posts.png ├── 6_admin_gallery.png └── 5_admin_post_editor.png ├── requirements.txt ├── manage.py ├── CHANGELOG.md ├── README.md └── LICENSE /blog/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blogproject/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/management/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/* 2 | -------------------------------------------------------------------------------- /blog/templatetags/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /media/.gitignore: -------------------------------------------------------------------------------- 1 | covers/* 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | db.sqlite3 3 | -------------------------------------------------------------------------------- /autobackupjsondb/.gitignore: -------------------------------------------------------------------------------- 1 | [^.]* 2 | -------------------------------------------------------------------------------- /blog/management/commands/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blog/migrations/.gitignore: -------------------------------------------------------------------------------- 1 | [^.]* 2 | -------------------------------------------------------------------------------- /media/gallery/.gitignore: -------------------------------------------------------------------------------- 1 | [^.]* 2 | -------------------------------------------------------------------------------- /blogproject/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/* 2 | local_settings.py 3 | -------------------------------------------------------------------------------- /static/.gitignore: -------------------------------------------------------------------------------- 1 | admin/* 2 | cms/* 3 | redactor/* 4 | suit/* 5 | -------------------------------------------------------------------------------- /blog/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BlogConfig(AppConfig): 5 | name = 'blog' 6 | -------------------------------------------------------------------------------- /__screenshot/3_admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/__screenshot/3_admin.png -------------------------------------------------------------------------------- /__screenshot/1_homepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/__screenshot/1_homepage.png -------------------------------------------------------------------------------- /__screenshot/2_detail_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/__screenshot/2_detail_post.png -------------------------------------------------------------------------------- /__screenshot/4_admin_posts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/__screenshot/4_admin_posts.png -------------------------------------------------------------------------------- /__screenshot/6_admin_gallery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/__screenshot/6_admin_gallery.png -------------------------------------------------------------------------------- /blog/templates/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: Mediapartners-Google 2 | Disallow: 3 | 4 | User-agent: * 5 | Disallow: /search 6 | Allow: / 7 | -------------------------------------------------------------------------------- /static/assets/icons/avatar.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/static/assets/icons/avatar.jpeg -------------------------------------------------------------------------------- /static/assets/icons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/static/assets/icons/favicon.ico -------------------------------------------------------------------------------- /static/assets/images/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/static/assets/images/avatar.jpg -------------------------------------------------------------------------------- /static/assets/icons/file-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/static/assets/icons/file-icon.png -------------------------------------------------------------------------------- /__screenshot/5_admin_post_editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/__screenshot/5_admin_post_editor.png -------------------------------------------------------------------------------- /static/assets/css/app.css: -------------------------------------------------------------------------------- 1 | .tab-content { 2 | margin-top: 20px; 3 | } 4 | .tengah { 5 | text-align: center; 6 | } 7 | .card { 8 | margin-top: 20px; 9 | } -------------------------------------------------------------------------------- /static/assets/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/static/assets/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /static/assets/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/static/assets/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /static/assets/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/static/assets/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /static/assets/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agusmakmun/Django-Blog-Python-Learning/HEAD/static/assets/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Django==1.10.1 2 | django-disqus==0.5 3 | django-import-export==0.5.0 4 | django-nocaptcha-recaptcha==0.0.19 5 | django-suit==0.2.21 6 | django-wysiwyg-redactor==0.4.9.1 7 | mock==2.0.0 8 | pbr==1.10.0 9 | Pillow==3.3.1 10 | psycopg2==2.6.2 11 | pytz==2016.6.1 12 | six==1.10.0 13 | tablib==0.11.2 14 | -------------------------------------------------------------------------------- /blog/templates/blog/blog_search.html: -------------------------------------------------------------------------------- 1 | {% extends "blog/blog_home.html" %} 2 | {% block title %}Posts under query {{ query }} - {{ block.super }}{% endblock %} 3 | {% block canonical_url %}https://{{ request.get_host }}{% url 'search_posts_page' %}{% endblock %} 4 | {% block message_info_homepage %} 5 |
6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /blog/templates/blog/blog_posts_tag.html: -------------------------------------------------------------------------------- 1 | {% extends "blog/blog_home.html" %} 2 | {% block title %}Posts under tag {{ tag }} - {{ block.super }}{% endblock %} 3 | {% block canonical_url %}https://{{ request.get_host }}{% url 'tag_posts_page' slug=tag.slug %}{% endblock %} 4 | {% block message_info_homepage %} 5 | 6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /blog/templates/blog/blog_posts_author.html: -------------------------------------------------------------------------------- 1 | {% extends "blog/blog_home.html" %} 2 | {% block title %}Posts under author {{ author }} - {{ block.super }}{% endblock %} 3 | {% block canonical_url %}https://{{ request.get_host }}{% url 'author_posts_page' username=author.user.username %}{% endblock %} 4 | {% block message_info_homepage %} 5 | 6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /blogproject/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for blogproject project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blogproject.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /blog/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from nocaptcha_recaptcha.fields import NoReCaptchaField 3 | 4 | 5 | class ContactForm(forms.Form): 6 | cst = { 7 | 'class': 'form-control cst__radius', 8 | 'required': 'required' 9 | } 10 | email = forms.EmailField( 11 | required=True, 12 | widget=forms.TextInput(attrs=cst) 13 | ) 14 | subject = forms.CharField( 15 | required=True, 16 | widget=forms.TextInput(attrs=cst) 17 | ) 18 | message = forms.CharField( 19 | required=True, 20 | widget=forms.Textarea(attrs=cst) 21 | ) 22 | captcha = NoReCaptchaField() 23 | -------------------------------------------------------------------------------- /static/assets/css/highlight.css: -------------------------------------------------------------------------------- 1 | .hljs{display:block;background:white;padding:0.5em;color:#333333;overflow-x:auto} 2 | .hljs-comment,.hljs-meta{color:#969896} 3 | .hljs-string,.hljs-variable,.hljs-template-variable,.hljs-strong,.hljs-emphasis,.hljs-quote{color:#df5000} 4 | .hljs-keyword,.hljs-selector-tag,.hljs-type{color:#a71d5d} 5 | .hljs-literal,.hljs-symbol,.hljs-bullet,.hljs-attribute{color:#0086b3} 6 | .hljs-section,.hljs-name{color:#63a35c} 7 | .hljs-tag{color:#333333} 8 | .hljs-title,.hljs-attr,.hljs-selector-id,.hljs-selector-class,.hljs-selector-attr,.hljs-selector-pseudo{color:#3C5BDA} 9 | .hljs-addition{color:#55a532;background-color:#eaffea} 10 | .hljs-deletion{color:#bd2c00;background-color:#ffecec} 11 | .hljs-link{text-decoration:underline} 12 | -------------------------------------------------------------------------------- /blog/templates/maintenance.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always contact us, otherwise we’ll be back online shortly!
17 |— The Team
18 |No tags yet!
18 | {% endfor %} 19 | ''' 20 | 21 | 22 | @register.assignment_tag 23 | def populartags(): 24 | tags_queryset = Tag.objects.all() 25 | mapping = [ 26 | { 27 | 'tag': tag, 28 | 'total': Post.objects.published().filter(tags__slug=tag.slug).count() 29 | } for tag in tags_queryset 30 | ] 31 | mapping.sort(key=lambda x: int(x['total']), reverse=True) 32 | return mapping[:10] 33 | 34 | 35 | @register.assignment_tag 36 | def recentposts(): 37 | posts = Post.objects.published() 38 | return posts[:5] 39 | -------------------------------------------------------------------------------- /blog/templates/blog/blog_contact.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Contact - {{ block.super }}{% endblock %} 3 | {% block canonical_url %}https://{{ request.get_host }}{% url 'contact_page' %}{% endblock %} 4 | 5 | {% block content %} 6 |{{ success }}
11 | {% else %} 12 |Posts does not exist!
50 | {% endfor %} 51 | {% endblock %} 52 | -------------------------------------------------------------------------------- /blog/templates/includes/sidebar.html: -------------------------------------------------------------------------------- 1 | {% load disqus_tags %} 2 | {% load globaltags %} 3 | 11 | 12 | 20 | 21 | 30 | 31 | 35 | 36 | 45 | 46 | 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Django-Blog-Python-Learning 2 | ------- 3 | 4 | Release Source Code of Django Blog Python Learning v.3.8 5 | 6 | ### Demo: 7 | - [https://python.web.id](https://python.web.id) 8 | 9 | ### Technologies 10 | 11 | - Django 1.10 12 | - Python 3.5 13 | - Postgresql 14 | 15 | ### Features 16 | 17 | - Django Suit 18 | - Django Wysiwyg Redactor 19 | - Django disqus for comments. 20 | - Face 90% bootstrap. 21 | - Admin Site: User, Post, Page, Author, Tag & Gallery. 22 | - Pagination posts, Sitemap page, Search posts page, Display posts under tags, Display posts under Author. 23 | - Related posts 24 | - Next and previous for post. 25 | - sitemap.xml, feed 26 | - Contact form. 27 | - About author in the botom of posts. 28 | - Visitor Counter 29 | - Auto backup to the json file 30 | - Json post view 31 | - much more... 32 | 33 | ### Instalation 34 | 35 | I assume you already setup your django development with virtual enviroment (virtualenv). 36 | 37 | **1. Create virtual enviroment and activate it.** 38 | 39 | ``` 40 | $ virtualenv --python=/usr/bin/python3 yourenv 41 | $ source bin/activate 42 | ``` 43 | 44 | **2. Cloning this project** 45 | 46 | ``` 47 | $ git clone git@github.com:agusmakmun/Django-Blog-Python-Learning.git 48 | ``` 49 | 50 | **3. Install all requirements** 51 | 52 | > If you getting an error, `error: command 'i686-linux-gnu-gcc' failed with exit status 1` 53 | > please install first the python3-dev 54 | > using command `sudo apt-get install python3-dev` for all-deb, or use different method. 55 | > This probelm specialy for `pip3 install psycopg2`. 56 | > For more, please checkout this answer: http://stackoverflow.com/a/11094752/6396981 57 | 58 | ``` 59 | $ pip install -r requirements.txt 60 | ``` 61 | 62 | **4. Database migrations** 63 | 64 | ``` 65 | $ ./manage.py makemigrations 66 | $ ./manage.py migrate 67 | ``` 68 | 69 | **5. Run the server** 70 | 71 | ``` 72 | $ ./manage.py runserver 73 | ``` 74 | ------- 75 | 76 | ### Screenshot: 77 | 78 | #### Homepage 79 | 80 |  81 | 82 | #### Detail Post 83 | 84 |  85 | 86 | #### Admin Dashboard _(using django suit)_ 87 | 88 |  89 | 90 | #### All Posts on the Admin Dashboard & _Included Django Import Export_ 91 | 92 |  93 | 94 | #### Tags Filter and Redactor Editor 95 | 96 |  97 | 98 | #### Gallery File & Images 99 | 100 |  101 | 102 | ### Update and Commits 103 | 104 | - https://github.com/agusmakmun/Django-Blog-Python-Learning/commits/master 105 | 106 | ### Stack Problem 107 | 108 | - https://python.web.id/tag/django/ 109 | - https://github.com/agusmakmun/Some-Examples-of-Simple-Python-Script/tree/master/Django 110 | 111 | 112 | ### ChangeLog 113 | 114 | * [CHANGELOG](CHANGELOG.md) 115 | 116 | 117 | ### License 118 | 119 | * [GPL-2.0](LICENSE) 120 | -------------------------------------------------------------------------------- /static/assets/css/blog.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Globals 3 | */ 4 | 5 | body { 6 | /*font-family: Georgia, "Times New Roman", Times, serif;*/ 7 | color: #555; 8 | } 9 | 10 | h1, .h1, 11 | h2, .h2, 12 | h3, .h3, 13 | h4, .h4, 14 | h5, .h5, 15 | h6, .h6 { 16 | margin-top: 0; 17 | /*font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;*/ 18 | font-weight: normal; 19 | color: #333; 20 | } 21 | 22 | 23 | /* 24 | * Override Bootstrap's default container. 25 | 26 | 27 | @media (min-width: 1200px) { 28 | .container { 29 | width: 970px; 30 | } 31 | } 32 | */ 33 | 34 | /* 35 | * Masthead for nav 36 | */ 37 | 38 | .blog-masthead { 39 | background-color: #428bca; 40 | -webkit-box-shadow: inset 0 -2px 5px rgba(0,0,0,.1); 41 | box-shadow: inset 0 -2px 5px rgba(0,0,0,.1); 42 | } 43 | 44 | /* Nav links */ 45 | .blog-nav-item { 46 | position: relative; 47 | display: inline-block; 48 | padding: 10px; 49 | font-weight: 500; 50 | color: #cdddeb; 51 | } 52 | .blog-nav-item:hover, 53 | .blog-nav-item:focus { 54 | color: #fff; 55 | text-decoration: none; 56 | } 57 | 58 | /* Active state gets a caret at the bottom */ 59 | .blog-nav .active { 60 | color: #fff; 61 | } 62 | .blog-nav .active:after { 63 | position: absolute; 64 | bottom: 0; 65 | left: 50%; 66 | width: 0; 67 | height: 0; 68 | margin-left: -5px; 69 | vertical-align: middle; 70 | content: " "; 71 | border-right: 5px solid transparent; 72 | border-bottom: 5px solid; 73 | border-left: 5px solid transparent; 74 | } 75 | 76 | 77 | /* 78 | * Blog name and description 79 | */ 80 | 81 | /*.blog-header { 82 | padding-top: 20px; 83 | padding-bottom: 20px; 84 | }*/ 85 | .blog-title { 86 | margin-top: 30px; 87 | margin-bottom: 0; 88 | /* font-size: 60px; */ 89 | font-weight: normal; 90 | } 91 | .blog-description { 92 | font-size: 20px; 93 | color: #999; 94 | } 95 | 96 | .related { 97 | margin-top: 2em; 98 | } 99 | /* 100 | * Main column and sidebar layout 101 | */ 102 | 103 | .blog-main { 104 | /* font-size: 18px; */ 105 | line-height: 1.5; 106 | } 107 | 108 | /* Sidebar modules for boxing content */ 109 | .sidebar-module { 110 | padding: 15px; 111 | margin: 0 -15px 15px; 112 | } 113 | .sidebar-module-inset { 114 | padding: 15px; 115 | background-color: #f5f5f5; 116 | border-radius: 4px; 117 | } 118 | .sidebar-module-inset p:last-child, 119 | .sidebar-module-inset ul:last-child, 120 | .sidebar-module-inset ol:last-child { 121 | margin-bottom: 0; 122 | } 123 | 124 | 125 | 126 | /* Pagination */ 127 | .pager { 128 | /*margin-bottom: 60px;*/ 129 | text-align: left; 130 | } 131 | .pager > li > a { 132 | width: 140px; 133 | padding: 10px 20px; 134 | text-align: center; 135 | border-radius: 30px; 136 | } 137 | 138 | 139 | /* 140 | * Blog posts 141 | */ 142 | 143 | .post { 144 | margin-bottom: 25px; 145 | overflow-x: hidden; 146 | } 147 | div.post h2:first-child { 148 | margin-bottom: 5px; 149 | /*font-size: 40px;*/ 150 | font-size: 20px; 151 | } 152 | div.post h2:first-child a:hover { 153 | text-decoration: none; 154 | } 155 | .meta { 156 | margin-bottom: 20px; 157 | color: #999; 158 | } 159 | 160 | 161 | /* 162 | * Footer 163 | */ 164 | 165 | .blog-footer { 166 | padding: 40px 0; 167 | color: #999; 168 | text-align: center; 169 | background-color: #f9f9f9; 170 | border-top: 1px solid #e5e5e5; 171 | } 172 | .blog-footer p:last-child { 173 | margin-bottom: 0; 174 | } 175 | -------------------------------------------------------------------------------- /blog/utils/paginator.py: -------------------------------------------------------------------------------- 1 | from django.core.paginator import (Paginator, EmptyPage, PageNotAnInteger) 2 | 3 | 4 | class GenericPaginator(object): 5 | """ 6 | Custom dinamic paginations for all views bassed in `generic.ListView` 7 | 8 | 1. app/views.py 9 | context_data['page_range'] = GenericPaginator( 10 | self.get_queryset(), 11 | self.paginate_by, 12 | self.request.GET.get('page') 13 | ).get_page_range() 14 | 15 | 2. app/templates/name.html 16 | {% block pagination %} 17 | {% if is_paginated %}{# `is_paginated` is default bassed in `generic.ListView` #} 18 |19 | Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. 20 |
21 |Posts does not exist!
35 | {% endfor %} 36 | 37 | {% if is_paginated %} 38 | {% if request.GET.q %} 39 |145 | You have an error {{ message }}. 146 |
147 |48 | {% if object.cover %} 49 |