Skip to main content

Connect POSTgreSQL with Django

 First install all necessary step 


$ sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib
Second
$ sudo su - postgres
$ psql
Create User name with password 
$ CREATE USER user_name WITH PASSWORD 'password'; 
Create New Database
$ CREATE DATABASE database_name WITH OWNER user_name;
Give permission 
$ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO user_name;
Update settings.py 
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'database_name',
'USER': 'user_name',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '5432',
}
}
 Then,
python3 manage.py migrate
and finally create super user
python3 manage.py createsuperuser 

Comments

Popular posts from this blog

Data visualize with matplotlib(solid line)

Nominal GDP      from matplotlib import pyplot as plt      years = [1950, 1960, 1970, 1980, 1990, 2000, 2010]      gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3]      plt.title('GDP')      plt.ylabel('Billios of $')      plt.plot(years,gdp,color='red',marker='o',linestyle='solid')      plt.show() * plt.plot(x,y,color,marker per year,linestyle) there are several line style '-', '--', '-.', ':', 'None', ' ', '', 'solid', 'dashed', 'dashdot', 'dotted' fig-