Created
July 15, 2014 15:25
-
-
Save siddartha/f3309730edb246ce2667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib.auth.models import User | |
# Create your models here. | |
class Site(models.Model): | |
user = models.ForeignKey(User) | |
site = models.CharField(max_length=255) | |
def __unicode__(self): | |
return self.site | |
class Inventory(models.Model): | |
site = models.ForeignKey(Site) | |
date = models.DateField() | |
impressions = models.IntegerField(default=0) | |
clics = models.IntegerField(default=0) | |
ctr = models.FloatField(default=0) | |
cpc = models.FloatField(default=0) | |
ecpm = models.FloatField(default=0) | |
earnings = models.FloatField(default=0) | |
def __unicode__(self): | |
return str(self.date)+' - '+str(self.site) |
Réponse =
list_stats = Inventory.objects.all().filter(site__user=User).order_by('date') ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Liste les stats du site si il appartient à l'user loggé :
list_stats = Inventory.objects.all().filter(user=user).order_by('date') ?