'Creating a shopping List in Django Admin

I am trying to show the shopping Cart for only a specific user in the Django Admin template . I managed to do it in a normal views like this :

order = Order.objects.get(user=self.request.user, ordered=False)

but when trying to do the same inside the model

items = models.ManyToManyField(OrderItem.objects.get(user=settings.AUTH_USER_MODEL))

I get this error

django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

What I'm trying to achieve is to only show the items that the user entered to his shopping cart instead of all the order items in the system so is there a way to filter what is shown in the admin panel based on the user



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source