how to add two different tables data in one table through button in django without form

urls.py

path('books/<int:book_id>/',addfavourite,name='addfavourite')
 

This is the model table.

models.py

 class Library(models.Model):
        user = models.ForeignKey(User,on_delete=models.CASCADE)
        book = models.ForeignKey(Book,on_delete=models.CASCADE,related_name='library')
        def __int__(self):
            return self.library_id

views.py

def addfavourite(request, pk):
    userid = auth.get_user(request)
    bookdetail = get_object_or_404(Book, pk=pk)
    if request.user.is_authenticated:
        favourite = Library()
        favourite = Library.objects.create(user=userid,book=bookdetail)
        favourite.save()
    else:
        return reverse('books.html')

The button to add data as no user value is needed.

<button type="submit" href="{% url 'addfavourite' bookdetail.pk %}" class="button">

I am not getting error but the data is not created in table.