Hi

When i do login using Django Admin Panel , i can easily perform CRUD
operation on Models.

can i customize the display of Models Records in django Admin Panel Itself,
when I select the model, I get all the records, But i want to filter the
records based on some Criteria.

Here is my model . Code executes.



class EmployeeManager(models.Manager):
        def get_queryset(self):
            return super(EmployeeManager,
self).get_queryset().filter(gender='F')





class Employee(models.Model):
      gender_choices = (
           ("M", "Male"),
           ("F", "Female")
      )
      roles_choices = (
           ("J", "Junior"),
           ("S", "Senior"),
      )
      first_name = models.CharField(max_length=200)
      last_name = models.CharField(max_length=200)
      email = models.CharField(max_length=250)
      gender = models.CharField(max_length=1, choices=gender_choices)
      role = models.CharField(max_length=120, choices=roles_choices,
default="J")
      active = models.BooleanField(default=True)

      # custom manager replaces objects manger
      all_employees = models.Manager()
      objects = models.Manager() # The default manager.
      active_objects = EmployeeManager() # The EmployeeManager manager.

      def __str__(self):
            return str(self.first_name) + str(self.last_name)

>From Shell, it executes.

    # Employee.active_objects.all()
    # Employee.active_objects.filter(email='[email protected]')
    # Employee.active_objects.count()

Source:
https://micropyramid.com/blog/how-to-add-a-custom-managers-in-django/

When

My Query is can i show the filtered record in directly Django Admin Panel
after doing Login based on Logged User Username.


-- 


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: [email protected] <[email protected]> *
*  Mobile: +91-9270696267*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAECSbOtQFeybd186pYSPuOThUvp3CgW7tf-p5hJzg92%2B5q84Pw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to