KC-software-en / QuizMe

A Django website for a Magazine providing quizzes for Education, Entertainment and General knowledge. It is Dockerised, hosted on AWS and uses an API.
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Add feature: Dockerized project #80

Closed deviserops closed 1 month ago

deviserops commented 1 month ago

Added dependency in requirements.txt :

Dockerized project

Docker build and run

[!CAUTION]

Found issue during pip packag installation from requirements.txt

  • You cannot use query inside model, it will cause issue at first setup because there are no item in database.
  • Instead change your model columns default vale
  • This goes for all models, you can remove query becuase already using ForeighKey field.
class Mythology(models.Model):   
     # retrieve the category object representing 'Education' from the Categories model
-    education_category_obj = Categories.objects.get(category='Education')
     # retrieve the subcategory object representing 'Mythology' from the Subcategories model
-    mythology_subcategory_obj = Subcategories.objects.get(subcategory='Mythology')

-    category = models.ForeignKey(Categories, on_delete=models.SET_DEFAULT, default=education_category_obj.pk)   
-    subcategory = models.ForeignKey(Subcategories, on_delete=models.CASCADE, default=mythology_subcategory_obj.pk) 
     # - providing further control over the default value
+   category = models.ForeignKey(Categories, on_delete=models.CASCADE)
+   subcategory = models.ForeignKey(Subcategories, on_delete=models.CASCADE)
KC-software-en commented 1 month ago

@deviserops Thanks, I'll have a look

KC-software-en commented 1 month ago

@deviserops I would also like to follow up on your recommendation for models.py. Does