These are chat archives for django/django

Apr 2016
Apr 29 2016 01:34 UTC
so i have a few models that belong to a user, ie, there isa user_id foreign key. I want to restrict editing of these model objects to the user. Is it beter, to in my views. just check that the current user's id matches the user_id on my models? or is it better to use django-guardian to do object level permissions?
Ezumezu Anselm
Apr 29 2016 04:00 UTC
Hi, is there a way to return a page based on the link clicked in flask
for example, i have about 5 links to different pages but one route. How do i change the content based on which link was clicked
Mir Nazim
Apr 29 2016 06:11 UTC
@aezumezu Link it to a different view funtion.
def index():
    return "Index page!"

def other_page():
    return "Other page!"

def another_page():
    return "yet another page!"
Ezumezu Anselm
Apr 29 2016 08:01 UTC
Thanks @mnazim
The scenerio i was trying to present was: creating two files. file1.html and file2.html
Alain Abrahan Paz
Apr 29 2016 08:03 UTC
Hello to the community
Ezumezu Anselm
Apr 29 2016 08:03 UTC
file1 has 5 links on it. Now in python flask, is there a way to make file2.html change depending on the link selected?
Alain Abrahan Paz
Apr 29 2016 08:06 UTC
There is way to value a value in list_editable property of ?
Ramon Moraes
Apr 29 2016 13:27 UTC
@clust3rsekt0r_twitter come again?
Apr 29 2016 15:41 UTC
I've built a personal site. by django. Feel free to visit and dont forget to leave me some suggestions . Thanks
Apr 29 2016 17:30 UTC
do i need django.contrib.sessions.middleware.SessionMiddleware if i am using django-rest-jwt?
i am not using sesstions because everything is authenticated with JWT
Apr 29 2016 19:44 UTC
many of my models have a forigen key to users, for example, my Profile model has a user_id. I only want to allow each user to update their profile, based on that user_id, is there a better way than calling the following in every one of my views?
        if not == user_pk:
            raise PermissionDenied
Dr M. Kaddour YAHYAOUI
Apr 29 2016 19:47 UTC
Hi People! i have a pdf output using (Xe)LaTeX , it renders a view containing two models in the context: patient and admission. The problem is it renders only the first page of the document
i have another similar view that renders one model 's context and it works flawlessly
Dr M. Kaddour YAHYAOUI
Apr 29 2016 19:52 UTC
It think i must use BytesIO buffer(), but i have no idea how :-/
Apr 29 2016 20:10 UTC
what is the difference between put and patch for updating?
in the context of django
Apr 29 2016 20:38 UTC
how do you update an object in django?
i can't figure how how to write an update method on my django rest serializer :( i need an example
Apr 29 2016 20:51 UTC
i guess django doesn't do nested forms as well as rails
o well
Mr. N
Apr 29 2016 22:32 UTC

I'm having trouble serving static files. My index.html page loads fine, albeit without style.

{% load staticfiles %}

<!DOCTYPE html>
  <link rel="stylesheet" type="text/css" href="{% static "/vivi/bower_components/bootstrap/dist/css/bootstrap.min.css" %}">

and my files are in vivi/static/vivi/ but it says "404" when i load the page

vivi is the name of my app
nvm. i just had to get rid of the / after static "
Apr 29 2016 22:59 UTC
does anyone ust django rest? i can't figure how how to get the serializer to rject posts that contain fields that don't exist on the model
ie, if i post {"sdfsdfsdf":"sdfsdfdsf"} it should throw a 400 or 422 because that key isn't a valid attribute on my model
or its not a valid field in my serializer