I've started using Django 2.0 and Python 3.6.3 to develop a website which will display customized "Posts", as in a blog Post.
My idea is to create hundreds of short Posts which can only be accessed at random, via a "Click here for random post" button.
I plan to create a Post model with different text fields, including also a UUID, or custom unique ID.
Once I have my model, my idea is for the user to click a button which selects a random instance of a Post, or an individual record from the database. Then, my View would display the random Post instance.
I'm not sure of all the possible ways this could be done. One way might be to get a random row from the database, then somehow grab the ID and use that for the URL. Another way might be to simply use template tags to somehow select a random model.
This is purely theoretical right now, so I don't have any code yet. If you have any ideas on how to approach this, I'd really appreciate it.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire