Advertisement
Guest User

Untitled

a guest
Aug 30th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. # view
  2. def music_add(request, music_id=None):
  3.     if music_id is not None:
  4.         operationType = "Alteração"
  5.         music = get_object_or_404(Music, pk=music_id)
  6.     else:
  7.         operationType = "Cadastro"
  8.         music = None
  9.     { ... }
  10.     if music_id:
  11.         context = {'form':form, 'music_id':music_id, 'operationType':operationType,}
  12.     else:
  13.         context = {'form':form, 'operationType':operationType,}
  14.     return render(request, 'repertory/music_add.html', context)
  15.  
  16. # template
  17. <h2>{{ operationType }} de Música</h2>
  18. {% if music_id %}
  19. <form enctype="multipart/form-data" action="{% url 'repertory:music_edit' music_id %}" method="post">
  20. {% else %}
  21. <form enctype="multipart/form-data" action="{% url 'repertory:music_add' %}" method="post">
  22. { ... }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement