-
views.py
-
models.py
Blog application
Press here to go to the application.At this point in my learning I was getting pretty comfortable with how everything in the Django framework functions. Comparatively getting the slotmachine and users component to work took me around three months and getting this application to work took me around two weeks and I don't remember feeling anything was particularly difficult about the process.
I did learn a lot about relational databases though, since the user has a foreign key relationship with the posts the user makes, so that if you delete your user account your posts will also be deleted.
I made these database tables using SQL syntax but I was still using the built in Django admin page to manage these databases at this point, except for these two lines of python-code which maintains the relationship between the database tables, this from the blog application models.py:
author = models.ForeignKey(User, on_delete=models.CASCADE)
and this from the users application models.py:
user = models.OneToOneField(User, on_delete=models.CASCADE)
As previously mentioned I now use MySQL for the most part and I usually have no problems with transitive dependancies or anything like that.