Djifferson
Treehouse
Djifferson
And so on .....
乌卡帕拉
hi guys, how to pass the model parameters or variables to templatetag, such as {% cal_vc fruit.vc %}, but {% cal_vc 0.36 %} is worked though.
Elflord
Hello guys new to django framework
Rohan
Ghorz
hello guys, how do I pass results to context_data from the snippet below https://dpaste.de/N027
Anonymous
I’m trying to write an app Server that receives and send data for 20 clients via TCP and a client via UFP. Any friend who has do it or have any suggestions? Thank you so much.
Mirco
hello guys, how do I pass results to context_data from the snippet below https://dpaste.de/N027
Override def get_context_data() It returns kwargs in which you can pass fields to use in your template
Mirco
btw its get_context_data()
🤣🤣🤣 sorry, bad typo 🤣
Ghorz
Override def get_context_data() It returns kwargs in which you can pass fields to use in your template
I guess the get_context_data would be bonded to return at form_valid(). Or could you show an example
Ghorz
Read here
Thanks, I understand this perfectly. The issue is am working with formview. How do I pass data to context right inside the form_valid function
Mirco
Thanks, I understand this perfectly. The issue is am working with formview. How do I pass data to context right inside the form_valid function
Do you mean for example a validated data ? You are working with a Python class , aren't you ? So define a class attribute , set as you need inside form_valid, then use it into your get_context_data as you would do with every class field into a class method
Ghorz
Okay
Mirco
Okay
Clear enough ?
Ghorz
Clear enough ?
I'll find a way to fix it.
Mirco
I'll find a way to fix it.
The simplest way is what I told u
Ghorz
If you look the code clearly on line 10
Ghorz
How will results be passes to context data
Anonymous
guys can it possible django model status change just a button click
Ghorz
It is not a model data. Instead data from a form was passed to a function. I want to return the results sets to a context data so I can display it in my template
Ghorz
Yes
Ghorz
https://dpaste.de/N027
Anonymous
Yup obviously
any example relating it
Mirco
You're the man
Or better https://dpaste.de/e3sR#L14
Ghorz
How I forgot OOP I don't know. Have not coded since January 5th, need to brush up
Mirco
That's why it's important to know Python before Django
Ghorz
That's why it's important to know Python before Django
Yea I coded python for 4years before I tried django. I hated OOP as a C programmer until I started with python. Even while working with python, i used pure function. Django made me create a tiny space in my heart for oop
Ghorz
since to work now but results resets to None in get_context_data
Anonymous
I need a help on django i.e how to create rest API to call services from elastic search
Ghorz
it seem to be localized
Mirco
Ghorz
self cant be used outside a function. am thankful for your help, what I will do is globalise the results variable
Mirco
Or better https://dpaste.de/e3sR#L14
This one should be the correct one
Rohan
C doesn't have classes at all
Rohan
Structs is the wey to go in C
Anonymous
Hi Guys! I want to know which is better to learn: django or nodejs? I am proficient at C language only. I don't knlow anything much about Python or JavaScript... Can you please help?
Sanjay Krishnan
Does django support composite primary key, like combination of 2 fields as primary key without having an extra column named id, i have googled a lot and couldn't find a proper solution to it..
Sanjay Krishnan
Has anyone faced this problem?
inchidi
Hi Guys! I want to know which is better to learn: django or nodejs? I am proficient at C language only. I don't knlow anything much about Python or JavaScript... Can you please help?
since you ask this in django group, then my answer is if you are good with django, then you will be good at python and javascript. that means learning nodejs will be as easy as reading docs.
Anonymous
@Inchidi so you mean to say that django is equal to learning python + javascript + nodejs
Anonymous
(concept wise)
Sanjay Krishnan
you can use primary key instead index as fk but i still dont understand what you want to do
I don't want id as primary key, instead if i have fields A and B then i want to identify objects uniquely by the combination of these 2 fields
inchidi
@Inchidi so you mean to say that django is equal to learning python + javascript + nodejs
not equal, but python is a must, javascript is a must in most case. learning nodejs is personal choice but will be easier if you already good with django for sure
sahil
Hey everyone I want to learn Django as fast as possible could you provide any tutorial or video lectures
Anonymous
djangogirlstutorial is the best one as far as I know
sahil
Sorry but i only want link of video lectures
Anonymous
9/10 you'll need/use javascript in your web app
Okay, but what I want to know is that are python and javascript co-related in some way?
Anonymous
In terms of ease of learning..
inchidi
how about just start learning? 🤔
Anonymous
Kaio
Guys.. I'm using django-filter, the problem is I have +400 entries in my database and I don't want to display all of that in my page without filtering... but when I user [:25] in my query.. the filtering gets error... Anyone has a clue?
Kaio
I tried.. but it seems not working.. the paginate_by only paginate the queryset of the listview.. but I'm displaying the results using the FilterQuerySet
Kaio
didn't find a way to paginate the filtering
inchidi
pls share your view
Kaio
class CompanyListView(ListView): model = Company paginate_by = 9 def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['filter'] = CompanyFilter(self.request.GET, queryset=self.get_queryset()) return context
Miguel
hey guys, good day
Kaio
Good!
Kaio
I'm trying `def get_queryset(self): return CompanyFilter(self.request.GET, queryset=Company.objects.all()).qs`
inchidi
should be something like this