Skip to content

Instantly share code, notes, and snippets.

@siddartha
Created July 15, 2014 15:25
Show Gist options
  • Save siddartha/f3309730edb246ce2667 to your computer and use it in GitHub Desktop.
Save siddartha/f3309730edb246ce2667 to your computer and use it in GitHub Desktop.
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)
@siddartha
Copy link
Author

Liste les stats du site si il appartient à l'user loggé :
list_stats = Inventory.objects.all().filter(user=user).order_by('date') ?

@siddartha
Copy link
Author

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