Skip to content

Instantly share code, notes, and snippets.

Chelder cheldernunes

View GitHub Profile
@cheldernunes
cheldernunes / bash.sh
Created Mar 11, 2019
Gerar SSH Key public
View bash.sh
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "dev@email.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub
@cheldernunes
cheldernunes / phone_validator_django.py
Created Oct 12, 2018
Django RegexValidator for phone numbers with ddd+number(8 or 9) digits
View phone_validator_django.py
# 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.")
@cheldernunes
cheldernunes / admin.py
Created Oct 5, 2018
This gist show how remove add link in related fields in admin django. Replace field_name with your field.
View admin.py
@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
You can’t perform that action at this time.