Answer the question
In order to leave comments, you need to log in
How to organize a wishlist in a django online store project?
Good afternoon, in my own interests, I am writing a store engine, tell me how to organize a wishlist, or tell me some thread of a tablet for this? I tried to use django-wishlist but as they say it didn't work right out of the box ^(
Answer the question
In order to leave comments, you need to log in
Why a battery for such a simple thing?
class Wish(models.Model):
customer = models.ForeignKey(User)
item = models.ForeignKey(Product)
class Meta:
unique_together = ['customer', 'item']
class WishCreate(CreateView):
model = Wish
fields = ['item']
def form_valid(self, form):
obj = form.save(commit=False)
obj.customer = self.request.user
obj.save()
return http.HttpResponseRedirect(self.get_success_url())
class WishDelete(DeleteView):
model = Wish
success_url = reverse_lazy('wish-list')
class WishList(ListView):
model = Wish
def get_queryset(self):
return Wish.objects.filter(customer=self.request.user)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question