Permalink
Browse files

Merge pull request #2 from adieu/bookmarkinstance-save-bug

Fixed the bug preventing editing existing BookmarkInstance object.
  • Loading branch information...
2 parents 2ea9ced + 4364114 commit 671ef391f9266ade0456fe80ee00e227bfabb6f0 @paltman paltman committed Jan 4, 2013
Showing with 8 additions and 7 deletions.
  1. +8 −7 bookmarks/models.py
View
@@ -67,13 +67,14 @@ class BookmarkInstance(models.Model):
tags = TaggableManager()
def save(self, force_insert=False, force_update=False):
- try:
- bookmark = Bookmark.objects.get(url=self.url)
- except Bookmark.DoesNotExist:
- # has_favicon=False is temporary as the view for adding bookmarks will change it
- bookmark = Bookmark(url=self.url, description=self.description, note=self.note, has_favicon=False, adder=self.user)
- bookmark.save()
- self.bookmark = bookmark
+ if getattr(self, 'url', None):
+ try:
+ bookmark = Bookmark.objects.get(url=self.url)
+ except Bookmark.DoesNotExist:
+ # has_favicon=False is temporary as the view for adding bookmarks will change it
+ bookmark = Bookmark(url=self.url, description=self.description, note=self.note, has_favicon=False, adder=self.user)
+ bookmark.save()
+ self.bookmark = bookmark
super(BookmarkInstance, self).save(force_insert, force_update)
def delete(self):

0 comments on commit 671ef39

Please sign in to comment.