0:00 AM
djapo
yes, i was.
0:00 AM
can i set a many to many with just a list of pks?
0:01 AM
FunkyBob
worth trying
0:01 AM
schinckel
Yeah, you can, IIRC.
0:01 AM
instance.related_set.add(*foo)
0:01 AM
Where foo is a list of pks.
0:01 AM
fikka has quit
0:03 AM
tbp has quit
0:03 AM
tbp joined the channel
0:05 AM
olrrai joined the channel
0:06 AM
CAPITANOOO has quit
0:07 AM
fikka joined the channel
0:11 AM
fikka has quit
0:12 AM
theWhisper_
mar77i: bleach?
0:14 AM
FunkyBob
theWhisper_: yes, bleach... it's a very useful lib
0:14 AM
0:17 AM
fikka joined the channel
0:19 AM
detseg joined the channel
0:21 AM
tbp has quit
0:21 AM
tbp joined the channel
0:22 AM
fikka has quit
0:23 AM
BigJono joined the channel
0:24 AM
eperzhand joined the channel
0:28 AM
aussiejames joined the channel
0:29 AM
aussiejames has quit
0:31 AM
sarp has quit
0:32 AM
tbp has quit
0:33 AM
tbp joined the channel
0:34 AM
djapo
schinckel: I assume the instance needs to have a pk
0:34 AM
schinckel
Yeah, the instance must have been saved.
0:35 AM
zeus1 joined the channel
0:37 AM
fikka joined the channel
0:41 AM
djapo
schinckel: can i expand a queryset with *
0:41 AM
?
0:41 AM
fikka has quit
0:41 AM
schinckel
djapo: I'm not sure. Maybe. If not, you could *list(qs)
0:42 AM
Try it and see.
0:42 AM
zeus1 has quit
0:42 AM
theWhisper_
alright i need some guidence here
0:42 AM
i have this f_requests = Friend.objects.filter(following=request.user, state='req').exclude(creator=request.user)
0:42 AM
now this will return the objects but not the friend requests
0:43 AM
djapo
schinckel: i get invalid syntax
0:43 AM
for both *qs and *list(qs)
0:43 AM
schinckel
Inside a function call?
0:44 AM
djapo
schinckel: yes
0:44 AM
schinckel
foo(*User.objects.all()) works for me.
0:44 AM
djapo
print(*qs)
0:44 AM
schinckel
For some reason, print(*x) does that.
0:45 AM
djapo
hmmm, weird
0:45 AM
yeah, it also does it for regular lists .. neat
0:46 AM
ok will try instance.exp.add(*qs)
0:48 AM
newdimension joined the channel
0:53 AM
vdamewood joined the channel
0:55 AM
norwood67 has quit
0:56 AM
fikka joined the channel
0:58 AM
eperzhand has quit
0:59 AM
eperzhand joined the channel
1:00 AM
iamriel has quit
1:01 AM
fikka has quit
1:03 AM
Leeds has quit
1:05 AM
shangxiao joined the channel
1:07 AM
fikka joined the channel
1:11 AM
fikka has quit
1:15 AM
norwood67 joined the channel
1:17 AM
fikka joined the channel
1:18 AM
Knyght has quit
1:18 AM
k_sze[work] joined the channel
1:19 AM
matsaman joined the channel
1:20 AM
jessamynsmith joined the channel
1:21 AM
matsaman has left the channel
1:21 AM
fikka has quit
1:21 AM
theWhisper_
ok so how i update a field of a manytomany table?
1:21 AM
schinckel
You mean on a through model?
1:23 AM
eperzhand has quit
1:24 AM
Knyght joined the channel
1:24 AM
tbp has quit
1:24 AM
FunkyBob
you access it directly, instead of via the m2m
1:25 AM
tbp joined the channel
1:25 AM
csotelo joined the channel
1:26 AM
djapo
hello i want to redirect from one url to the other while using a token of the old url in the new
1:26 AM
zeus1 joined the channel
1:27 AM
theWhisper_
access it directly?
1:28 AM
i have a field on a m2m model called satte
1:28 AM
state
1:28 AM
i wan tto update it to a different value
1:29 AM
FunkyBob
theWhisper_: as schinckel asked... on the through model, or on the target of the m2m?
1:29 AM
theWhisper_
i dont understand that question
1:29 AM
FunkyBob
djapo: where did the token come from?
1:29 AM
theWhisper_: does your ManyToManyField have a through= parameter?
1:30 AM
theWhisper_
i have a model m2m which you helped me create that has creator = foreignKey, following = ForeignKey and state = charfield
1:30 AM
FunkyBob
theWhisper_: in short, you're not giving us enough detail to answer your question... and your wording just makes it more ambiguous
1:30 AM
so you _are_ talking about the "through" table
1:30 AM
theWhisper_
i have one record in that table which i want to update
1:31 AM
i guess
1:31 AM
thts the only table yes
1:31 AM
FunkyBob
in that case, stop treating it as a m2m, start accessing it via the foreign key
1:31 AM
theWhisper_
but for a record
1:31 AM
FunkyBob
don't guess... know
1:31 AM
theWhisper_
what you mean accessing by foreignkey?
1:31 AM
let me show you a dpaste
1:32 AM
FunkyBob
good
1:32 AM
the "through" table will have a foreign key to each side of the M2M, right?
1:33 AM
cluelessperson has quit
1:33 AM
theWhisper_
1:33 AM
FunkyBob: right
1:33 AM
and i thats how i am getting the value yes
1:33 AM
FunkyBob: my problem is when updatin gone record
1:34 AM
rpkilby joined the channel
1:34 AM
FunkyBob
set the value on the model instance you got... save it..
1:34 AM
NeuroWinter joined the channel
1:35 AM
acc_friend = Friend.objects.get(creator=user, following=request.user, state='req')
1:35 AM
that gets you your Friend instance
1:35 AM
is that what you want to update a value on?
1:36 AM
or is it something else you want to change?
1:36 AM
theWhisper_
yes thats what i want to change the value on
1:36 AM
to that friend instance
1:36 AM
state i wan tto change it
1:37 AM
fikka joined the channel
1:37 AM
FunkyBob
acc_friend.state = 'acc' ; acc_friend.save()
1:38 AM
theWhisper_
exactly what i did yep!
1:38 AM
i am strating to get this
1:38 AM
this might not be efficient though
1:38 AM
FunkyBob
efficiency can come later
1:38 AM
NeuroWinter
I have this issue when using django_bootstrap4 and messages. I want to handle messages myself, but when I use the bootstrap_form tag to render a form, it takes control of my errors. Has anyone else had this issue and or found a way around it?
1:39 AM
cluelessperson joined the channel
1:39 AM
FunkyBob
err... no
1:40 AM
when I do use boostrap in the front end, I use django-sniplates to help with rendering...
1:41 AM
fikka has quit
1:43 AM
tdy joined the channel
1:44 AM
maks25 joined the channel
1:47 AM
NeuroWinter
Ahh ok I will look into that :)
1:47 AM
fikka joined the channel
1:47 AM
amcorreia has quit
1:47 AM
Also has anyone had an issue csrf and Edge?
1:48 AM
duoi
I've been trying Friend.objects.order_by('?').first() but it always comes back with None
1:48 AM
:(
1:52 AM
fikka has quit
1:52 AM
kooldude has quit
1:55 AM
lobo_d_b has quit
1:57 AM
jalalsfs has quit
1:57 AM
olrrai has quit
1:59 AM
djapo
FunkyBob: sorry for late responce, the token is part of the url
1:59 AM
so i can capture it with a regex
2:07 AM
jgadelange has quit
2:07 AM
fikka joined the channel
2:08 AM
jalalsfs joined the channel
2:10 AM
jgadelange joined the channel
2:10 AM
sarp joined the channel
2:12 AM
theWhisper_
FunkyBob: so i have a little bit of an issue here
2:12 AM
fikka has quit