Things that make me happy

Things that make me happy

Python + Django y mucho más!

2e19e78ec961cd9c60642ce7fe9f8c68?s=128

Jorge Bastida

April 01, 2012
Tweet

Transcript

  1. !"#$%& '%()*+,-./0- 12%()*3-./0-

  2. 42-&)% '%()*+,-./0- 12%()*3-./0-

  3. 5$6&).+#$-#+7-8*+7*+$-99": '%()*+,-./0- 12%()*3-./0-

  4. None
  5. !"#$%&'(')*%&+ ;<<=>;<?<+#$*@%0*A-(7 ;<?<>;<??+B0*-#*@- C3(6D+;<??+E#(**#D6A*:@%7

  6. ,-./012 02-&)%>0-2-F 02-&)%>0-2-F6@* @..3G.#*( )DG* HG&8D%-0I+HD-.8>J%&)%*&)6&*I+HD-.8>4*3G)5%%D3-(I+'6&2%>76&6A"+:::

  7. K?+L63*(-(+@M06)%

  8. L-+7*2%(+0*@6.6M&+NG*+$*+#%7-0%: +++++++O2%.I++++++++P*Q6*R.: S-"+)*&#*+.345672"6+-$T+AG*(-: U U

  9. -"164&&+4%$

  10. -"164&&+4%$

  11. -"164&&+4%$ ;V9F

  12. -"164&&+4%$ ;WX9F ?WX9F ;V9F

  13. -"164&&+4%$ ;WX9F ?WX9F ;V9F ?X<9F Y<9F

  14. $ glue source destination Z+[*&*(-0%(+0*'&85./6&'4&&+0*.0*+*D+#*(76&-D: Z+CG#%7-/\-(+G&+9(%@*.%+/69.%&%: Z+B&#*)(-3D*+*&+*D+9(%@*.%+0*+@%796D-@6M&+0*+-..*#.: Z+:63%5'3;$65%'96'56<16&/& Z+?+]@$*(%+^)(-&0*_+`+&+]@$*(%.+9*NG*a%.: =%5-62)&#9)>-"16

  15. .sprite-icons-rainbow{ background-image:url(sprite.png); background-repeat:no-repeat; background-position: 247px 147px; width: 25px; height: 25px;

    } ... .9(6#*:9&) .9(6#*:@.. =%5-62)&#9)>-"16
  16. ?&/)97&#4)& @@A 9-T.*. B(C 9b)6&-.+Q6.#-. D@C R-#@$*(. DBA A%(8. EA

    0T-.
  17. ,-./012 02-&)%>0-2-F 02-&)%>0-2-F6@* @..3G.#*( -"16

  18. K;+!"#$%&

  19. c%I+*&+.*(6%I+!"#$%&:::

  20. F6-.2"6: ++E6&#-F6.+6&#G6/Q-+"+*.#(6@#- G5%914#H%+ ''d&#(*+?ef+"+?eV+7b.+@%&@6.%+NG*+'-Q-+%+ghh I.H65#9%+ ''JG"+06Q*(/0%

  21. JJJ'K516L'M)"&6'N'M)"&6L'K516 JJJ'K516 M)"&6 JJJ'M)"&6 K516

  22. iii+679%(#+#$6.

  23. JJJ'.$8%5/'/0.& K06'O63'%P'GQ/0%3L'2Q'K.$'G6/65& R6)1#P1"'.&'26S65'/0)3'1-"Q+ ?T8".4./'.&'26S65'/0)3'.$8".4./+ U.$8"6'.&'26S65'/0)3'4%$8"6T+ V%$8"6T'.&'26S65'/0)3'4%$8".4)/69+ M")/'.&'26S65'/0)3'36&/69+ U8)5&6'.&'26S65'/0)3'963&6+ W6)9)2."./Q'4%13/&+ U864.)"'4)&6&')563X/'&864.)"'63%1-0'/%'256)C'/06'51"6&+

    Y"/0%1-0'85)4#4)"./Q'26)/&'815./Q+ ?55%5&'&0%1"9'36H65'8)&&'&."63/"Q+ Z3"6&&'6T8".4./"Q'&."63469+ [3'/06'P)46'%P')$2.-1./QL'56P1&6'/06'/6$8/)#%3'/%'-16&&+ K0656'&0%1"9'26'%36\\')39'856P65)2"Q'%3"Q'%36'\\%2H.%1&'])Q'/%'9%'./+ Y"/0%1-0'/0)/'])Q'$)Q'3%/'26'%2H.%1&')/'^5&/'13"6&&'Q%1X56'I1/40+ _%]'.&'26S65'/0)3'36H65+ Y"/0%1-0'36H65'.&'%`63'26S65'/0)3'a5.-0/a'3%]+ [P'/06'.$8"6$63/)#%3'.&'0)59'/%'6T8").3L'./X&')'2)9'.96)+ [P'/06'.$8"6$63/)#%3'.&'6)&Q'/%'6T8").3L'./'$)Q'26')'-%%9'.96)+ _)$6&8)46&')56'%36'0%3C.3-'-56)/'.96)'\\'"6/X&'9%'$%56'%P'/0%&6b
  24. Kf+679%(#+#$6.

  25. KW+!d!=

  26. c1.9%'H)3'W%&&1$'deAA@f P*@%7*&0-@6%&*.+0*+*./D% Z+^P*-0-36D6#"+@%G&#._ Z+^g%0*+6.+(*-0+7G@$+7%(*+%j*&+#$-&+6#+6.+R(6k*&:_ G?Gg

  27. G)")25)&'&68)5)9)&'8%5'h 7"l)(**&l$%G.* V)$6"'V)&6 S%G.* B77G#-3D*S%G.* H)5.)2"6&'Q'P134.%36& $.31&41")& $%G.* 4")&6&

  28. iE'4)5)4/j56& [963/)4.%3 B'6&8)4.%& "%3-./19'$kT.$) spam(ham[1], {eggs: 2}) 6&8)4.%& 6/4+++

  29. KV+B0*&#-/%&

  30. def my_function(foo return "Hello W ....

  31. lm%1'$1&/'3%/'0)H6'/5.69'./'Q6/+n o.9%'p)3'W%&&1$'dGQ4%3'ZU'eA@ef

  32. E$%R+7*+#$*+@%0*m

  33. def my_function(foo, bar): return "Hello World!" P134.%36&+

  34. class Human(object): def __init__(self, name, sex): self.name = name self.sex

    = sex def say(self, message): print "{0}: {1}".format(self.name, message) 4")&6&+
  35. for i in range(10): print i [0, 1, 2, 3,

    4, 5, 6, 7, 8, 9] P%5+
  36. i = 10 while i: print i i -= 1

    ]0."6+
  37. >>> def gt0(num): ... return num > 0 ^"/65+ >>>

    filter(gt0, [1, -5, 3, -7]) [1, 3]
  38. >>> map(str, range(5)) ['0', '1', '2', '3', '4'] $)8+

  39. >>> map(lambda x: x>2 , range(5)) [False, False, False, True,

    True] $)8+
  40. >>> a = [1,2,3] >>> b = [4,5,6] >>> zip(a,b)

    [(1, 4), (2, 5), (3, 6)] q.8+
  41. >>> sorted([5, 1, 3, 4, 2]) [1, 2, 3, 4,

    5] &%5/69+
  42. [X:Y:Z] start end step &".4.3-+

  43. >>> nums[0] >>> nums = range(5) >>> nums [0, 1,

    2, 3, 4] >>> nums[::-2] >>> nums[:2] >>> nums[2:] >>> nums[:-1] >>> nums[-1:] >>> nums[::2] >>> nums[::-1] 0 [2, 3, 4] [0, 1] [0, 1, 2, 3] [4] [0, 2, 4] [4, 3, 2, 1, 0] [4, 2, 0]
  44. >>> [i for i in range(5)] [0, 1, 2, 3,

    4] ".&/'4%$856063&.%3&+
  45. >>> [i for i in range(5) if i > 2]

    [3, 4] ".&/'4%$856063&.%3&+
  46. >>> [i**2 for i in range(10) if i % 2]

    [1, 9, 25, 49, 81] ".&/'4%$856063&.%3&+
  47. KY+[*./M&+0*+9-NG*#*.

  48. .3&/)")5';"#$)'H65&.r3 n+969+6&.#-DD+9-NG*#* .3&/)")5'13)'H65&.r3 n+969+6&.#-DD+9-NG*#*oo?:W )4/1)".q)5 n+969+6&.#-DD+9-NG*#*+>>G9)(-0* 96&.3&/)")5 n+969+G&6&.#-DD+9-NG*#* G[G

  49. pq+*&+*D+7G&0%+(*-Dr

  50. 456)5'H.5/1)"63H n'Q6(#G-D*&Q+9(%"*@#% )4#H)5'H.5/1)"63H n+.%G(@*+9(%"*@#%e36&e-@/Q-#* H.5/1)"63H

  51. .3&/)")5'56<1.&./%&'96'13'85%Q64/% n'969+6&.#-DD+>(+PdstBPdJdc5E+>d+9(%"*@#% H.5/1)"63H's'8.8

  52. .3&/)")5'56<1.&./%&'96'13'85%Q64/% n'969+6&.#-DD+>(+PdstBPdJdc5E+>d+9(%"*@#% H.5/1)"63H's'8.8 django==1.4 glue gunicorn>=0.1.4 ...

  53. dF%/.7%.

  54. #include <iostream> int main () { int a = 10;

    int b = 10; std::cout << &a << " " << &b; } $ ./app 0x7fff5fbff4cc 0x7fff5fbff4c4
  55. >>> a = 10 >>> b = 10 >>> print

    id(a), id(b) 4300032496 4300032496
  56. >>> a = 10 >>> b = 10 a b

    10 >>> c = b c >>> b = 5 5
  57. >>> a = [1] >>> b = a a b

    >>> b.append(2) [1] [1,2]
  58. .$$1/)2"6&+ c%&* B&#I+HD%-#+::: ,%%D*-&. E#(6&). t&6@%0* 5G9D*. $1/)2"6&: L6.#-. 46@@6%&-(6%.

  59. >>> a = "Hello" >>> a[0] = "B" Traceback (most

    recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment
  60. >>> a = "Hello" >>> a.replace("H", "B") 'Bello' >>> a

    'Hello'
  61. KX+B&#(%.9*@@6M&

  62. >>> dir(str) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__',

    '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] d.+G&-+D6.#-m
  63. >>> a = "10" >>> [[m, getattr(a, m)()] for m

    in dir(a) if m.startswith("is")] [['isalnum', True], ['isalpha', False], ['isdigit', True], ['islower', False], ['isspace', False], ['istitle', False], ['isupper', False]]
  64. >>> def foo(arg1, arg2="hello"): ... a = arg1 ... b

    = arg2 ... c = arg1 + arg2 ... return 2000 ... >>> foo.func_defaults ('hello',) >>> foo.func_code.co_consts (None, 2000) >>> foo.func_code.co_varnames ('arg1', 'arg2', 'a', 'b', 'c') >>> foo.func_code <code object foo at 0x1004c0cd8, file "<stdin>", line 1>
  65. K=+06.:06.uv

  66. >>> import dis >>> def sumar(a, b): ... return a

    + b ... >>> dis.dis(sumar) 2 0 LOAD_FAST 0 (a) 3 LOAD_FAST 1 (b) 6 BINARY_ADD 7 RETURN_VALUE
  67. >>> def llenar(lista): ... for i in range(10): ... lista.append(i)

    >>> dis.dis(llenar) 2 0 SETUP_LOOP 33 (to 36) 3 LOAD_GLOBAL 0 (range) 6 LOAD_CONST 1 (10) 9 CALL_FUNCTION 1 12 GET_ITER >> 13 FOR_ITER 19 (to 35) 16 STORE_FAST 1 (i) 3 19 LOAD_FAST 0 (lista) 22 LOAD_ATTR 1 (append) 25 LOAD_FAST 1 (i) 28 CALL_FUNCTION 1 31 POP_TOP 32 JUMP_ABSOLUTE 13 >> 35 POP_BLOCK >> 36 LOAD_CONST 0 (None) 39 RETURN_VALUE B'.3&/5144.%36&
  68. >>> def llenar2(lista): ... op = lista.append ... for i

    in range(10): ... op(i) >>> dis.dis(llenar2) 2 0 LOAD_FAST 0 (lista) 3 LOAD_ATTR 0 (append) 6 STORE_FAST 1 (op) 3 9 SETUP_LOOP 30 (to 42) 12 LOAD_GLOBAL 1 (range) 15 LOAD_CONST 1 (10) 18 CALL_FUNCTION 1 21 GET_ITER >> 22 FOR_ITER 16 (to 41) 25 STORE_FAST 2 (i) 4 28 LOAD_FAST 1 (op) 31 LOAD_FAST 2 (i) 34 CALL_FUNCTION 1 37 POP_TOP 38 JUMP_ABSOLUTE 22 >> 41 POP_BLOCK >> 42 LOAD_CONST 0 (None) 45 RETURN_VALUE t'.3&/5144.%36&
  69. u:6=%5vuV1)3/%v

  70. Kw+/7*6#

  71. >>> import timeit >>> t = timeit.Timer("code", "setup") >>> print

    t.timeit(number=10000000)
  72. >>> import timeit >>> t = timeit.Timer("llenar([])", """def llenar(lista): ...

    for i in range(10): ... lista.append(i)""") >>> print t.timeit(number=10000000) 24.431292057 >>> t = timeit.Timer("llenar2([])", """def llenar2(lista): ... op = lista.append ... for i in range(10): ... op(i)""") >>> print t.timeit(number=10000000) 20.4608399868
  73. ]&+0*+D-+7-0(6)G*(-+0*D+@%&*2%:

  74. GQ/0%3:%"):140%

  75. uw1.63'1&)'GQ/0%3v

  76. None
  77. g-0-+@-9-+*.+6&0*9*&06*&#*+"+0*.@%&%@*+ @%79D*#-7*&#*++-+D-.+0*7b.: J*&%.+@M06)%: 4*.-((%DD%+b)6D: M."%&%x)

  78. dQ6#-(+*D+#(-3-2%+#*06%.%: 4%&x#+P*9*-#+q%G(.*DA+u4Pqv: d]@6*&#*I+HD*F63D*I+E679D*+"+E*)G(%:+ M."%&%x)

  79. ,6*&Q*&60%.+-D+7G&0%+0*+O\

  80. P-6D. E"7A%&" ?Ww ??X fV ;w y+B&@DG60-+D-+@-(9*#-+0*D+9(%"*@#% M.4065%&'Q'V)586/)& 42-&)% W

    ? H6@$*(%. g-(9*#-. u?&'I=)3-%'/)3'&.$8"6'Q'Pk4."'96'1&)5v
  81. J-&%.+-+D-+7-.-m

  82. :%96" K6$8")/6 p.6]

  83. tPL. z6*R. RI Fr-.4) yK:F :%96" K6$8")/6 p.6]

  84. Y88 K6$8")/6 p.6] :%96" G5%=64/ Y88 &6z3-& 15"& )88&'s'".2& K6$8")/6

    p.6] :%96" Y88 K6$8")/6 p.6] :%96"
  85. ZWF& (r'^accounts/$', 'vista') def vista(request): ... 15"&+8Q

  86. ZWF& (r'^accounts/(\w+)/$', 'vista') def vista(request, name): ... 15"&+8Q

  87. ZWF& (r'^accounts/', include('accounts.urls')) 15"&+8Q def vista(request, name): ... (r'(\w+)/$', 'vista')

    (r'^sales/', include('sales.urls'))
  88. p.6]& H.6]&+8Q from django.shortcuts import render def vista(request): return render(request,

    'list.html') yS8W6<16&/ yS8W6&8%3&6 v
  89. p.6]& H.6]&+8Q from django.shortcuts import render, redirect def vista(request): if

    request.method == 'POST': ... return render(request, 'list.html')
  90. V")&&p.6]& H.6]&+8Q from django.views.generic import TemplateView class Vista(TemplateView): template_name =

    "template.html" def get(self, request): return self.render_to_response({...}) def post(self, request): ...
  91. tPL. z6*R. :%96" K6$8")/6 p.6]

  92. tPL. z6*R. :%96" K6$8")/6 p.6] p.6]

  93. K?<+J%0*D.

  94. J%0*D pEsLr

  95. {6DD+6#+R6#$+](*m

  96. :%96"& $%96"&+8Q from django.db import models class Book(models.Model): name =

    models.CharField(max_length=100) created = models.DateTimeField() available = models.BooleanField(default=True)
  97. :%96"& $%96"&+8Q ! ,%%D*-&H6*D0 ! B&#*)*(H6*D0 ! g$-(H6*D0 ! 4-#*H6*D0

    ! 4-#*567*H6*D0 ! 4*@67-DH6*D0 ! d7-6DH6*D0 ! H6D*H6*D0 ! HD%-#H6*D0 ! B7-)*H6*D0+ ! B!C0(*..H6*D0 ! EDG)H6*D0 ! 5*F#H6*D0 ! 567*H6*D0 ! tPLH6*D0 ! H%(*6&){*" ! J-&"5%J-&"H6*D0 ! O&*5%O&*H6*D0
  98. $ python manage.py sqlall app u:)-.)v_%

  99. BEGIN; CREATE TABLE "website_books" ( "id" integer NOT NULL PRIMARY

    KEY, "name" varchar(100) NOT NULL, "created" datetime NOT NULL, "available" bool NOT NULL ); COMMIT; BEGIN; CREATE TABLE "website_books" ( "id" serial NOT NULL PRIMARY KEY, "name" varchar(100) NOT NULL, "created" timestamp with time zone NOT NULL, "available" boolean NOT NULL ); COMMIT;
  100. $ python manage.py syncdb u:)-.)v_%

  101. :%96"&sp.6]& :)C.3-'<165.6& from django.shortcuts import render from app.models import Book

    def vista(request): books = Book.objects.all().order_by('name') return render(request, 'list.html', {'books': books})
  102. w165.6& Book.objects.all() Book.objects.filter(available=True) Book.objects.filter(available=True, name__icontains='Pilares') Book.objects.get(id=145) c6/ M."/65

  103. w165.6& Book.objects.filter(available=True).order_by('name') Book.objects.filter(available=True).order_by('-name') {5965 ?T4"196 Book.objects.filter(available=True).exclude(price__gt=30.0) Book.objects.filter(available=True).order_by('name', 'price')

  104. from django.db.models import Q Book.objects.filter(Q(name__startswith='What') | Q(name__icontains='dog') wdf from django.db.models

    import Q Book.objects.filter(Q(name__startswith='What') | ~Q(name__icontains='dog') %5'3%/+++
  105. 189)/6 Book.objects.all().update(available=True) &.$8"6 Book.objects.all().update(price=F('price') + 10.05) Mdf Book.objects.filter(name__icontains='Pilares' ).update(available=True)

  106. w165.6& %865)9%56& !+@-79%ll*F-@#+o+|| !+@-79%ll6*F-@#+o+|| !+@-79%ll@%&#-6&.+o+|| !+@-79%ll6@%&#-6&.+o+|| Book.objects.filter(name__icontains='Pilares')

  107. !+@-79%ll)#+o+< !+@-79%ll)#*+o+< !+@-79%llD#+o+< !+@-79%llD#*+o+< w165.6& %865)9%56& Book.objects.filter(price__lt=30.0)

  108. !+@-79%ll(-&)*+o+u+Iv !+@-79%ll6&+o+}+I~ Book.objects.filter(price__range=(30.0, 40.0)) w165.6& %865)9%56&

  109. K??+P*D-#*0+O32*@#.

  110. {36K%{36M.6"9 W6")/69'%2=64/& pgM7%+G.-7%.+D-+(*D-@6M&+0*.0*+D-.+6&.#-&@6-.r ? ? class Coche(models.Model): motor = OneToOneField(Motor)

    class Motor(models.Model): ... >>> c.motor <Motor: Motor object> >>> m.coche <Coche: Coche object> [(-@6-.+-+&%.%#(%. [(-@6-.+-+I=)3-%
  111. M%56.-3|6QM.6"9 W6")/69'%2=64/& >>> p.blog <Blog: Blog object> >>> b.post_set.all() [<Post:

    Post object>, ...] pgM7%+G.-7%.+D-+(*D-@6M&+0*.0*+D-.+6&.#-&@6-.r [(-@6-.+-+&%.%#(%. [(-@6-.+-+I=)3-% ? & class Blog(models.Model): ... class Post(models.Model): blog = ForeignKeyField(Blog)
  112. :)3QK%:)3QM.6"9 W6")/69'%2=64/& pgM7%+G.-7%.+D-+(*D-@6M&+0*.0*+D-.+6&.#-&@6-.r & 7 class Post(models.Model): tags = ManyToManyField(Tag)

    class Tag(models.Model): ... >>> p.tags.add(t1, t2) >>> p.tags.all() [<Tag: Tag object>, ...] >>> t.post_set.add(p1, p2) >>> t.post_set.all() [<Post: Post object>, ...] [(-@6-.+-+&%.%#(%. [(-@6-.+-+I=)3-%
  113. K6$8")/6 p.6] p.6] :%96"

  114. K?;+5*79D-#*.

  115. K6$8")/6& P%5 ... <ul> {% for book in books %}

    <li>{{ book.name }}</li> {% endfor %} </ul> ... {'books': [book1, book2, book3]...}
  116. K6$8")/6& P%5 ... <ul> <li>El señor de los anillos</li> <li>Los

    Pilares de la tierra</li> <li>Harry Potter</li> </ul> ...
  117. K6$8")/6& .P'>'6"&6 {% if username == "Juan" %} Hola Juan,

    me gustas! {% else %} Hola {{ username }}! {% endif %}
  118. K6$8")/6& ^"/65& {{ username|length }} "63-/0 12 {{ username|cut }}

    41/ Juanesmajo {{ username|slugify }} &"1-.PQ juan-es-majo {{ username|upper }} 18865 JUAN ES MAJO {{ username|wordcount }} ]%594%13/ 3 {'username': 'Juan es majo'} {{ username|default:”Desconocido” }} 96P)1"/ Desconocido {'username': None }
  119. K6$8")/6& ^"/65& {'username': 'Juan es <b>majo, guapo y <em>listo</em></b>'} {{

    username|striptags }} &/5.8/)-& Juan es majo guapo y listo {{ username|truncatewords_html:4 }} /5134)/6]%59&h0/$" Juan es <b>majo guapo</b> ... {{ username|removetags:”em a br” }} 56$%H6/)-& Juan es <b>majo guapo y listo</b>
  120. K6$8")/6& ^"/65& {'value': 123456789} {{ value|add:”1” }} )99 123456790 {{

    value|filesizeformat }} ^"6&.q6P%5$)/ 117.7MB {{ date|timesince }} #$6&.346 4 days, 6 hours {{ date|timeuntil }} #$613#" 1 days, 6 hours {{ date|date:”d M Y” }} 9)/6 11 Sep 2010 {'date': datetime.datetime(2010, 9, 11, 17, 1, 59, 385323) }
  121. S*(*&@6-+0*+5*79D-#*.

  122. K6$8")/6& 065634.) 3-.*:$#7D $62-:$#7D <html> <head> <title>Mi página personal</title> </head>

    <body> {% block content %} Contenido por defecto. {% endblock %} </body> </html> {% extends "base.html" %} {% block content %} Hola desde la portada. {% endblock %}
  123. p.6] p.6] :%96" K6$8")/6

  124. K?f+02-&)%:@%&#(63:-076&

  125. )9$.3 9=)3-% 1 2 3

  126. 1 2 3 )9$.3 9=)3-%

  127. 1 )9$.3 9=)3-%

  128. None
  129. !+H%(7. !+J%0*DH%(7. !+g%&#*F#!(%@*..%(. !+J600D*R-(*. !+6?=& !+@-@$* !+:::

  130. K?WI+K?VI+K?Y+:::+C99.

  131. )88& &%1/0 Z+E6.#*7-+6&#*D6)*&#*+9-(-+(*-D6\-(+0*+7-&*(-+-G#%7b/@-+ 76)(-@6%&*.+0*+*.NG*7-.: ZpsG*+.G@*0*+.6+#*&)%+G&+J%0*D%+@%&+?<<:<<<+]D-.+"+NG6*(%+-a-06(+ G&-+@%DG7&-r+:::+.%G#$m Zc*@*.6#%+76)(-(+*D+@%&#*&60%+0*.0*+76+-&/)G%+J%0*D%+-+G&%+ &G*Q%:::+.%G#$m Zc*@*.6#%+NG*+:::+.%G#$m $k9ee.%G#$:-*(-@%0*:%()e

  132. )88& &%1/0 $k9ee.%G#$:-*(-@%0*:%()e $ python manage.py schemamigration website --initial 456)5'85.$65'&406$)

    $ python manage.py schemamigration website --auto 456)5'e\a'$.-5)4.r3 $ python manage.py migrate )8".4)5'$.-5)4.%36&
  133. )88& 0)Q&/)4C Z+^dL_+E6.#*7-+0*+3Ä.NG*0-.+9-(-+42-&)% Z+HG&@6%&-+@%&+Q-(6%.+.6.#*7-.+0*+B&0*F-@6M& Z+E%D(I+Å-96-&I+Ç$%%.$ Z+H*-#G(*. Z+ÉJ%(*+D68*+#$6.x ZH-@*/&) ZS6)$D6)$/&) Z+E9*DD6&)+EG))*./%&

    Z+*#@:::
  134. )88& 9=)3-%\9621-\/%%"2)5

  135. )88& 46"65Q ZE6.#*7-+0*+5-(*-.+C.T&@(%&-.+06.#(63G60-.: ZH*-#G(*.+g%D-.I+g%&@G((*&@6-I+46.#(63G60%::: ZJG"+Ab@6D+679D*7*&#-@6M&+"+*.@-D-3D*: }V)&%&'85k4#4%&~ Zd&Q6-(+G&+*7-6D Zg-D@GD-(+*D+8-(7-+0*+0*+D%.+G.G-(6%.+0*D+.6.#*7-: Z5-(*-.+9(%)(-7-0-.+uL6796*\-I+!%.#>9(%@*.-0%I+*#@:::v

  136. )88& 46"65Q from celery.decorators import task @task def add(x, y):

    return x + y >>> result = add.delay(4, 4) >>> result.wait() # wait for and return the result 8
  137. )88& &63/5Q

  138. )88& 4%$$)39\6T/63&.%3 Z+dF#*&.6M&+9-(-+^7-&-)*:9"_ Z+JG@$-.+G/D60-0*.+9-(-+*D+0T-+-+0T- Z+t&-+0*+D-.+7*2%(*.+)(-9$l7%0*D. Z+t.-&0%+[(-9$z6\+)*&*(-+G&+7%0*D%+(*D-@6%&-D+0*+D%.+ 7%0*D%.+0*+&G*.#(%+9(%"*@#%:

  139. None
  140. 9)=)T85%=64/+4%$

  141. Z+E*#+0*+D63*(T-.+C'CÅ+9-(-+02-&)%: Z+02-&)%>0-2-F6@* Z+g%(*+0*+@%7G&6@-@6M&: Z+d&Q6-(+6&A%(7-@6M&+-."&@(%&-7*&#*: Z+02-&)%>0-2-F Z+7-&69GD-(+*D+4OJ+G.-&0%+!"#$%&: 9)=)T85%=64/+4%$

  142. g%77G&6@-/%&+G&6A%(7*+*&#(*+*D+@D6*&#*+"+*D++ .*(Q60%(+: Z+C)&%./@%+-+@G-DNG6*(+H(-7*R%(8+'E: Z+!(%#%#"9*I+2sG*("I+*#@::: Z+LM)6@-+0*+9(*.*&#-@6M&+AG*(-+0*+D-.+Q6.#-.: Z+g(%..3(%R.6&): {2=6#H%&'9)=)T.46

  143. ?=6$8"% from django.utils import simplejson from dajaxice.decorators import dajaxice_register @dajaxice_register

    def my_example(request): return simplejson.dumps({'message':'Hello World'}) Si. es una funcion que retorna json.
  144. ?=6$8"% function on_whatever(){ Dajaxice.example.my_example(my_js_callback); } app function name callback

  145. ?=6$8"% function my_js_callback(data){ alert(data.message); } callback your stuff

  146. Z+J-&69GD-(+*D+4OJ+G.-&0%+!"#$%&: Z+E6&+&*@*.60-0+0*+@%&%@*(+'E+*&+9(%AG&060-0: Z+E%9%(#-+H(-7*R%(8.+@%7% {2=6#H%&'9)=)T

  147. ?=6$8"% from dajax.core.Dajax import Dajax def assign_test(request): dajax = Dajax()

    dajax.assign('#list li','innerHTML','Hello!') dajax.add_css_class('#list li','new') ... return dajax.json() tus acciones
  148. ?=6$8"% function on_whatever(){ Dajaxice.app.assign_test(Dajax.process); } Dajax callback

  149. dD+E#-@8

  150. 3-.3T'~gA -13.4%53 I=)3-% oUc['U65H65 M5%3/639 I68"%Q &634.""% ]%5C65'@ ]%5C65'e ]%5C65'3

  151. -13.4%53 I=)3-% 3-.3T'~gA ]62@ -13.4%53 I=)3-% 3-.3T'~gA ]62e -13.4%53 I=)3-%

    3-.3T'~gA ]623 3-.3T'~gA'~BBt H)53.&0 0)85%TQ P5%3/639@ 3-.3T'~gA'~BBt H)53.&0 0)85%TQ P5%3/639e .8P)."%H65 I68"%Q 3%'/)3'&634.""%
  152. K?W+H-3(6@

  153. P*9*//%&+D*-0.+#%+3%(*0%7I 3%(*0%7+#%+$%((6A"6&)+76.#-8*.I $%((6A"6&)+76.#-8*.+#%+[%0>B>R6.$>B>R-.>./DD>3%(*0: “

  154. $ fab deploy -R test

  155. $ fab deploy -R www

  156. env.user = "example" env.hosts = ["web1.com", "web2.com", "..."] def deploy():

    run('git pull /home/site/') sudo('service supervisord restart')
  157. L-+9G&#-+0*D+6@*3*()

  158. p!(*)G&#-.r