Commit 2aefa448 authored by lizonr1's avatar lizonr1

Add sample places

parent c3c56659
from App.loyaltyMe.models import Place
__author__ = 'Rafal'
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = 'Closes the specified poll for voting'
def handle(self, *args, **options):
places = [
#['name', 'type', 'screen_img', 'logo_img', 'description', 'offer', 'promotions'],
['Kocia Kawiarnia', 'Cafeteria', '/static/media/img/photo_1.jpg', '/static/media/img/photo_1.jpg', 'description', None, None],
['Kocia Kawiarnia2', 'Cafeteria', '/static/media/img/photo_1.jpg', '/static/media/img/photo_1.jpg', 'description', None, None],
]
print("Creating Places")
for place in places:
print('Create {0}'.format(place[0]))
print(place)
new_place = Place.objects.create(name=place[0], type=place[1], screen_img=place[2], logo_img=place[3], description=place[4], offer=place[5], promotions = place[6])
new_place.save()
\ No newline at end of file
......@@ -12,6 +12,7 @@ class Product(models.Model):
class Offer(models.Model):
name = models.CharField(max_length=50)
products = models.ManyToManyField(Product)
......@@ -25,9 +26,9 @@ class Promotion(models.Model):
class Place(models.Model):
name = models.CharField(max_length=50, unique=True)
type = models.CharField(max_length=50, unique=True)
type = models.CharField(max_length=50,)
screen_img = models.ImageField()
logo_img = models.ImageField()
description = models.CharField(max_length=50)
offer = models.ForeignKey(Offer)
promotions = models.ForeignKey(Promotion)
offer = models.ForeignKey(Offer, null=True, blank=True)
promotions = models.ForeignKey(Promotion, null=True, blank=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment