title: Create and save django object on click
body: <p>I have a shoppinglist app. I want that when the user clicks on "add to shopping list" the item is saved to the shopping list.</p>
  
  <p>How can I do that?</p>
  
  <p>in the template I wrote:</p>
  
  <pre><code>&lt;a href="javascript:{document.getElementById('add_item').submit()}" class="btn btn-primary btn-block"&gt;Add to
  shopping list
  &lt;/a&gt;
  &lt;form action="{% url 'add_to_shopping_list' product.id %}" id="add_item" method="POST"&gt;
      {% csrf_token %}
      &lt;input type="hidden"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>in <code>urls.py</code> I dispaced the urls like this:</p>
  
  <pre><code>urlpatterns = [
      path('add_to_shopping_list/&lt;int:pk&gt;', views.add_to_shopping_list, name='add_to_shopping_list'),
  ]
  
  </code></pre>
  
  <p>this calls the view <code>add_to_shopping_list</code> where I want create a ShoppingItem object and to link this to the Product object. The problem is that I don't want to redirect the user anywhere, but just stay on the same page without refreshing. But the view wants me to return an HtmlResponse, or I get this error:</p>
  
  <pre><code>The view shoppinglist.views.add_to_shopping_list didn't return an HttpResponse object. It returned None instead.
  </code></pre>
  
  <p>Is the idea correct? If yes how can I solve this problem?
  Thanks</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>here is the <code>view.py</code>, this is just the idea, I could not debug it</p>
  
  <pre><code>from . models import ShoppingItem
  from products.models import Product
  
  def add_to_shopping_list(request, pk):
      item = Product.objects.get(pk=pk)
      shopping_list = request.user.shopping_lists.all()[0]
      product = ShoppingItem(name=item.name, list=shopping_list, price=item.price)
      product.save()
      return ???
  </code></pre>
  
  <p>The Product object already exists, but I need to create a ShoppingItem object that is associated to that shopping list that belongs to that user.</p>