These are chat archives for django/django

9th
Dec 2016
HyeonAh Autumn Lee
@bonoyi87
Dec 09 2016 00:02
hey guys, I have a question. Is there any way to use 'replace' function in django ORM?
I don't want to use raw or extra..
Andy Alameddine
@andyalam
Dec 09 2016 07:35
Hey guys I have a client who wants to be able to upload an image as a background to a certain page via the admin panel. Do I have to integrate django-cms to achieve something like that or can I make a naive implementation using models?
sheepsy90
@sheepsy90
Dec 09 2016 12:18
@ajkotsubailo I tried almost everything now - even used the vanilla django 1.10.2 configuration but still i get the problem that in chrome there is a csrf token error which doesn't occur in firefox
Andrei Kotsubailo
@ajkotsubailo
Dec 09 2016 12:28
@sheepsy90 I can try to help but I need to know more to try to reproduce - can you create gist(without private info of course) with your settings?
pkariz
@pkariz
Dec 09 2016 13:10
Hi, i have models A and B where relation is one to many (so instance of A has many instances of B). How do i write rest api so that when i 'get' instance of A i get all the data with it (so actually nested B's) and when i want to 'post' new instance A i only post ID's of B's?
pkariz
@pkariz
Dec 09 2016 13:37
@ajkotsubailo tnx, but if i do whats shown in this example the 'get' works as i would expect, 'post' however doesnt accept that field (probably because the attribute name is the same and u tell it its read-only). I want to have the same attribute though if its possible for both post and get
Andrei Kotsubailo
@ajkotsubailo
Dec 09 2016 13:43
@pkariz maybe I'm not understand your question… how about to use next example http://www.django-rest-framework.org/api-guide/relations/#writable-nested-serializers
pkariz
@pkariz
Dec 09 2016 13:50
@ajkotsubailo if i understand correct this one is ment to be used if u want to allow creating of both objects with the same post (so u need to create your own 'create' function to handle this case), i just want to be able to post with id and get the nested model, found an example here: http://stackoverflow.com/questions/36189303/django-rest-framework-receive-primary-key-value-in-post-and-return-model-object