Last major update: 25.08.2020
- Что такое авторизация/аутентификация
- Где хранить токены
- Как ставить куки ?
- Процесс логина
- Процесс рефреш токенов
- Кража токенов/Механизм контроля токенов
| """ | |
| Django ORM Optimization Tips | |
| Caveats: | |
| * Only use optimizations that obfuscate the code if you need to. | |
| * Not all of these tips are hard and fast rules. | |
| * Use your judgement to determine what improvements are appropriate for your code. | |
| """ | |
| # --------------------------------------------------------------------------- |
UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth
on useless vacuuming of the table (since we never DELETE or UPDATE the table).COPY FROM STDIN. This is the fastest possible approach to insert rows into table.time timestamp with time zone is enough.synchronous_commit = off to postgresql.conf.| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| import lxml.etree | |
| import lxml.html | |
| import requests | |
| xml_sample = """<?xml version="1.0" encoding="UTF-8"?> | |
| <foo:Results xmlns:foo="http://www.foo.com" xmlns="http://www.bah.com"> | |
| <foo:Recordset setCount="2"> |
| # You have a model something like this | |
| from django.contrib.postgres.fields import JSONField | |
| class MyModel(models.Model): | |
| jsonfield = JSONField() # {"name": "Gaurav", "age": "25", "address": {"country": "India", "city": "Jaipur"}} | |
| # few more fields... | |
| # And in admin you want to create filter for jsonfield properties/keys | |
| # for e.g. in above case we want to show filter for age and country |
| require 'openssl' | |
| require 'base64' | |
| require 'json' | |
| require 'httpclient' | |
| http = HTTPClient.new(:agent_name => useragent) | |
| key = "" #The Private key | |
| login_info = {:guid => "00000000-0000-0000-0000-000000000000", | |
| :password => "PASSWORD", | |
| :username => "USERNAME", |
| Индекс,Тип региона,Регион,Тип района,Район,Тип города,Город,Тип н/п,Н/п,Код КЛАДР,Код ФИАС,Уровень по ФИАС,Признак центра района или региона,Код ОКАТО,Код ОКТМО,Код ИФНС,Часовой пояс,Широта,Долгота,Федеральный округ,Население | |
| 385200,Респ,Адыгея,,,г,Адыгейск,,,0100000200000,ccdfd496-8108-4655-aadd-bd228747306d,4: город,0,79403000000,79703000001,0107,UTC+3,44.8783715,39.190172,Южный,12689 | |
| 385000,Респ,Адыгея,,,г,Майкоп,,,0100000100000,8cfbe842-e803-49ca-9347-1ef90481dd98,4: город,2,79401000000,79701000001,0105,UTC+3,44.6098268,40.1006527,Южный,144055 | |
| 649000,Респ,Алтай,,,г,Горно-Алтайск,,,0400000100000,0839d751-b940-4d3d-afb6-5df03fdd7791,4: город,2,84401000000,84701000,0400,UTC+7,51.9582681,85.9602957,Сибирский,62861 | |
| 658125,край,Алтайский,,,г,Алейск,,,2200000200000,ae716080-f27b-40b6-a555-cf8b518e849e,4: город,0,01403000000,01703000,2201,UTC+7,52.4920914,82.7794145,Сибирский,28528 | |
| 656000,край,Алтайский,,,г,Барнаул,,,2200000100000,d13945a8-7017-46ab-b1e6-ede1e89317ad,4: город,2,01401000000,01701000,2200,UTC+7,53. |
| from django import forms | |
| from django.core.exceptions import ValidationError | |
| from django.db import transaction | |
| class InvalidInputsError(Exception): | |
| def __init__(self, errors, non_field_errors): | |
| self.errors = errors | |
| self.non_field_errors = non_field_errors |