Thursday, January 30, 2020

JSONField() ordering and removing latest

Hello together,
i have the following problem. I need to save different versions of an article in a json object:

{
"1580388458.2877874": {
"title": "Erster Artikel", 
"text_block_with_image": [{"text": "Super Text der einen weiterhilft", "image": "http://test.de/test.jpg"}]
}, 

"1580388556.6462297": {
"title": "Erster Artikel angepasst", 
"text_block_with_image": [{"text": "Super neuer neuer Text der einen weiterhilft", "image": "http://test.de/test.jpg"}]
}

}

I save this information in a JSONField().

The numbers here are the current time in seconds. 
I want to do an article template where i show the latest version of the article (by current time seconds).

How can i filter after the latest version?

Articles.objects.filter( ?? )



My second problem:

How can i delete the oldest version (key), when i add a new entry?


Thank you!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f0624188-fd77-4c50-acbe-b0c841043554%40googlegroups.com.

No comments:

Post a Comment