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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title> jQuery Youtube </title> | |
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > | |
| <link rel="stylesheet" href="../../reset.css" type="text/css" media="screen" charset="utf-8"> | |
| <link rel="stylesheet" href="../../screen.css" type="text/css" media="screen" charset="utf-8"> | |
| <link rel="stylesheet" href="screen.css" type="text/css" media="screen" charset="utf-8"> | |
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.core.files.storage import default_storage | |
| def delete_image_update_view(self, request): | |
| qs = self.get_object(queryset=self.model.objects.all()) | |
| if qs and request.FILES.get(key='image', default=None): | |
| try: | |
| cur_file = self.model.objects.get(pk=qs.pk) | |
| default_storage.delete(cur_file.image.path) |
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
| Sql QuerySet Notes | |
| SELECT count(*) FROM fruit Fruits.objects.count() table count | |
| SELECT count(*) FROM fruit WHERE name=’Orange’ Fruits.objects.filter(name__exact=’Orange’).count() count with filter | |
| SELECT * FROM fruit WHERE color is NULL Fruits.objects.get(color__isnull=True) filter by null | |
| SELECT * FROM fruit WHERE color is NOT NULL Fruits.objects.get(color__isnull=False) filter by null | |
| SELECT * FROM fruit WHERE name=’Apple’ Fruits.objects.get(name__exact=’Apple’) case sensitive | |
| SELECT * FROM fruit WHERE lower(name)=lower(‘Apple’) Fruits.objects.get(name__iexact=’Apple’) case in-sensitive | |
| SELECT * FROM fruit WHERE name LIKE ‘App%’ Fruits.objects.filter(name__startswith=’App’) case sensitive LIKE | |
| SELECT * FROM fruit WHERE upper(name) LIKE ‘APP%’ Fruits.objects.filter(name__ista |
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
| # Simple json response generic view | |
| from django.views.generic import View | |
| from django.utils import simplejson | |
| class JSONResponseView(View): | |
| def render_to_response(self, data, **httpresponse_kwargs): | |
| "Retuns a json response based on the context" | |
| json_data = simplejson.dumps(data) |
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 * | |
| >>> print User.objects.all().query | |
| SELECT "auth_user"."id", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user" | |
| >>> print User.objects.filter(username='andrews').query | |
| SELECT "auth_user"."id", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."username" = andrews | |
| >>> |
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 | |
| # encoding: utf-8 | |
| import sys | |
| from argparse import ArgumentParser | |
| from xml.dom import minidom | |
| try: | |
| from urllib.request import urlopen | |
| from urllib.parse import urlencode | |
| except ImportError: |
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
| #! /bin/bash | |
| set -e | |
| LOGFILE=/home/sites-clip/clip-2/logs/gunicorn_clip-2.log | |
| LOGDIR=$(dirname $LOGFILE) | |
| PIDFILE=/home/sites-clip/clip-2/tmp/gunicorn_clip-2.pid | |
| # Number of worker processes. | |
| # Should be no less than the number of cores available and a popular formula | |
| # is 1 + 2 * number of cores. | |
| NUM_WORKERS=3 |
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
| import urllib | |
| URL = "http://webservices.daehosting.com/services/eleventest.wso/IsAllNumbers" | |
| numero = "" | |
| XML = """\ | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | |
| <soap:Body> |
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
| <script type="text/javascript"> | |
| $(function(){ | |
| $('#enviar_contato').click(function(){ | |
| var id_username = $("#id_username").val(); | |
| var id_password = $("#id_password").val(); | |
| var id_token = $("#id_token").val(); | |
| if (id_username!='' & id_password!='' & id_token!='') | |
| { | |
| $('.loading').show(); | |
| $('form')[0].reset(); |
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
| setinsgs.py | |
| MEDIA_ROOT = os.path.join(PROJECT_ROOT_PATH, 'media') | |
| MEDIA_URL = '/media/' | |
| STATIC_ROOT = os.path.join(PROJECT_ROOT_PATH, 'media/admin') | |
| STATIC_URL = '/media/admin/' | |
| ADMIN_MEDIA_PREFIX = STATIC_URL + 'grappelli/' | |
| urls.py |