sudo apt update
sudo apt install software-properties-common -y
# Written by Senko Rasic <[email protected]> | |
# Released into Public Domain. Use it as you like. | |
from django.db import models | |
class SingletonModel(models.Model): | |
"""Singleton Django Model | |
Ensures there's always only one entry in the database, and can fix the |
{% load startswith %} | |
<li{% if request.path|startswith:'/settings/' %} class="active"{% endif %}> |
# Objective: Running selenium python scripts in alpine without grid | |
FROM python:3.7.2-alpine3.8 | |
RUN pip install selenium | |
RUN apk add chromium | |
RUN apk add chromium-chromedriver | |
ENV CHROME_BIN=/usr/bin/chromium-browser \ |
from django.core.exceptions import ValidationError | |
def validate_meli_code(value: str): | |
if not len(value) == 10: | |
raise ValidationError("کد ملی باید ۱۰ رقم باشد.") | |
res = 0 | |
for i, num in enumerate(value[:-1]): | |
res = res + (int(num) * (10 - i)) |