<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: D</title>
    <description>The latest articles on DEV Community by D (@dj221ai).</description>
    <link>https://dev.to/dj221ai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F447165%2F4a8783e0-74f5-44cf-b929-f17711be862a.jpg</url>
      <title>DEV Community: D</title>
      <link>https://dev.to/dj221ai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dj221ai"/>
    <language>en</language>
    <item>
      <title>The Art of Learning</title>
      <dc:creator>D</dc:creator>
      <pubDate>Sun, 30 Aug 2020 17:52:57 +0000</pubDate>
      <link>https://dev.to/dj221ai/the-art-of-learning-1kdo</link>
      <guid>https://dev.to/dj221ai/the-art-of-learning-1kdo</guid>
      <description>&lt;p&gt;&lt;strong&gt;Disclaimer :- The post is bit big&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the world of programming there are lots of languages like java, python, c++ etc, concepts like Data structures, Algorithms, Databases with frameworks like Django, React, Vue, Flask, spring and many more uncountable things are there. This field demand us to learn more than one language or framework and we go towards it.&lt;br&gt;
we try to learn the things as quick as possible. we want to see our self making the things quickly. so we start learning through tutorials, books or articles whatever is convenient.&lt;br&gt;
And we go on learning from one topic to another, than another than another and the loop continues. But while doing so sometimes (in case of newbies many of the times) we forget that we clearly need to understand the topic not only understand but to practice also and we continue to move from one topic to another.&lt;br&gt;
After finishing the topics we wanted to learn, when we turn back or we go for the interview, we see that we lack the understanding of many concepts. we intend to think that we need to start over and in many cases we have to start over, and this loop continues until and unless we really come to know the things and this in most cases make us an under confident person. &lt;br&gt;
&lt;strong&gt;So how to Overcome it&lt;/strong&gt;&lt;br&gt;
Most of us have heard about the &lt;strong&gt;&lt;em&gt;The Art of Learning&lt;/em&gt;&lt;/strong&gt; book. In this book the author has taken the &lt;strong&gt;depth first approach&lt;/strong&gt; instead of &lt;strong&gt;breadth first&lt;/strong&gt;. &lt;br&gt;
The author has mastered two skills through this approach(chess and Tai-chi) and it takes lots of effort, determination and consistency. &lt;br&gt;
We also can use this &lt;em&gt;depth&lt;/em&gt; approach to understand the programming concepts at a very deep level and then we can move to another concepts once we are comfortable with the current technology. &lt;br&gt;
Suppose we start leaning a framework like Django, so then how we can &lt;strong&gt;proceed&lt;/strong&gt;? When author was learning chess he used to practice almost every &lt;strong&gt;possible moves&lt;/strong&gt; through each &lt;strong&gt;piece&lt;/strong&gt;. In the same way we can try many different moves with each technology (in this case Django) like creating the login-registration page or some other crud application. And when you do certain projects than you start to develop the habit of thinking the big picture with small steps. In this way by creating several projects on your own, you will drill yourself more and can reach to the level where you know many of the things. With time the more projects you do the better you become, but remember doing every project in the same way won't let you drill yourself much, instead try to take different approaches, through that you can learn the most efficient ways to do the things. When you are comfortable with that specific concepts than you should move towards other technology whatever you wishes to learn. The same thing can be done in learning everything whether programming or sports or some other thing.&lt;br&gt;
The key is to be consistent and have patience while learning instead of rushing. Try to focus on depth instead of just learning everything in short span, even if you have less time. &lt;/p&gt;

&lt;p&gt;Note:- Just going through tutorials and doing the things in  project that author makes, will keep you in &lt;strong&gt;tutorial purgatory&lt;/strong&gt; and won't allow you to expand yourself because we just want to finish the things quickly so we have to come back again and again. So be patience and take time to learn the things instead of rushing through it. I am not saying that you should not take tutorials instead take tutorials and try to do the things by yourself also.&lt;/p&gt;

&lt;p&gt;If you guys follow the same approach or some other ways also please let me know. It will be very much valuable to learn different ways of learning.&lt;/p&gt;

</description>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Multiple Databases in Django</title>
      <dc:creator>D</dc:creator>
      <pubDate>Wed, 05 Aug 2020 08:14:34 +0000</pubDate>
      <link>https://dev.to/dj221ai/multiple-databases-in-django-2ki0</link>
      <guid>https://dev.to/dj221ai/multiple-databases-in-django-2ki0</guid>
      <description>&lt;p&gt;This post was Originally from my medium posts.&lt;/p&gt;

&lt;p&gt;In this tutorial we gonna see how we can use multiple databases in django. In this tutorial we used django 3.0 but it will be suitable for all version of django ≥ above 2.2.&lt;br&gt;
let first create a directory and setup the virtual environment for this project. I am using python 3.6 and Django 3.0 for this project.&lt;br&gt;
Go to the folder in which you want to create the project and install django and the other required things.(It would be much better if you create the project in virtual environment it will separate this project from your other projects).&lt;br&gt;
Create Project called checkingdb&lt;br&gt;
djanog-admin startproject checkingdb&lt;br&gt;
cd checkingdb&lt;br&gt;
python manage.py startapp contenter, python manage.py startapp customer, python manage.py startapp userchecking&lt;br&gt;
Now in settings.py file the db’s gets configured, but first start your pgAdmin if you are using postgres and create new databases. here i have created 3 db’s named contentdb, usersdb, customerdb where contentdb is the default one and the other two are the extra db’s which you can use for other purposes.&lt;br&gt;
First add all your apps in INSTALLED_APPS and now lets configure the DATABASE_ROUTERS.&lt;br&gt;
DATABASE_ROUTERS = ['contenter.router.CheckerRouter']  # it consists the path where your router.py file reside. in my case it is in contenter app.&lt;br&gt;
Now lets configure the database in settings&lt;br&gt;
DATABASES = {&lt;br&gt;
    'default': {&lt;br&gt;
        'ENGINE': 'django.db.backends.postgresql',&lt;br&gt;
        'NAME': 'contentdb',&lt;br&gt;
        'USER': 'postgres',&lt;br&gt;
        'PASSWORD': 'admin1234',&lt;br&gt;
        'HOST': 'localhost',&lt;br&gt;
        'PORT': '5432'&lt;br&gt;
    },&lt;br&gt;
    'usersdb': {&lt;br&gt;
        'ENGINE': 'django.db.backends.postgresql',&lt;br&gt;
        'NAME': 'usersdb',&lt;br&gt;
        'USER': 'postgres',&lt;br&gt;
        'PASSWORD': 'admin1234',&lt;br&gt;
        'HOST': 'localhost',&lt;br&gt;
        'PORT': '5432'&lt;br&gt;
    },&lt;br&gt;
    'customerdb': {&lt;br&gt;
        'ENGINE': 'django.db.backends.postgresql',&lt;br&gt;
        'NAME': 'customerdb',&lt;br&gt;
        'USER': 'postgres',&lt;br&gt;
        'PASSWORD': 'admin1234',&lt;br&gt;
        'HOST': 'localhost',&lt;br&gt;
        'PORT': '5432'&lt;br&gt;
    }&lt;/p&gt;

&lt;p&gt;}&lt;br&gt;
I have created the router.py file in contenter app. below is the code for router.py file.&lt;br&gt;
class CheckerRouter:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def db_for_read(self, model, **hints):
    if model._meta.app_label == 'customers':
        return 'customerdb'
    elif model._meta.app_label == 'userchecking':
        return 'usersdb'
    return 'default'

def db_for_write(self, model, **hints):
    if model._meta.app_label == 'customers':
        return 'customerdb'
    elif model._meta.app_label == 'userchecking':
        return 'usersdb'
    return 'default'

def allow_relation(self, obj1, obj2, **hints):
    if obj1._meta.app_label == 'customers' or obj2._meta.app_label == 'customers':
        return True
    elif 'customers' not in [obj1._meta.app_label, obj2._meta.app_label]:
        return True
    elif obj1._meta.app_label == 'userchecking' or obj2._meta.app_label == 'userchecking':
        return True
    elif 'userchecking' not in [obj1._meta.app_label, obj2._meta.app_label]:
        return True
    return False

def allow_migrate(self, db, app_label, model_name=None, **hints):
    if app_label == 'customers':
        return db == 'customerdb'
    elif app_label == 'userchecking':
        return db == 'usersdb'
    return None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now need to do some changes in models.py in all apps and we are good to go.&lt;br&gt;
contenter\models.py&lt;br&gt;
from django.db import models&lt;/p&gt;

&lt;p&gt;class Content(models.Model):&lt;br&gt;
    app_name = models.CharField(max_length=100)&lt;br&gt;
    language = models.CharField(max_length=100)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def __str__(self):
    return self.app_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;customers\models.py&lt;br&gt;
from django.db import models&lt;/p&gt;

&lt;p&gt;class CustomerChecker(models.Model):&lt;br&gt;
    customer_name = models.CharField(max_length=100)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Meta:
    # app_label helps django to recognize your db
    app_label = 'customers'

def __str__(self):
    return self.customer_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;userchecking\models.py&lt;br&gt;
from django.db import models&lt;/p&gt;

&lt;p&gt;class UserChecker(models.Model):&lt;br&gt;
    user_name = models.CharField(max_length=100)&lt;br&gt;
    age = models.IntegerField()&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Meta:
    app_label = 'userchecking'  # name of app

def __str__(self):
    return self.user_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Don’t forget to include your models in admin.py file.&lt;br&gt;
After all these need to migrate all the apps&lt;br&gt;
python manage.py migrate — database=customerdb&lt;br&gt;
python manage.py migrate — database=usersdb&lt;br&gt;
python manage.py migrate&lt;br&gt;
than run the server using python manage.py runserver and go to browser&lt;br&gt;
and type localhost:8000/admin and login and add data in your models and check in your db.&lt;br&gt;
Note:- When you change anything in models don’t forget to use Python manage.py makemigrations.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
