Skip to content

Instantly share code, notes, and snippets.

View RANUX's full-sized avatar
🏠
👉JavaScript dev. Open for job offerings

Alexander RANUX

🏠
👉JavaScript dev. Open for job offerings
View GitHub Profile
@RANUX
RANUX / rename_model.md
Created September 7, 2020 05:24
Переименовать модель Django

Шаг 1: отредактируйте соответствующие имена полей в models.py

class Bar(models.Model):
    name = models.CharField(unique=True, max_length=32)
    description = models.TextField(null=True, blank=True)


class AnotherModel(models.Model):
    bar = models.ForeignKey(Bar)  # <-- changed field name
    is_awesome = models.BooleanField()
@RANUX
RANUX / rename_model_field.md
Last active September 11, 2020 11:57
Переименовать поле модели Django
  1. Изменить имя поля в модели (но запомнить старое имя для 3 шага!)
  2. Создать пустую миграцию
$ python manage.py makemigrations --empty myApp
  1. Отредактировать новый файл пустой миграции он находится в папке миграции в папке вашего приложения и будет последней миграцией) добавив:
operations = [
        migrations.RenameField('MyModel', 'old_field_name', 'new_field_name'),
 ]
@RANUX
RANUX / settings.py
Created February 23, 2021 15:11 — forked from andreagrandi/settings.py
Sending emails from Django during development without using a real SMTP server. Python comes with a very basic and integrated SMTP server. To start it just open a terminal and type: python -m smtpd -n -c DebuggingServer localhost:1025 Then configure your settings.py using the following parameters. You will see the email directly in the terminal …
if DEBUG:
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = '[email protected]'
@RANUX
RANUX / fields.py
Created September 16, 2021 12:45 — forked from ramsrib/fields.py
A form field to handle validation of image + svg in Django 3
import sys
import xml.etree.cElementTree as et
from io import BytesIO
from django.core.exceptions import ValidationError
from django.core.validators import (
FileExtensionValidator,
get_available_image_extensions,
)
from django.forms import ImageField as DjangoImageField
@RANUX
RANUX / README.md
Last active October 7, 2021 21:46
Server settgins for godot web editor with hestia cp

Enable mod_headers

a2enmod headers
systemctl restart apache2

put .htaccess to public_html

DirectoryIndex godot.tools.html
@RANUX
RANUX / install-ansible.sh
Created March 30, 2022 11:58
install ansible on ubuntu 20
apt-get update
apt-get upgrade
apt install git python3-pip
update-alternatives --install /usr/bin/python python /usr/bin/python3 2
pip3 install ansible

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.

How to install Python 3.10 in Miniconda

conda create --name threeten --no-default-packages python=3.10
conda activate threeten