docker run -p 8000:80 <your-tag-name>
-- Port 8000 is your local port, Port 80 from container.
[!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)
subcategory = models.ForeignKey(Subcategories, on_delete=models.CASCADE)
mean that the default values will have to be selected on the database instead of it automatically being selected?
Added dependency in requirements.txt :
Dockerized project
Docker build and run
docker build --tag <your-tag-name>
docker run -p 8000:80 <your-tag-name>
-- Port8000
is your local port, Port80
from container.