title: Unable to make dynamic variables in views and url of DJANGO Rest Framework
body: <p>I was trying create a api like &quot;http://127.0.0.1:8000/api/data/year&quot;.
  but i am not able to do it, unable to dynamic the year in the endpoint.  Please check the urls.py
  2nd problem - i want to make requestedYear as dynamiic in views.py.</p>
  <p>Reference files are mentioned below. Please check.</p>
  <p><strong>models.py</strong></p>
  <pre><code>class DataModel(models.Model):
      city = models.CharField(max_length=100)
      date = models.DateField(editable=True)
  </code></pre>
  <p><strong>serializers.py</strong></p>
  <pre><code>class DataSerializer(serializers.ModelSerializer):
      YearOfDate = serializers.SerializerMethodField()
      class Meta:
          model = DataModel
          fields = ['id', 'city', 'date', 'YearOfDate']
      def get_YearOfDate(self, obj):
          return obj.date.year
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre><code>class DataListView(generics.ListAPIView):
      serializer_class = DataSerializer
      model = DataModel
      queryset = model.objects.all()
      def get_queryset(self):
          requestedYear = 2009
          return DataModel.objects.filter(date__year=requestedYear)
  </code></pre>
  <p><strong>urls.py</strong></p>
  <pre><code>urlpatterns = [ path('admin/', admin.site.urls), 
  path('api/data/2009', views.DataListView.as_view()),
  #re_path(r'^api/match/(?P&lt;year&gt;[0-9]{4})/$', views.DataListView.as_view()),]
  
  </code></pre>