Tuesday, April 30, 2019

Suggested model structure to achieve users selection of services/package

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. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHZR7JeK4wqbCHVzWsH1%2BWLpgMPQTBZ5QTwePg4o%2BDpr98FNVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment