AngularJS で処理したいタグの周りを verbatim ~ endverbatim タグで囲むことで Django が {{ }} を処理するのを防ぎます。
<body ng-app="TestApp"> <div ng-controller="TestController as tc"> {% verbatim %} <p>{{ tc.message }}</p> {% endverbatim %} </div>
<body ng-app="TestApp"> <div ng-controller="TestController as tc"> {% verbatim %} <p>{{ tc.message }}</p> {% endverbatim %} </div>
<input is="core-input" id="input_records" required type="text" min="1" pattern="/^[\s]*[0-9]+[\s]*(,[\s]*[0-9]+[\s]*)*$/">
<input type="date" required id="input_date" name="date" value="{{ date }}">
Polymer({ date: new Date().toISOString().substr(0, 10), ...
Polymer({ date: new Date(), ready: function() { this.$.input_date.valueAsDate = this.date; }
<paper-input-decorator label="" error="入力必須" isInvalid="{{!$.input_name.validity.valid}}"> <input is="core-input" id="input_name" required type="text" value="{{ name }}"> </paper-input-decorator> <paper-button on-click="{{ post_data }}"></paper-button> <core-ajax id="post" url="/someurl" method="post" handleAs="json" on-core-response="{{ response }}" on-core-error="{{ error }}"> </core-ajax>
post_data: function() { if(!this.$.input_name.validity.valid){ alert("名前を入力してください"); } else { var data = { 'name': this.name, }; this.$.post.body = "data=" + JSON.stringify(data); this.$.post.go(); } }, response: function (event, response) { }, error: function(event, response) { }
class ActivityInfoListApi(View): def post(self, request, *args, **kwargs): data = request.POST.get("data", None) if data is None or len(data) == 0: return HttpResponseBadRequest() obj = json.loads(data) try: name = obj["name"] # 型チェック if (not isinstance(name, str) and not isinstance(name, unicode)): return HttpResponseBadRequest() # 受け取った値で何か処理… return HttpResponse("json形式文字列…") except KeyError: logging.error("Missing Parameter") return HttpResponseBadRequest()
<link rel="import" href="/bower_components/polymer/polymer.html"> <link rel="import" href="/bower_components/paper-button/paper-button.html"> <link rel="import" href="/bower_components/paper-dialog/paper-action-dialog.html"> <link rel="import" href="/bower_components/core-style/core-style.html"> <core-style id="my-dialog-style"> html /deep/ { width: 16px; height: 16px; } html /deep/ paper-action-dialog::shadow #scroller { width: 360px; height: 360px; } </core-style> <core-style ref="my-dialog-style"></core-style> <polymer-element name="my-paper-action-dialog" attributes="toggle"> <template> <style> :host { position: absolute; width: 100%; height: 100%; } </style> <paper-action-dialog id="dialog"> <div> ... </div> <paper-button dismissive>CANCEL</paper-button> <paper-button affirmative>OK</paper-button> </paper-action-dialog> </template> <script> Polymer({ toggle: function () { this.$.dialog.toggle(); } }); </script> </polymer-element>
Chart.defaults.Radar.pointLabelFontSize = 16; // 少し大きく(デフォルトは 10) Chart.defaults.Radar.pointLabelFontColor = 0x00FFFFFF; // 赤
「教えてください、あなたは何をするのですが/その激しくかけがえのない一度きりの人生で」 メアリー・オリバー
from django.views.decorators.csrf import csrf_exempt .... url(r'^category$', csrf_exempt(MyViewClass.as_view())),
fetched_list = MyModel.query().fetch() json_without_keyid = json.dumps([c.to_dict() for c in fetched_list ]) json_with_keyid = json.dumps([dict(c.to_dict(), **dict(id=c.key.id())) for c in fetched_list ])
from datetime import date class JSONDateEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, date): return obj.isoformat() return json.JSONEncoder.default(self, obj) fetched_list = MyModel.query().fetch() json_without_keyid = json.dumps([c.to_dict() for c in fetched_list ], cls=JSONDateEncoder) json_with_keyid = json.dumps([dict(c.to_dict(), **dict(id=c.key.id())) for c in fetched_list ], cls=JSONDateEncoder)
The corporation cannot refuse to take a stand on public issues of major concern.
(...) world coöperation is our business, because without it there might be no world and there fore no business.
You can’t just be bland, or you throw away your influence. But you can’t take a stand on every major issue, either.