These are chat archives for django/django

12th
Feb 2018
Marios Panagopoulos
@MariosPanag
Feb 12 2018 00:00
list_with_ids  = [6,3,1]
preserved = Case(*[When(pk=pk, then=pos) for pos, pk in enumerate(list_with_ids)])
queryset = Example.objects.filter(id__in = list_with_ids).order_by(preserved)
I solved it like this
Roel
@roelzkie15
Feb 12 2018 00:04
@MariosPanag :thumbsup:
wqhhust
@wqhhust
Feb 12 2018 00:46
In django, we are using redirect using relative path. But we want to convert all http to https when doing redirect, if not do redirect, then just use http. How to do this?
lakshya aggarwal
@lakshya-aggarwal
Feb 12 2018 04:36
Hey. I am working on dynamic formsets. I am using jquery to dynamically add a new form to formset and display but the data from these forms is not being sent to my views.py. Attaching my index.html javascript snippet.
index-html.png
Can anyone suggest changes or an alternative method?
philipmutua
@philipmutua
Feb 12 2018 06:24
@ptink I was trying installing this project https://github.com/prikhi/AcornAccounting
:]
@elcolie
Feb 12 2018 09:23
@bochiedev Your both user are StaffAdmin
philipmutua
@philipmutua
Feb 12 2018 11:05
@siddhantdubey you can start practicing django in this repo her http://bit.ly/2BTszui
Siddhant Dubey
@siddhantdubey
Feb 12 2018 11:33
@philipmutua Thanks I will check that out
Ahmed Kotb
@AEzzatA
Feb 12 2018 13:44
Hi, I have a Form 'not ModelForm' which has an image upload.. all i want is to save it in the /media/ and just save the url somewhere in the db..
how to do so since I have everything up until form.cleaned_data['image_file']
in other words, form cleaned data gives me an InMemoryUploadedFile object.. how to save it in /media/ and generate a url for it?
emihir0
@emihir0
Feb 12 2018 18:46
you don't save your file directly in the form. you simply set it to a field on your model and save the model instance
e.g. myphoto.image = self.cleaned_data.get('image')
myphoto.save()