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


This is the model table.

 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

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)
        return reverse('books.html')

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

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

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