Suggested model structure to achieve users selection of services/package

6 views
Skip to first unread message

Gavin Boyle

unread,
Apr 30, 2019, 12:32:54 PM4/30/19
to django...@googlegroups.com

I am building an application that offers different services, a user can select and purchase specific needed packages. I want to know the best way to create the model so that our users can select and once paid it sets the service to active. I have one model that holds information about each individual services which includes (Package Title / Description / Price ). I need another model to handle what services are associated to each user but I am unsure how to go about this.

I have created two models as shown below but unsure how I can accomplish the above as I believe there is a better was to accomplish this.

# Model to store club information on what clubs have access to what packages
class ClubPackages(models.Model):

club_id = models.ForeignKey(ClubInfo, on_delete=models.CASCADE)
PACKAGE_STATUS = (
('0', 'Active'),
('1', 'Not Active')
)
player_register_package = models.CharField(default='1', max_length=1, choices=PACKAGE_STATUS)
player_register_price = models.DecimalField(default=100.00, max_digits=8, decimal_places=2)
player_register_expiry = models.DateField(default=timezone.now)
roster_package = models.CharField(default='1', max_length=1, choices=PACKAGE_STATUS)
roster_price = models.DecimalField(default=50.00, max_digits=8, decimal_places=2)
roster_expiry = models.DateField(default=timezone.now)
rent_a_pitch_package = models.CharField(default='1', max_length=1, choices=PACKAGE_STATUS)
rent_a_pitch_price = models.DecimalField(default=100.00, max_digits=8, decimal_places=2)
rent_a_pitch_expiry = models.DateField(default=timezone.now)
shop_package = models.CharField(default='1', max_length=1, choices=PACKAGE_STATUS)
shop_price = models.DecimalField(default=50.00, max_digits=8, decimal_places=2)
shop_expiry = models.DateField(default=timezone.now)
# Model to store our available packages
class OurPackages(models.Model):

title = models.CharField(max_length=50)
description = models.TextField(max_length=200)
price = models.DecimalField(max_digits=8, decimal_places=2)

def __str__(self):
return self.title

Séanadh Ríomhphoist/

Email Disclaimer

Tá an ríomhphost seo agus aon chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin amháin é. Is féidir tuilleadh a léamh anseo. 

This e-mail and any files transmitted with it are confidential and are intended solely for use by the addressee. Read more here. 

Reply all
Reply to author
Forward
0 new messages