title: Creating django api view that returns filtered objects
body: <p><strong>Problem Description</strong><br />
  I'm new to django-rest-framework and got a problem in my view. I have three models namely #User, #Profession and #StudentProfessions. I need to create an api-view that takes user_id as request-parameter and returns a list of all professions that belongs to a particular user_id.</p>
  <p><strong>Here's My Codes</strong></p>
  <p><strong>profession_app &gt;&gt; models.py</strong></p>
  <pre><code>from django.db import models
  
  class Profession(models.Model):
      profession_name = models.CharField(max_length=100)
  
      def __str__(self):
          return self.profession_name
  </code></pre>
  <p><strong>User Model</strong></p>
  <p>I used the django default model.</p>
  <p><strong>student_profile_app &gt;&gt; models.py</strong></p>
  <pre><code>
  from django.contrib.auth.models import User
  from department_app.models import Department
  from profession_app.models import Profession
  from program_app.models import Program
  from django.db import models
  
  class StudentProfile(models.Model):
      student_status = models.BooleanField()
      phone_number = models.CharField(max_length=100)
      year_of_study = models.CharField(max_length=100)
      program_id = models.ForeignKey(Program, on_delete=models.CASCADE)
      student_id = models.OneToOneField(User, on_delete=models.CASCADE, related_name=&quot;student_id&quot;)
      organization_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name=&quot;organization_id&quot;)
      profile_image = models.ImageField(upload_to='images/', blank=True)
      field_supervisor_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name=&quot;field_supervisor&quot;)
      department_id = models.ForeignKey(Department, on_delete=models.CASCADE)
      academic_supervisor_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name=&quot;academic_supervisor&quot;)
  
      def __str__(self):
          return f'{self.student_id.username } Profile'
  
  
  class StudentProfession(models.Model):
      student_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name=&quot;student_profession_id&quot;)
      profession_id = models.ForeignKey(Profession, on_delete=models.CASCADE)
  
      def __str__(self):
          return f'{self.student_id.username } Profession' 
  </code></pre>
  <p><strong>student_profile_app &gt;&gt; views.py</strong></p>
  <pre><code>from .models import StudentProfile, StudentProfession
  
  def getStudentProfessions(request, studentId):
      professions = StudentProfession.objects.filter(student_id=studentId)
      return professions
  </code></pre>
  <p><strong>And In My urls</strong></p>
  <pre><code>from student_profile_app.views import getStudentProfessions
  from rest_framework import routers
  
  router.register('getStudentProfessions/&lt;int:studentId&gt;', getStudentProfessions, 'getStudentProfessions')
  
  urlpatterns = router.urls
  </code></pre>
  <p><strong>But when i run the server i got the following error</strong></p>
  <pre><code>    urlpatterns = router.urls
    File &quot;E:\Codes\FIP\fipEnv\lib\site-packages\rest_framework\routers.py&quot;, line 77, in urls
      self._urls = self.get_urls()
    File &quot;E:\Codes\FIP\fipEnv\lib\site-packages\rest_framework\routers.py&quot;, line 338, in get_urls
      urls = super().get_urls()
    File &quot;E:\Codes\FIP\fipEnv\lib\site-packages\rest_framework\routers.py&quot;, line 236, in get_urls
      routes = self.get_routes(viewset)
    File &quot;E:\Codes\FIP\fipEnv\lib\site-packages\rest_framework\routers.py&quot;, line 152, in get_routes
      extra_actions = viewset.get_extra_actions()
  AttributeError: 'function' object has no attribute 'get_extra_actions'
  </code></pre>