Auto rename file after uploaded

By: summonagus ● at Aug. 5, 2017, 8:24 a.m. ● Posted under: #Django, #Tricks, #Solution, #Problem

Django Auto rename file after uploaded. This method to handle duplicated files in same times. This snippet below is how to do that;import os, time, uuid from django.db import models from django.utils.deconstruct import deconstructible class ImageUploader(models.Model): @deconstructible class PathAndRename(object): def __init__(self, sub_path): self.path = sub_path def __call__(self, instance, filename): # ...

Read More →

Deploying Django Project at Pythonanywhere

By: summonagus ● at July 21, 2017, 6:46 p.m. ● Posted under: #Django, #APP, #Project, #News

PythonAnywhere is an online Integrated Development Environment (IDE) and Web hosting service based on the Python programming language. It provides in-browser access to server-based Python and Bash Command-line interfaces, along with a code editor with Syntax highlighting. Program files can be transferred to and from the service using the user's ...

Read More →

Fixed CommandError: Unable to find a locale path to store translations for file __init__.py

By: summonagus ● at Feb. 27, 2017, 12:04 p.m. ● Posted under: #Solution, #Django, #Internationalization, #Multi Languages, #Settings, #Problem

Hello guys, this day I want to share a simply tutorial how to fix CommandError: Unable to find a locale path to store translations for file <app_name>/__init__.py for Django 1.10 In my previous LOCALE_PATHS inside file of settings.py is like this: LOCALE_PATHS = ( os.path.join(BASE_DIR, 'projectname/locale'), ) This should an ...

Read More →

Django query to group records with created field

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

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: #Internet, #Solution, #Problem

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: #Templates, #Tricks, #Security, #Solution, #Django, #Problem

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: #Django, #APP, #Module, #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, #Project, #News

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: #Templates, #Tricks, #Solution, #Django, #Ajax, #Problem

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: #Django, #Tricks, #Solution, #Database

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 →