fork download
  1. class Bookmark(models.Model):
  2. user = models.ForeignKey(User)
  3. profile = models.ForeignKey(OdeskProfileData)
  4.  
  5. url(r'^add_remove_bookmark/(\d+)/(\d+)/$', 'Registry.views.add_remove_bookmark'),
  6.  
  7.  
  8. @login_required
  9. def add_remove_bookmark(request,uid, qid):
  10. try:
  11. bookmark = Bookmark.objects.get(user=uid, profile=qid)
  12. bookmark.delete()
  13. except Bookmark.DoesNotExist:
  14. bookmark = Bookmark.objects.create(
  15. user=User.objects.get(id=uid),
  16. profile=OdeskProfileData.objects.get(id=qid))
  17. bookmark.save()
  18. return HttpResponseRedirect('/bookmarks/' + qid)
Runtime error #stdin #stdout #stderr 0.02s 8688KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
NameError: name 'models' is not defined