def create_items(self, session_items):
pks = list(session_items.keys())<EOL>items = {}<EOL>item_class = self.item_class<EOL>process_object = self.process_object<EOL>for obj in self.get_queryset(pks):<EOL><INDENT>pk = str(obj.pk)<EOL>obj = process_object(obj)<EOL>items[pk] = item_class(obj, **session_items[pk])<EOL><DEDENT>if len(items) < len(session_items):<EOL><INDENT>self._stale_pks = set(session_items).difference(items)<EOL><DEDENT>return items<EOL>
Instantiate cart items from session data.

        The value returned by this method is used to populate the
        cart's `items` attribute.

        Parameters
        ----------
        session_items : dict
            A dictionary of pk-quantity mappings (each pk is a string).
            For example: ``{'1': 5, '3': 2}``.

        Returns
        -------
        dict
            A map between the `session_items` keys and instances of
            :attr:`item_class`. For example::

                {'1': <CartItem: obj=foo, quantity=5>,
                 '3': <CartItem: obj=bar, quantity=2>}