These are chat archives for django/django

30th
Jul 2017
Pachael phillip
@mosdeng_twitter
Jul 30 2017 06:56
``
`
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
guys can anyone help up with django markdownx?????
Pachael phillip
@mosdeng_twitter
Jul 30 2017 07:12
"GET /media/markdownx/03487de6-925f-48bb-9df6-be3c7936579a.jpg HTTP/1.1" 404 2209 iam getting this error when i load the image.can anyone suggest me?
vaibhav jain
@vaibhav-jain
Jul 30 2017 09:13
@sheepsy90 Try this in your view def get(self, request, args, *kwargs):
form_class = self.get_form_class()
form = self.get_form(form_class)
form.fields['field'].queryset = models.MyModel.objects.none()
return self.render_to_response(self.get_context_data(form=form))
@sheepsy90 my bad you wanted to keep the list but clear the selection. Well try to set initial value inside View's get _initial method.
vaibhav jain
@vaibhav-jain
Jul 30 2017 09:23
def get_initial(self):
self.initial = {
'field': 'SomeOffLimitValue'
}
return super(Your View, self).get_initial()
I think SomeOffLimitValue might also work in form. I found this https://stackoverflow.com/questions/1431966/add-an-empty-option-to-a-choicefield-based-on-model-datas. Basically you should use ModelChoiceField not ChoiceField.
Davide Cristini
@davcri
Jul 30 2017 13:13
Hi guys! Is there any Django app that recognize user's operating system using the incoming HTTP request ?
John
@flyboy1565
Jul 30 2017 15:21
Idk if there is a way in Django, but you could use JavaScript.. https://stackoverflow.com/questions/9514179/how-to-find-the-operating-system-version-using-javascript and send it in a ajax request any time the user connects via a new IP
Lim H.
@limdauto
Jul 30 2017 15:22
the best you can get is from the HTTP request User-Agent header: https://stackoverflow.com/questions/228256/operating-system-from-user-agent-http-header
it's an imprecise endeavor, though, and represents only a best-guess effort because user agent sucks: http://webaim.org/blog/user-agent-string-history/
John
@flyboy1565
Jul 30 2017 15:46
^ true that
Davide Cristini
@davcri
Jul 30 2017 21:18
thank you very much for the infos ;) so I guess that there is no Django app because there is no secure way to determine the OS that generated the HTTP request ?
Lim H.
@limdauto
Jul 30 2017 22:05
I wouldn't use the word "secure". I would say there is no "100% reliable" way. But it depends on your use case. For analytics, I found it to be good enough.
John
@flyboy1565
Jul 30 2017 22:22
Ya, the times I've used it was to figure out if my users where mobile or desktop, OS.. it doesn't have to be super accurate.. just enough to tell what are current consumers are using..
Helped me diagnose a guys issue with connecting my site.. he was still using Windows 95.…..
Lim H.
@limdauto
Jul 30 2017 23:34
lol