Answer the question
In order to leave comments, you need to log in
What is the best way to store a post in django?
I am learning django and for learning I am making my own analogue of pikabu. Any user can make a post in which a different number / order of blocks [text] and [image]
The question is how to store it in the database? I came to this conclusion:
-During the construction of the post, the text is simply inserted into the div.
-If you need to upload a picture (s), it is sent to the server using this input and ajax. The server saves it and sends the path, which is inserted into the post block.
It turns out something like this HTML code
< div> post text div>
< img src="mysite/img/img_1.img">
< div> Some other post text div>
< img src="mysite/img/img_2.img">
< img src="mysite/img/img_3.img">
< img src="mysite/img/img_4.
< div> Text Conclusion div>
And I will store the text itself in the database.
It turns out something like this table
User: Author's name, Title: Post title, Text: Post HTML code.
I think there are options much easier and / or more rational. Can you suggest the best way?
Specifically, does pikabu use textarea instead? The <p> tag how is it done and why?
Answer the question
In order to leave comments, you need to log in
The post is normally stored as plain HTML code. The tag <p>
is a paragraph. <div>
for this purpose you apply incorrectly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question