I am a beginner in django/python * :(*

I am making a dashboard of sellers App.
I am stuck in filtering orders of the products according to the logged in 


from django.conf import settings
from django.core.urlresolvers import reverse
from django.db import models
from django.contrib.auth.models import User

class SellerAccount(models.Model):
    user = models.ForeignKey(User)
    managers = models.ManyToManyField(settings.AUTH_USER_MODEL, 
related_name="manager_sellers", blank=True)
    active = models.BooleanField(default=False)
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)

    def __unicode__(self):
        return str(self.user.username)

    def get_absolute_url(self):
        return reverse("products:vendor_detail", kwargs={"vendor_name": 


class Order(models.Model):
    status = models.CharField(max_length=120, choices=ORDER_STATUS_CHOICES, 
    cart = models.ForeignKey(Cart)
    user = models.ForeignKey(UserCheckout, null=True)
    billing_address = models.ForeignKey(UserAddress, 
related_name='billing_address', null=True)
    shipping_address = models.ForeignKey(UserAddress, 
related_name='shipping_address', null=True)
    shipping_total_price = models.DecimalField(max_digits=50, 
decimal_places=2, default=5.99)   
    order_total = models.DecimalField(max_digits=50, decimal_places=2, )
    order_id = models.CharField(max_length=20, null=True, blank=True)
    paymethod = models.CharField(max_length=120, choices=CHOICES, 

    def __unicode__(self):
        return str(self.cart.id)


import datetime

from django.db.models import Count, Min, Sum, Avg, Max

from dress.mixins import LoginRequiredMixin
from orders.models import Transaction, Order
from products.models import Product

from .models import SellerAccount

class SellerAccountMixin(LoginRequiredMixin, object):
    account = None
    products = []
    transactions = []
    orders = []

    def get_account(self):
        user = self.request.user
        accounts = SellerAccount.objects.filter(user=user)
        if accounts.exists() and accounts.count() == 1:
            self.account = accounts.first()
            return accounts.first()
        return None

    def get_products(self):
        account = self.get_account()
        products = Product.objects.filter(seller=account)
        self.products = products
        return products

   def get_sold_products(self):
        products = self.get_products()
          THIS IS THE PROBLEM AREA ????? i want to show orders of the 
products i got from (products = self.get_products()).
        keeping this thing in mind that order is completed if its status 
set to be 'paid'....
        In other words i want to show products of the user that is logged 
in if the status of that products are paid.
        sold = Order.objects.all().filter('products')
        return sold


class SellerDashboard(SellerAccountMixin, FormMixin, View):
    form_class = NewSellerForm
    success_url = "/seller/"
            context["products"] = self.get_products()
            context["sold_products"] = self.get_sold_products()


{{ sold_products }}

i hope someone will definitely figure out my problem....

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to