Posts

Showing posts with the label django-guid

Setup S3 bucket in Django Project: How to set-Up amazone s3 bucket storage

Image
Hii Viewer, welcome on our blog here we will learn that how we can setup Amazon S3 Bucket in our django project. So there are some miner steps, you can follow this and lets complete the process. 1. Install the the package - boto3 pip install boto3  2. add 'storages' in INSTALLED_APPS of setting.py #add this line in setting.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'user', ' storages ',                    #new line ] 3. Remove MEDIA_URL and MEDIA_ROOT on your setting.py file if you have added. 4. add code in setting.py file  #add this line in setting.py DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' AWS_S3_ACCESS_KEY_ID = os.environ['...

import dotenv: How to use dotenv (.env) in django ?

1. First install : pip install django-dotenv 2.   Manage.py file import dotenv and add a line dotenv . read_dotenv ()  in main function import os import sys import dotenv     #new def main (): dotenv . read_dotenv ()     #New os . environ . setdefault ( 'DJANGO_SETTINGS_MODULE' , 'xpertstreet.settings' ) try : from django . core . management import execute_from_command_line except ImportError as exc : 3. Create a file .env with the app (where the all apps are available) .env file Contains: ALLOWED_HOSTS = "13.233.156.17,localhost" DB_NAME = "wooxpertstreet" DB_USER = "postgres" DB_PASS = "12345" DB_HOST = "localhost" DB_PORT = 5432 4. How to get .env values in settings.py or anywhere? import os DATABASES = {     'default' : {         'ENGINE' : 'django.db.backends.postgresql_psycopg2' ,         'NAME' : os . environ . get ( "DB_NAME...