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
"""Illustration for various types of namespace scopes in TensorFlow. | |
> python tf_scopes.py | |
foo_name_scoped : | |
v.name= v:0 | |
v2.name= foo_name_scoped/v2:0 | |
a.name= Variable:0 | |
b.name= Variable_1:0 | |
result_op.name= foo_name_scoped/Add:0 | |
foo_op_scoped : |
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
==== SNIP ==== | |
class DistanceSerializer(serializers.Serializer): | |
km = serializers.FloatField() | |
m = serializers.FloatField() | |
mi = serializers.FloatField() | |
ft = serializers.FloatField() | |
class SearchResultSerializer(serializers.Serializer): |
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
def forwards(self, orm): | |
for a in orm.Author.object.all(): | |
try: | |
a.first_name, a.second_name = a.name.split(" ") | |
except: | |
a.first_name, a.second_name = a.name, "" | |
c.save() | |
def backwards(self, orm): | |
for a in orm.Author.object.all(): |
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.db.models import signals | |
from tags.models import Tag | |
def create_tags(app, created_models, **kwargs): | |
Tag.objects.get_or_create(name="Architecture") | |
Tag.objects.get_or_create(name="Art") | |
Tag.objects.get_or_create(name="Books") | |
Tag.objects.get_or_create(name="Cars & Motorcycles") | |
Tag.objects.get_or_create(name="DIY & Crafts") |