Posts under tag: "Database"

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 →

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 →

How to implement Django Internationalization

By: summonagus ● at Nov. 17, 2016, 8:27 p.m. ● Posted under: #Tricks, #Solution, #Project, #Django, #Module, #Settings, #Database, #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 →

Step by step how to use multiple databases with database routers in Django

By: summonagus ● at Oct. 26, 2016, 11:29 p.m. ● Posted under: #Project, #Django, #APP, #Settings, #Database, #Problem, #Tricks, #Solution, #SSO, #Multi Databases

1. Please create a new superuser for the second/default/current database. Because you will getting this issue that i already asked before: https://gitter.im/django/django?at=5810b0b5806316005dc11f46 i use multiple site, multiple env, multiple project, multiple database. and found this error message if use DATABASE_ROUTERS. insert or update on table "django_admin_log" violates foreign key constraint ...

Read More →

How to implement the ForeignKey for multi databases Django

By: summonagus ● at Oct. 23, 2016, 6:12 a.m. ● Posted under: #Tricks, #Solution, #Project, #Django, #APP, #Database, #Problem, #SSO, #Multi Databases, #Ajax

Previously i had confused how to handle this problem, this problem also already asked by someone on stackoverflow (Cross Database foreign key error) and has the best answered by someone http://stackoverflow.com/a/23273703/6396981 with quote: If you have used a router to partition models to different databases, any foreign key and many-to-many ...

Read More →

Django Blog Python Learning released v.3.6 with feature autobackup

By: summonagus ● at Oct. 4, 2016, 9:28 a.m. ● Posted under: #Problem, #Database, #APP, #Django, #News, #Project

Previously, the Django already has a method to backup the database to the json file with quick command: $ ./manage.py dumpdata --format=json > outfile.json Yup, with dumpdata. But why this "Django Blog Python Learning" not use it? We need to explore and use another method, so we know what we ...

Read More →

How to make cronjob for Django in Hosting, VPS or Server

By: summonagus ● at Oct. 2, 2016, 5:23 p.m. ● Posted under: #Tricks, #Database, #Django, #Project, #Solution

How to make cronjob for Django in Hosing, VPS or Server. This config also what we do in this site. For example, in your file of /yourproject/yourapp/management/commands/autobackup.py from django.core.management.base import BaseCommand, CommandError class Command(BaseCommand): help = 'To backup your app!' def add_arguments(self, parser): parser.add_argument( 'backup', help='To backup your app!' ) ...

Read More →

E11000 duplicate key error index in mongodb

By: summonagus ● at Oct. 2, 2016, 4:55 p.m. ● Posted under: #Problem, #Database, #Flask, #Solution

E11000 duplicate key error index in mongodb. I found this error after migrating my field from "unique" to "non-unique". And in this problem we use mongoengine for flask. First, i have a model such as bellow class Tag(db.Document): title = db.StringField(max_length=50, unique=True) and then, i need to change it without ...

Read More →

Backup and Restore database Postgres Django in terminal ssh

By: summonagus ● at Oct. 2, 2016, 8:13 a.m. ● Posted under: #Database, #Django, #Project

Backup and Restore database Postgres Django in terminal ssh. Bismillahirrahmanirrahim, malam hari ini kita akan berbagi sedikit tutorial yang diambil dari dokumentasi saya pribadi mengenai problem solved backup and restore database postgres django, yaitu tepatnya ketika sudah dalam keadaan di hosting. Beberapa tutorial telah dicoba satu-satu, dan alhamdulillah masih gagal, lalu ...

Read More →