Posts under tag: "Django"

Good bye DracEditor, welcome Martor

By: summonagus ● at Sept. 23, 2017, 6:42 a.m. ● Posted under: #Django, #APP, #Module, #Project, #News

Martor is Markdown Editor plugin for Django and new face of DracEditor. 1. DracEditorPreviously we found serious problem, as @gomezjdaniel reported where "Markdown widget becomes unresponsive when a model has multiple DraceditorField", thank for reported this issue. 2. MartorWhat news? New face from two sides into tabs Support Multiple Fields ...

Read More →

How to Implement a notification system in Django

By: summonagus ● at Sept. 16, 2017, 6:54 a.m. ● Posted under: #Django, #Tricks, #Solution

I suggest you to use ContentType to make a dynamic notifications fo any models. This snippet below is an example how to implement the notification system;1. in your models.pyfrom django.db import models from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey from django.utils.translation import ugettext_lazy as _ ...

Read More →

Rename app name in django admin

By: summonagus ● at Sept. 14, 2017, 5:45 a.m. ● Posted under: #Django, #Tricks, #Solution, #APP

Prior to Django 1.7 You can give your application a custom name by defining app_label in your model definition. But as django builds the admin page it will hash models by their app_label, so if you want them to appear in one application, you have to define this name in ...

Read More →

Automatic asset versioning in Django

By: summonagus ● at Sept. 6, 2017, 7:36 p.m. ● Posted under: #Django, #Tricks, #Solution, #Project, #Performance

Following on from Ed's "Automatic versioning of CSS, JavaScript and Images" here is a method to version filenames based on modification times to be used in Django as a template tag.This is really handy technique for when you set expires headers to a long way into the future. With headers ...

Read More →

Optimizing Django ORM Queries for Best Performance

By: summonagus ● at Aug. 25, 2017, 9:34 p.m. ● Posted under: #Django, #Tricks, #Solution, #Database, #Problem

Django framework already comes with lot of ORM (Object Relational Mapping) functionalities. Once the models are created, you can create, update, retrieve and delete objects using its database abstraction api. Any changes in the models can also be handled using migrations which is pretty awesome. Making queries in django is ...

Read More →

Django Count Online Users

By: summonagus ● at Aug. 5, 2017, 4:13 p.m. ● Posted under: #Templates, #Tricks, #Django

Create file where location of is saved, eg: projectname/projectname/ projectname/projectname/ projectname/projectname/ Then following this lines; from django.core.cache import cache from django.conf import settings from django.contrib.auth.models import User from django.utils.deprecation import MiddlewareMixin ONLINE_THRESHOLD = getattr(settings, 'ONLINE_THRESHOLD', 60 * 15) ONLINE_MAX = getattr(settings, 'ONLINE_MAX', 50) def get_online_now(self): return User.objects.filter(id__in=self.online_now_ids or ...

Read More →

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

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>/ for Django 1.10 In my previous LOCALE_PATHS inside file of 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 class Post(models.Model): caption = models.CharField(max_lenght=200) description = models.TextField() created = models.DateTimeField(auto_now_add=True) modified ...

Read More →