Python
4
Вклад в тег
import base64
with open("yourfile.ext", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
"link": HOST + item.find("a", class_="js-item-slider").get('href'),
version: '3.7'
services:
web:
build: .
command: python /profi/manage.py runserver 0.0.0.0:8000
environment:
# DJANGO_SETTINGS_MODULE: "project.settings.development"
DEBUG: 1
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_HOST: db
volumes:
- .:/profi
ports:
- "${HTTP_PORT:-8000}:8000"
depends_on:
- db
db:
image: postgres:11
volumes:
- postgres_data:/var/lib/posgresql/data/
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_HOST: db
ports:
- "${DB_PORT:-5432}:5432"
volumes:
postgres_data:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('POSTGRES_DB', default='postgres'),
'USER': os.environ.get('POSTGRES_USER', default='postgres'),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', default='postgres'),
'HOST': os.environ.get('POSTGRES_HOST', default='localhost'),
'PORT': "5432"
}
}
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
"--path",
dest="path",
default=os.path.join(os.path.abspath(os.path.dirname(__name__)), 'data.csv')
)
def handle(self, *args, **options):
path = options.get("path")
...
call_command('my_command', path=create_test_csv_file)