title: How to get input value from templates and store to database [Django]
body: <p>I'm trying to get <strong>{{ id }}</strong> when user clicks on movie and save it to models. I can't use modelForm because id parameter comes from html template. Any suggestions?</p>
  <p>Maybe, there is a different way to get an id of that movie user clicks?</p>
  <p>Btw, I'm using tmdb api.</p>
  <pre><code>{% for id, poster in poster_id_zip %}
      &lt;div style=&quot;display: inline-block; margin: 10px;&quot; class=&quot;&quot;&gt;
        &lt;a href=&quot;{{ movie_details }}&quot;&gt;&lt;img src=&quot;{{ poster }}&quot; alt=&quot;&quot;&gt;&lt;/a&gt;
        &lt;form class=&quot;add-movie-form&quot; method=&quot;POST&quot;&gt;
          {% csrf_token %}
          &lt;input type=&quot;hidden&quot; name=&quot;movie-id&quot; value=&quot;{{ id }}&quot;&gt;
          &lt;button style=&quot;display: block; margin: 5px auto 0 auto;&quot; type=&quot;submit&quot; name=&quot;add&quot;&gt;Add&lt;/button&gt;
        &lt;/form&gt;
      &lt;/div&gt;
  {% endfor %}
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre><code>def index(request):
      api_key = &quot;api_key&quot;
      image_base_url = &quot;https://image.tmdb.org/t/p/&quot;
      if request.method == &quot;POST&quot;:
          user_query = request.POST.get('search-box', ' ')
          if user_query == '':
              user_query = ' '
  
          search_movies_url = &quot;https://api.themoviedb.org/3/search/movie?api_key={}&amp;query={}&quot;.format(api_key, user_query)
  
          search_results_data = requests.get(search_movies_url)
  
          total_results = search_results_data.json().get(&quot;total_results&quot;) # for handling no search results
  
          movie_ids, poster_path, poster_full_url = [], [], []
  
          for movie in search_results_data.json().get(&quot;results&quot;):
              movie_ids.append(movie.get(&quot;id&quot;))
              poster_path.append(movie.get(&quot;poster_path&quot;))
  
          for poster in poster_path:
              poster_full_url.append(image_base_url+&quot;{}{}&quot;.format(&quot;w185&quot;, poster))
  
          movie_details = &quot;https://api.themoviedb.org/3/movie/{}?api_key={}&quot;.format(movie_ids, api_key)
  
          poster_id_zip = zip(movie_ids, poster_full_url) # grouping ids with poster images
  
          context = {&quot;movie_ids&quot;: movie_ids, &quot;poster_url&quot;: poster_full_url, &quot;movie_details&quot;: movie_details, &quot;poster_id_zip&quot;: poster_id_zip, &quot;total_results&quot;: total_results,}
  
          return render(request, 'homepage/movies.html', context)
      return render(request, 'homepage/index.html')
  </code></pre>
  <p><strong>models.py</strong></p>
  <pre><code>from django.db import models
  
  # Create your models here.
  
  class MovieId(models.Model):
      movie_id = models.IntegerField()
      def __str__(self):
          return self.movie_id
  </code></pre>