diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-03 09:07:44 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-03 09:07:44 -0500 |
commit | 9dc6e678a57203f0bc5c08f4780069b7cabdb45a (patch) | |
tree | 75f28ec3eba658aa66f414a4ad2e6933f273ff94 | |
parent | 4e85f4e162358118bd313514da969eabc3db468b (diff) |
redid admin slightly
-rw-r--r-- | app/deals/admin.py | 2 | ||||
-rw-r--r-- | app/deals/models.py | 65 |
2 files changed, 59 insertions, 8 deletions
diff --git a/app/deals/admin.py b/app/deals/admin.py index 7f78079..9e37d67 100644 --- a/app/deals/admin.py +++ b/app/deals/admin.py @@ -9,7 +9,7 @@ from .models import Deal, Brand @admin.register(Deal) class DealAdmin(OSMGeoAdmin): - list_display = ('brand_str', 'brand', 'title', 'category', 'deal_price', 'original_price', 'discount_percent', 'promo_type', 'amazon_link', 'search_ccc', 'search_wired', 'get_airtable_code') + list_display = ('title', 'brand', 'category', 'deal_price', 'original_price', 'discount_percent', 'promo_type', 'amazon_link', 'search_ccc', 'search_wired', 'get_airtable_code') search_fields = ['brand__name', 'title', ] list_filter = ('category', 'promo_type', ('brand_str', DropdownFilter),) diff --git a/app/deals/models.py b/app/deals/models.py index ae2f92e..0d58367 100644 --- a/app/deals/models.py +++ b/app/deals/models.py @@ -86,6 +86,57 @@ with open(path) as f: reader = csv.reader(f) count = 0 for row in reader: + if count > 0: + print(row) + if row[4] == "Y": + prime = True + else: + prime = False + _, created = Deal.objects.get_or_create( + asin=row[0], + category=row[1], + brand_str=row[2], + title=row[3], + prime_only=prime, + promo_type=row[5], + deal_price= row[9], + original_price = row[10], + discount_percent_str=row[12], + url=row[13], + ) + count = count+1 + + + +b, created = Brand.objects.get_or_create( + name = deal.brand_str +) +deal.brand = b +deal.save() + + + + + + + + + + + + + + + + + + + + +with open(path) as f: + reader = csv.reader(f) + count = 0 + for row in reader: if count > 0 if row[5] == "Y": prime = True @@ -96,13 +147,13 @@ with open(path) as f: asin=row[0], cateogry=row[1], brand=row[2], - title=row[4], - prime_only=row[5], - promo_type=row[6], - deal_price= row[10], - original_price = row[11], - discount_percent=row[13], - url=row[13], + title=row[3], + prime_only=row[4], + promo_type=row[5], + deal_price= row[9], + original_price = row[10], + discount_percent=row[11], + url=row[12], ) print(row[0], row[1], row[2], row[4],row[5],row[6],row[10],row[13],row[14]) |