Django query to group records with created field

By: summonagus ● at Feb. 9, 2017, 11:53 p.m. ● Posted under: #Problem, #Django, #Solution

Hello guys, this night I want to share a simply tutorial how to querying the objects to group records with created field. This case is what already aksed by someone at stackoverflow.And the question is; in the models.py class Post(models.Model): caption = models.CharField(max_lenght=200) description = models.TextField() created = models.DateTimeField(auto_now_add=True) modified ...

Read More →

Fixed DNS PROBE on Ubuntu

By: summonagus ● at Jan. 22, 2017, 10:32 a.m. ● Posted under: #Problem, #Internet, #Solution

These errors indicate that there is some problem with DNS. check cat /etc/resolv.conf for your DNS settings. And add following name server in /etc/resolv.conf for temporary or in /etc/resolvconf/resolv.conf.d/head for permanent nameserver 8.8.8.8 nameserver 8.8.4.4 To add these two name server address in resolv.conf run command sudo gedit /etc/resolv.conf Copy ...

Read More →

Django: Custom safe excludes from dangerous XSS Injection

By: summonagus ● at Jan. 3, 2017, 7:44 a.m. ● Posted under: #Tricks, #Templates, #Problem, #Django, #Security, #Solution

Django Custom safe excludes from dangerous XSS Injection. Answered from: http://stackoverflow.com/a/41434870/6396981 from bs4 import BeautifulSoup from django import template from django.utils.html import escape register = template.Library() INVALID_TAGS = ['script', 'style'] def clean_html(value): soup = BeautifulSoup(value) for tag in soup.findAll(True): if tag.name in INVALID_TAGS: #tag.hidden = True # you also can ...

Read More →

DracEditor - Django Markdown Editor built for Dracos Linux

By: summonagus ● at Jan. 1, 2017, 9:18 p.m. ● Posted under: #Module, #APP, #Django, #Project

DracEditor - Django Markdown Editor built for Dracos Linux. Few days ago i created package django markdown editor. I created this plugin specially to handle the new forum of Dracos Linux. Demo Video: https://youtu.be/DZCZD7Y8P0YFeatures Integrated with Ace Editor Integrated with Semantic-UI Live Preview Upload Image to imgur.com (via API) Emoji ...

Read More →

Top 10 Python libraries of 2016

By: summonagus ● at Dec. 24, 2016, 10:31 a.m. ● Posted under: #Module, #News, #Project

Last year, we did a recap with what we thought were the best Python libraries of 2015, which was widely shared within the Python community (see post inr/Python). A year has gone by, and again it is time to give due credit for the awesome work that has been done ...

Read More →

How to custom html choose image upload for django markdownx

By: summonagus ● at Dec. 19, 2016, 9:38 p.m. ● Posted under: #Tricks, #Templates, #Problem, #Django, #Solution, #Ajax

Django markdownx is a Markdown editor built for Django https://github.com/adi-/django-markdownx Previously i already created isssue before: https://github.com/adi-/django-markdownx/issues/36, as the owner says: There is no easy way to do it "quick", I think. You could change JS script a bit to be able to send images. This should be a simple ...

Read More →

Command to handle deploy Django with quickly

By: summonagus ● at Dec. 19, 2016, 5:44 a.m. ● Posted under: #Tricks, #Database, #Django, #Solution

Hello guys, this morning i want to share simply how to custom command to handle deploy Django with quickly. ./manage.py deploy --yes <username> <password> <email> ./manage.py deploy --yes --username=myusername --password=mypassword Let see, the `email` has default empty string, so you can fill with your email or just passed it.For example, ...

Read More →

Djipsum already in new version 1.0.9

By: summonagus ● at Dec. 2, 2016, 4:56 a.m. ● Posted under: #Module, #APP, #Django, #News

Djipsum already in new version 1.0.9. Djipsum is awesome command plugin to generate fake content for Django. What news? Fixed ManyToManyField (return the random objects from many to many field). Fixed ForeignKey Field (return the random object from foreign field). Install:$ pip install djipsum I never test this tool with ...

Read More →

Understanding @user_passes_test Django

By: summonagus ● at Nov. 28, 2016, 10:05 p.m. ● Posted under: #Tricks, #Problem, #Django, #Security, #Solution

Django decorator has a function to manage the user, once of it is user_passes_test. But, in my implementation i found this problem: ERR_TOO_MANY_REDIRECTS, or 'AnonymousUser' object is not iterable. I need to custom the user by instancing from user models, for example: from django.db import models from django.contrib.auth.models import User ...

Read More →

How to implement Django Internationalization

By: summonagus ● at Nov. 17, 2016, 8:27 p.m. ● Posted under: #Tricks, #Database, #Settings, #Module, #Django, #Project, #Solution, #Internationalization, #Multi Languages

Django is real fucking awesome, this morning i want to share a basic tutorial how to implement the django internationalization with GeoIP. Of course this tutorial if you need to make a site with multiple languages. Default django already integrated with common / modern translation system. as the docs warning ...

Read More →