This file contains hidden or 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
| from fabric.api import task | |
| from fabric.api import local | |
| from fabric.api import cd | |
| from fabric.api import env | |
| from fabric.api import prefix | |
| from fabric.api import sudo | |
| from fabric.api import run | |
| env.user = 'eduardo' | |
| env.hosts = ['147.182.241.110'] |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import urllib2 | |
| gh_url = 'https://api.github.com' | |
| req = urllib2.Request(gh_url) | |
| password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm() |
This file contains hidden or 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
| from django.contrib.auth.models import Group | |
| Group.objects.create(name="Awesome Users") | |
| awesome_users = Group.objects.get(name="awesome_users") | |
| awesome_users.permissions.add(permisson, permission, ...) |
This file contains hidden or 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
| # with Ruby on Rails | |
| User.where('email is ?', nil).limit(10) | |
| # with Django | |
| User.objects.filter(email__isnull=True)[:10] |
This file contains hidden or 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
| user.permissions.add(permission, permission, ...) | |
| user.permissions = [permission_list] | |
| user.permissions.clear() | |
| user.get_all_permissions() |
This file contains hidden or 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
| DATABASES = { | |
| 'default': { | |
| 'ENGINE': 'django.db.backends.sqlite3', | |
| 'NAME': BASE_DIR / 'db.sqlite3', | |
| } | |
| } | |
This file contains hidden or 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
| from djangodjango.conf import settings | |
| from django.db import models | |
| from django.utils import timezone | |
| class Post(models.Model): | |
| author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) | |
| title = models.CharField(max_length=200) | |
| text = models.TextField() |
This file contains hidden or 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
| from django.contrib.auth.models import Group | |
| Group.objects.create(name="administacion") | |
| administracion = Group.objects.get(name="administracion") | |
| administracion.permisos.add(permiso1, permiso2) | |
This file contains hidden or 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
| user.permissions.add(permiso1, permiso2) | |
| user.permissions = [lista_de_permisos] | |
| user.permissions.clear() | |
| user.get_all_permissions() | |
This file contains hidden or 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
| from django.conf import settings | |
| from django.db import models | |
| from django.utils import timezone | |
| class Post(models.Model): | |
| autor = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) | |
| titulo = models.CharField(max_length=200) | |
| texto = models.TextField() | |
| creado = models.DateTimeField( |
NewerOlder