- To update .po translate file run
python manage.py makemessages -l=pt_BR
; - Run
python manage.py compilemessages
to compile the translations (pt-br only);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@admin.register(ModelName) | |
class CustomAdmin(admin.ModelAdmin): | |
def formfield_for_dbfield(self, db_field, **kwargs): | |
formfield = super().formfield_for_dbfield(db_field, **kwargs) | |
if db_field.name == "field_name": | |
formfield.widget.can_add_related = False | |
return formfield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# brazil's code areas | |
# http://www.anatel.gov.br/setorregulado/codigos-nacionais/codigos-nacionais | |
# http://www.anatel.gov.br/legislacao/resolucoes/16-2001/383-resolucao-263 | |
phone_validator = RegexValidator(regex=r'^(1[1-9]|2[1-2,4,7,8]|3[1-5]|3[7-8]|4[1-9]' | |
r'|5[1,3-5]|6[1-9]|7[1,3,4,5,7,9]' | |
r'|8[1-9]|9[1-9]){1}[0-9]{8,9}$', | |
message="Phone number must be entered in the format '99000000000'. " | |
"where 99(2 digits) is a brazil code area, and 000000000 is a number phone " | |
"with 8 or 9 digits.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~/.ssh | |
ssh-keygen -t rsa -b 4096 -C "[email protected]" | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_rsa | |
cat ~/.ssh/id_rsa.pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' ca.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --hard && git pull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(json.dumps({"key": "value"}, indent=4, sort_keys=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fail2ban-client -vvvv set wordpress banip 129.213.67.237 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Run in terminal of OSX | |
*/ | |
sudo killall VDCAssistant | |