Skip to content

Instantly share code, notes, and snippets.

@runekaagaard
Last active November 2, 2019 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runekaagaard/469968d8d27330621fb493d962b5d61e to your computer and use it in GitHub Desktop.
Save runekaagaard/469968d8d27330621fb493d962b5d61e to your computer and use it in GitHub Desktop.
state = {
"users":
User.mutable.all() > {
"tags": Tag.mutable.up().all(),
},
"movie":
Movie.mutable.get(pk=91) > {
"actors": Actor.mutable.up().all(),
"style": Style.mutable.up().get(),
}
}
with mutate():
state.users[5].name = "Mark Mark"
state.movie.watched += 1
state.users[1].tags.append(Tag(tag="scify"))
del state.movie.actors[4]
print state.users[5].did_change() # True
print state.users[4].did_change() # False
"""
{% loop user in state.users <div> %}
{{user.email}}
{% for tag in user.tags %}
<li>{{tag.tag}}</li>
{% endfor %}
{% endloop %}
{% item movie <div> %}
{{movie.title}}
{% loop actor in movie.actors <li> %}
{{actor.name}}
{% endloop %}
{% enditem %}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment