def bookmark_save_page(request): if request.method == 'POST': form = BookmarkSaveForm(request.POST) if form.is_valid(): # Create or get link. link, dummy = Link.objects.get_or_create( url=form.cleaned_data['url'] ) # Create or get bookmark. bookmark, created = Bookmark.objects.get_or_create( user=request.user, link=link ) # Update bookmark title. bookmark.title = form.cleaned_data['title'] # If the bookmark is being updated, clear old tag list. If not created: bookmark.tag_set.clear() # Create new tag list. tag_names = form.cleaned_data['tags'].split() for tag_name in tag_names: tag, dummy = Tag.objects.get_or_create(name=tag_name) bookmark.tag_set.add(tag) # Save bookmark to database. bookmark.save() return HttpResponseRedirect( '/user/%s/' % request.user.username ) else: form = BookmarkSaveForm() variables = RequestContext(request, { 'form': form }) return render_to_response('bookmark_save.html', variables)
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
def bookmark_save_page(request): if request.method == 'POST': form = BookmarkSaveForm(request.POST) if form.is_valid(): # Create or get link. link, dummy = Link.objects.get_or_create( url=form.cleaned_data['url'] ) # Create or get bookmark. bookmark, created = Bookmark.objects.get_or_create( user=request.user, link=link ) # Update bookmark title. bookmark.title = form.cleaned_data['title'] # If the bookmark is being updated, clear old tag list. If not created: bookmark.tag_set.clear() # Create new tag list. tag_names = form.cleaned_data['tags'].split() for tag_name in tag_names: tag, dummy = Tag.objects.get_or_create(name=tag_name) bookmark.tag_set.add(tag) # Save bookmark to database. bookmark.save() return HttpResponseRedirect( '/user/%s/' % request.user.username ) else: form = BookmarkSaveForm() variables = RequestContext(request, { 'form': form }) return render_to_response('bookmark_save.html', variables)