<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def slice(self, order_by='pk', n=None):
 """ return n objects according to specified ordering """

        if n is not None and n < 0:
            raise ValueError('slice parameter cannot be negative')
        
        queryset = self.order_by(order_by)
        
        if n is None:
            return queryset[0]
        else:
            return queryset[0:n]