How do we add custom MANAGER in Django

By: renjithsraj ● Nov. 23, 2017, 2:16 a.m. ● Tags: #Django

Django Custom ManagersA Manager is used to query database operations which will be provided to Django models. Every model in Django application consists at least one Manager by default.Regarding the Manager names:By default, Django adds a Manager with the name "objects" to every model class. However, if you want to ...

Read More →

How to Backup And Restore your databases

By: renjithsraj ● Nov. 21, 2017, 1:33 p.m. ● Tags: #Python3, #Databases

In this post we going to explain you how to backup and restore our databases, commonly using databases are follows,MySQLPostGresSQlMongoDBWhy we Need Backup scripts ?In the production environments, data loss when we accidentally delete the files, or when server crashes or system fails, or when we applied migrations to the ...

Read More →

How to Deploy Django Applications on Heroku

By: renjithsraj ● Nov. 20, 2017, 11:54 p.m. ● Tags: #Django, #Hosting Service

Heroku is a cloud application platform, it is basically a Platform-as-a-Service (PaaS). They support several programming languages, including Python. It is very easy to deploy Django applications on Heroku. They also offer a free plan, which is quite limited, but it is great to get started and to host demos ...

Read More →

How to prevent multiple users login using the same credentials

By: Akhil ● Nov. 19, 2017, 9:23 p.m. ● Tags: #Django, #Python2

Let's discuss about how to prevent multiple user login using django application. In order to implement this I am writing custom middleware class. First we need to create a model to save the user and user session key.class Visitor(models.Model): pupil = models.OneToOneField(User, null=False) session_key = models.CharField(null=False, max_length=40)What is middlewareMiddlewares are ...

Read More →

Best Practise for Django development

By: renjithsraj ● Nov. 19, 2017, 5:21 p.m. ● Tags: #Django

Django is a robust, open-source, Python-based framework for building web applications. Its popularity has increased during the last couple of years, and it is already mature and widely-used with a large community behind it.Among other Python-based frameworks for creating web applications (like Flask and Pyramid), Django is by far the ...

Read More →

How to create management commands in Django

By: renjithsraj ● Nov. 18, 2017, 10:44 p.m. ● Tags: #Django

You must have used createsuperuser command in your django application at one or other time. If not then I am sure you must have used makemigrations or migrate commands in your project.Eg. for Django builtin management commands 1. Python manage.py createsuperuser 2. Python manage.py migrate 3. Python manage.py startappSo these ...

Read More →

How to use AJAX with Django

By: renjithsraj ● Nov. 18, 2017, 12:43 a.m. ● Tags: #Web Design, #Django, #Python3

AJAX is an acronym for Asynchronous JavaScript and XML. It is a group of inter-related technologies like JavaScript, DOM, XML, HTML, CSS etc. AJAX allows you to send and receive data asynchronously without reloading the web page. At some point in your project development process you will need AJAX to ...

Read More →

Django compress image before saving

By: renjithsraj ● Nov. 17, 2017, 7:25 a.m. ● Tags: #Django

This post going to explore you, How we can compress the images before saving in the disk in Django applications, please find below snippets.from PIL import Image as Img import StringIO class Images(models.Model): image = models.ImageField() def save(self, *args, **kwargs): if self.image: img = Img.open(StringIO.StringIO(self.image.read())) if img.mode != 'RGB': img ...

Read More →

Django 2.0 release candidate 1 released

By: renjithsraj ● Nov. 16, 2017, 9:51 a.m. ● Tags: #django news & events

Tim Graham posted in the Django official website, Django 2.release candidate 1 is the final opportunity for you to try out the assortment of new features before Django 2.0 is released.The release candidate stage marks the string freeze and the call for translators to submit translations. Provided no major bugs ...

Read More →

S3 Static & Media Files for Django

By: renjithsraj ● Nov. 16, 2017, 12:24 a.m. ● Tags: #Django, #Python3, #Hosting Service

1. create AWS account : here2. Create AWS User credentialsNavigate to IAM UsersSelect Create New UsersEnter awsbean as a user name (or whatever you prefer)Ensure Programmatic Access is selected, hit Next.Select Download credentials and keep them safe.Open the credentials.csv file that was just downloaded/createdNote the Access Key Id and Secret ...

Read More →