inchidi
maybe the js raise an error
George
</footer>
{{ form.media.js }}
</body>
</html>
George
George
only favicon error
George
maybe it doesn't support django 2.1
inchidi
did the js fully loaded? try follow url generated in your page
George
nope
George
there is no js :(
George
why doesn't it load the js
inchidi
then 9/10 thats the problem. a sec, let me check the doc
Ronald
George
omfg
George
my theory is that i was overwriting form in the views but i put it a different name
George
Add the CSS to the head of your Django template:
{{ form.media.css }}
Add the JavaScript to the end of the body of your Django template:
{{ form.media.js }}
George
neither the css or the js appear
inchidi
George
George
omg
George
but, really, i have to load this for any form?
George
ooohh
George
what a bullshit
George
IT LOADS
George
THANK YOU @Inchidi
inchidi
alright you're welcome
George
yes but it's not clear
George
in the docs
George
also it's too small the generated object
inchidi
looks like css thingy. did something overwrite the css or the css fail to load?
George
yes, maybe
George
i have to see, hmm
inchidi
or maybe you put the form.as_table at too small div
George
:/
George
i think i didn't put a limit
George
width: auto;
inchidi
width: auto;
try put outside anything like:
<body>{{ form.as_table }}..</body> and see if it load properly. if yes, then outer element too small, if not, then the element itself have too small size.
George
i have it in another div and it expands when selected
inchidi
add __str__ to your model tho
George
inchidi
George
oh really?
inchidi
yeah you can do that to your Model
George
if my model is FailureType would it be str(self.field_FailureType)
inchidi
no it will be str(self.spectrum)
George
hmmmmmm
George
but the problem is that i have to filter each one, its strange but it makes sense for me
inchidi
George
Yes yes, i know but hum
George
i got another problem, the queryset is being ignored
inchidi
George
right
George
i mean, my queryset filters and gets 3 elements but i get 6
George
yes
inchidi
thats weird but ig its not about select2 anymore since the queryset handled by ModelChoicefield
George
George
class MyWidget(ModelSelect2Widget):
queryset=FailureType.objects.filter(spectrum = 'infrared').order_by('id')
search_fields = [
'kind__icontains'
]
class FailureForm(forms.ModelForm):
class Meta:
model = FailureType
fields = ['kind']
widgets = {
'kind': MyWidget,
}
George
George
i think i'm gonna dump django-select2, it's a waste of time
George
i already did my implementation and works
George
but i was trying something more pythonic
George
i already made a dependent dropdown and it's working but only with custom jquery and shit, if anyone needs it, just ask
George
i think it's somewhat hardcoded but it works
George
i am going to rest, thank you as always inchidi
inchidi
okay you're welcome
George
English
Anonymous
how do I access an object related to another related object? I have a Question class, a Comment, and a Reply. Comment is with an FK for Question, and Replu is with an FK for Comment. I can access the comments using Question.comment.all, but I can not access the answers using Question.comment.reply.all, it is giving error '' RelatedManager 'object has no attribute' replies' "in my view. app: https://github.com/marcoscoder/vesttest/tree/master/questoes
Mirco
Anonymous
Combot
Marcos (0) has increased reputation of Mirco (7)
Mirco
Mirco
Ty
Or this one
https://stackoverflow.com/questions/15553167/querying-models-in-django-two-levels-deep
Anonymous
in the stackoverflow examples, the query is filtered, I want to simply retrieve all objects in Question> Comment> Reply