Yes, you are right.

On Sat, Jul 13, 2013 at 7:07 PM, Victor Rocha <vicoro...@gmail.com> wrote:

> This is a wild guess but I do not see the login_required decorator on your
> view. I think you are getting this error because you are trying to save an
> Bookmark object passing an anonymous user as one of your arguments. An
> anonymous user is a SimpleLazyObject; it is a user but there is no
> reference to it on your databases. The Bookmark foreign key expects to
> point to user instance on the users table.
>
> Thank you,
> Victor Rocha
> www.RochApps.com
>
>
>
> On Friday, July 12, 2013 2:45:00 PM UTC-4, Kakar wrote:
>>
>> I've got a TypeError:
>>
>> int() argument must be a string or a number, not 'SimpleLazyObject'
>>
>>
>> Here's my view:
>>
>> 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 bookmarks.
>>             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)
>>
>> I really don't know what's going on here. Please guide me.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to