Question: I have an array of arrays containing subnets, one of the subnets is wrong (is missing one octet) and I would like to merge them and ignore the wrong one.

I have the following code:

```
subnets = ["149.62.168.0/24"], ["134.247.2.0/24"], ["159.226.92.0/24","159.8.57/22"]

require 'netaddr'

subnet.each do |net|
  begin
  merged_subnets = NetAddr.merge(net)
  rescue ArgumentError => error
    puts error
  end
  puts merged_subnets
end 

```

This code gives me the following output:

```
149.62.168.0/24
134.247.2.0/24
One of the provided CIDR addresses raised the following errors: 159.8.57 is invalid (IPv4 requires (4) octets).

```

However, what I was expecting was:

```
 149.62.168.0/24
 134.247.2.0/24
 159.226.92.0/24
 One of the provided CIDR addresses raised the following errors: 159.8.57 is invalid (IPv4 requires (4) octets).

```

I don't understand why the subnet **159.226.92.0/24** doesn't appear in the output.

Answer: 
You need to install these libraries first :

```
sudo apt-get install libpq-dev postgresql postgresql-contrib

```

**Configuration**

in settings.py

```
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'db_name',                      
        'USER': 'db_user',
        'PASSWORD': 'db_user_password',
        'HOST': '',
        'PORT': 'db_port_number',
    }
}

```

You can refer to these two links: 

1. For More Detailed information about setup :[Tutorial for setting up application using PostgreSql](https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-django-application-on-ubuntu-14-04)
2. [Documentation link for writing Queries](https://docs.djangoproject.com/en/1.11/intro/tutorial02/)
Glad you're coming on board with Django! It's a great language with plenty of useful features, you won't regret learning it. 

To connect to an existing database, check out the docs [here](https://docs.djangoproject.com/en/1.11/howto/legacy-databases/). This explains how to use your existing db to create models in your project.

I also recommend checking out the tutorials in the docs starting [here](https://docs.djangoproject.com/en/1.11/intro/tutorial02/). This tutorial will explain how to connect to your postgres db, as well as how to begin writing queries for your views. This is the place to start learning the basics of Django, just follow it along and you will get the hang of everything in no time