Manish
yes i dont need redis
Manish
i tried with RequestContext but instead of working it gave me error
R
Cache it
Manish
R
https://docs.djangoproject.com/en/2.1/topics/cache/
Manish
no bro not possible
Rajjix
u can query it once and save to user session, but again that’s a very stupid idea
R
no bro not possible
Within one minute, you have not even had time to read one of the available caching ways that django provide you
Manish
i am thinking in this from last 15 minute but got no good idea
Rajjix
just write ur custom query sets, makes querying a lot easier, and besides ur db can handle much more cnx than u think, so if u don’t wanna cache it, don’t bother in looking for other ways, they will all be stupid or vurnable in one way or another
R
Mixin + low level cache is the way to go
Manish
actually i did this https://del.dog/usinamivok
Manish
that's why i need solution for preserving objects
R
This sux
Rajjix
Preserving them for what, in case he refreshes the home page? 🤔
George
hi, why can't i make petitions to server when logged in the admin?
Manish
Preserving them for what, in case he refreshes the home page? 🤔
preserving them for other page so that the included html can be rendered with context data which is only on my home view
Manish
This sux
yes. any good way to do this please tell me.
Manish
Manish
can i use mixin with finction based view?
George
i didn't understand.
when i make an ajax request to my server, if i am logged in the /admin it spits 403 forbbiden
R
yes. any good way to do this please tell me.
Why you query all items in db to just pass the first one to context?
R
can i use mixin with finction based view?
No, but you can create a function that returns a context, and call this function from every func based view
R
And home, and contact
Manish
Why you query all items in db to just pass the first one to context?
i have only one instance in each of home contact and social so how to get those.
Manish
i knew only this way to do that
Manish
tell me if i can optimize it.
R
.get(pk=1) .first() you should look at django query api documentation
R
And think if you really need to create tables in database for just 1 record...
Manish
And think if you really need to create tables in database for just 1 record...
no i think. but i have no idea how to deal this if i dont save it in database.
R
Just put it in the template? 😰
Manish
Just put it in the template? 😰
u didn't understood. i made that so that i can change data of one record from django admin panel and render in template dynamically
Manish
.get(pk=1) .first() you should look at django query api documentation
this wont work if i delete first one then create new one. because the id of the new one will be 2 instead of having 1. and query will fail
Rajjix
this wont work if i delete first one then create new one. because the id of the new one will be 2 instead of having 1. and query will fail
bottom line is yes u need a mode to change an object from admin panel to view, but u can make query set save in a list in your view and past that list to ur template
Rajjix
There u can display and pass objects from one template to another template using with inside ur curly brackets For example {% url ‘some_other_page’ with object %}
R
u didn't understood. i made that so that i can change data of one record from django admin panel and render in template dynamically
I understood, but it has no sense having 3 tables for just one record each, you would have other options to modify it from django admin and not using those tables, but seeing your django knowledge and predisposition to learn, do it as you want
Manish
I understood, but it has no sense having 3 tables for just one record each, you would have other options to modify it from django admin and not using those tables, but seeing your django knowledge and predisposition to learn, do it as you want
no no roger. actually i really want to learn and explore new ways. but i am learning by doing. i do codes in very bad way, but that doesnt mean i dont want to learn good ways. and i respect and appriciate your answer.
Sanjay Krishnan
Try to make those 3 models into onemodel if its just for one record each
Sanjay Krishnan
Can you show your 3 models
Manish
Can you show your 3 models
sure. wait a second
Manish
Can you show your 3 models
https://del.dog/agadisedut
Sanjay Krishnan
You can maybe create a model named configuration and add all your fields in that
Sanjay Krishnan
Then specify it in your settings file and call it whenever you want
Manish
sounds good. i will try this.
Sanjay Krishnan
👍👍
Mirco
https://del.dog/agadisedut
One question for my curiosity Why do you need to store social links ?
Anders (izzno / gooood) 🇳🇴
@Rajjix @Sin_atra Look at this: https://github.com/digi604/django-smart-selects
Manish
One question for my curiosity Why do you need to store social links ?
so that user can modify it in django admin template whenever he wants. without learning any programming.
Mirco
Ok now it's clear And you repeat your query for multiple views because they are inside the footer ?
Mirco
Have you already thought about context processor ? Think about static or i18n in your templates , you can make social links and load them in your base template So you query them inside your settings just once Something like this
Mirco
thank you
Yw 😀😀
Mi
What would you use to push new data from a django rest backend to a vue frontend, for example? Websockets? Django channels?
Mirco
POST requests ?
Rajjix
i think he’s talking about webhooks
Rajjix
@Rajjix @Sin_atra Look at this: https://github.com/digi604/django-smart-selects
interesting stuff might save you a lot of work, keep us updated on how it goes with that.
Mi
POST requests ?
But the front end does not know when the django backend has new data, and I don't think polling is a good strategy for this
Mi
I'm talking about pushing data modified or updated by one client (spa) from a backend to another client
Kaio
Hey y'all! I'm trying to save a M2M multi select field in a CreateView but it's not working at all! All my fields have been saved but not the M2M. Do I need to specify something in my view? That's what I have so far:
Rajjix
you should pass ur model fields in the form meta Class, and see why it’s not saving, you should get an error, to show that error you can add a for loop in your template, for error in form.<m2m_field>.errors then display the error in a span tag or something
Rajjix
or add a form_invalid method and repost the data to the form to check what data is being accepted and what not
Rajjix
or share ur model and form
Danilo
hi guys
Danilo
one question
Danilo
after install Pipefile, i can delete requirements.txt?
Rajjix
yes
Danilo
nice
Danilo
thanks
Anonymous
i want space between two posts here is the code home.html i use bootstrap for card view
Rajjix
class =“card ma-5”
Anonymous
Rajjix
style=“margin:0 10px;”