These are chat archives for django/django

12th
Dec 2017
Kriss
@kritsanut
Dec 12 2017 05:56
@
Asad Ahmed
@asadahmedtech
Dec 12 2017 06:51
Hi everyone, I'm new to open source. I've been using django for quite some time and I would like to contribute for django can anyone help on how to start?
Prateek Dabas
@dprateek11
Dec 12 2017 09:30
hello everyone, i am new to django. ia m getting this error while doing a youtube tutorial
error is 'list' object has no attribute 'title'
def post_detail(request, id=None): #retrieve
instance = get_list_or_404(Post, id=1)
context = {
"title": instance.title,
"instance" : instance,
}
return render(request,"post_detail.html",context)
Please help
FoxMaSk
@foxmask
Dec 12 2017 09:32
@dprateek11 as the name of the function get_list_or_404 says
it return 404 or a list
so instance is a list
so you cant use "title" : insatnce.title
avocadosarelife
@avocadosarelife
Dec 12 2017 09:33
hello! I am making a django application and using a LDAP backend for authentication, do you guys know how to restrict the views so that only some users can see it? Users in a group for example?
Is this done with decorators?
FoxMaSk
@foxmask
Dec 12 2017 09:34
@dprateek11 you would prefer using get_object_or_404 ; that way that will work
Prateek Dabas
@dprateek11
Dec 12 2017 09:36
@foxmask ok thank you this is working fine
Luke-VideoLibre
@LukeVideo
Dec 12 2017 09:44
@asadahmedtech probably the new documentation internationalisation could be a starting point. As for fr for example isn't supported in the 2.0 documentation. Maybe
FoxMaSk
@foxmask
Dec 12 2017 09:49
@dprateek11 you're welcome
:]
@elcolie
Dec 12 2017 09:55
@avocadosarelife Are you useing Django template or Django REST?
Easily done by Permission
:]
@elcolie
Dec 12 2017 10:00
@emihir0 Strongly recommend to use postgres even in the development. Some fields will not be able to use if you are using sqlite. https://docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields/ For exmaple jsonfield
Marios Panagopoulos
@MariosPanag
Dec 12 2017 10:16
hi guys can someone tell me how i can do WHERE collection_id = (SELECT collection_id FROM colshare.colshare_collection where user_id = 1)
with django ?
Luke-VideoLibre
@LukeVideo
Dec 12 2017 10:21
@elcolie Oh Json !? Well i guess i have to migrate ASAP.
Marios Panagopoulos
@MariosPanag
Dec 12 2017 10:22
nvm i f ound it :P
JsonPipe
@JsonPipe
Dec 12 2017 11:58
Hi
Can I ask if someone if willing to look at a problem/question I have that I posted on StackOverflow yesterday, but no one have replied yet?
JsonPipe
@JsonPipe
Dec 12 2017 12:07
It is about getting the OSMWidget to show in template.
I would really appreciate it.
:]
@elcolie
Dec 12 2017 12:22
@chris10an Are you using google map?
JsonPipe
@JsonPipe
Dec 12 2017 12:23
@elcolie no
avocadosarelife
@avocadosarelife
Dec 12 2017 12:26
@elcolie thank you I'll try that : )
:]
@elcolie
Dec 12 2017 12:26
@chris10an Your template inheritence is wrong.
Then JS could not be able to find ol
If I were you I would start form base.html
And render page by page with <script> new ol</script(pseudo code)
JsonPipe
@JsonPipe
Dec 12 2017 12:42
@elcolie thanks for your feedback. I will try and work on it. I just extended base.html instead cause the assets to load.
@chris10an I'm not sure I completely understand, then :D
:]
@elcolie
Dec 12 2017 12:44
@chris10an You are talking to yourself!
JsonPipe
@JsonPipe
Dec 12 2017 12:52
@elcolie lol sorry. my bad.
JsonPipe
@JsonPipe
Dec 12 2017 13:17

@elcolie I can only make it work if is copy js/OLMapWidget.js from django/contrib/gis/static/gis/js/OLMapWidget.js into my static directory and the link to it directly from the template.

{% load staticfiles %}

{% block extra_js %}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.js"></script>
    <script src="{% static 'js/OLMapWidget.js' %}"></script>
{% endblock %}

very unpleasing and hacky. But it is a start. :D

Thanks for your assistance.

:]
@elcolie
Dec 12 2017 14:54
@chris10an Congratulation!
I suspect the root cause comes from your settings.py. static and urls.py
matrixbot
@matrixbot
Dec 12 2017 15:18
Synek Hey, I got a really big machine learning model which I want to have in-memory between requests. Loading from a pickle every time a request arrives is too slow
Synek What's the best way to do this?
Synek I tried to use memcached, but the max size per item is 128MB
Synek My pickle is about 240MB
Synek I want to unpickle + cache the file in wsgi.py and then access it in views.py from the cache