請幫忙避免重複的代碼。如何削減記錄?
我需要首先調用get_count_authors_entries()get_new_authors_entries的()
from django.db import models
from django.contrib.auth.models import User, UserManager
class UserProfile(User):
phone = models.CharField(
max_length=50,
blank=False,
)
skype = models.CharField(
max_length=50,
blank=False,
)
@classmethod
def get_new_authors_entries(self):
return self.objects.filter(is_active=1, is_superuser=0).order_by('-date_joined')
@classmethod
def get_count_authors_entries(self):
return self.objects.filter(is_active=1, is_superuser=0).order_by('-date_joined').count()