These are chat archives for django/django

12th
May 2017
Vasily Alexandrov
@the-neuro
May 12 2017 01:12
I've been stuck with a problem for a while - is it possible to create a property that is calculated based on request user? Certainly - a friendship flag between two users, I'm trying to get a list of users where friends of requesting users will have a friendship property True. Anyone knows if that's possible?
:]
@elcolie
May 12 2017 03:08
@chrisRubiano No. You mix up dealer
Kyle Mulka
@mulka
May 12 2017 03:34
@the-neuro When you say property, do you mean like a property of a django model? You might need it to be a method on the model so you can pass in the request
Or, you might be able to do something interesting with a queryset. like, add the data in the query.
Mokilok
@Mokilok
May 12 2017 04:18
For fun and curiority I want to create a batch of software within django for a single company. One component would be a documentation platform, another a crm, another used to monitor alerts related to the company. Would all this normally be done as a single project with each of those components being an "App" or would you build each of those components as a project and then break it down further? I've read the Python Django doco, I'm just looking for opinons really.
Kyle Mulka
@mulka
May 12 2017 05:38
@Mokilok I'd probably build them as separate projects. Unless you wanted them to share a single django admin or host name
sharing login might get tricky. do you have an idea for how you want to do authentication?
does the company already have a centralized login system?
or maybe this is all behind a firewall, or maybe you don't want to share logins between them at all
Mokilok
@Mokilok
May 12 2017 05:40
@mulka Why would you do them that way? To avoid bottlenecks or just best practices? I was thinking auth might be easier if it's a single project. I'd probably use Google auth and no they don't. It's all theoretical.
Kyle Mulka
@mulka
May 12 2017 05:42
this is all my opinion. I just feel like the apps you mentioned seem unrelated
Mokilok
@Mokilok
May 12 2017 05:42
Good point. The idea was a collection of apps for running a small business.
Kyle Mulka
@mulka
May 12 2017 05:42
I like the concept of "do one thing and do it well"
Mokilok
@Mokilok
May 12 2017 05:43
Also, I would want them to get information from each other ocassionally, that was why I had thought of putting them together in a single project.
Kyle Mulka
@mulka
May 12 2017 05:43
also, in the future you might have different teams working on each of these things
Mokilok
@Mokilok
May 12 2017 05:43
Yeah, that's a good point too.
I guess they could still get info from eachother via public rest api from Django or something.
Kyle Mulka
@mulka
May 12 2017 05:44
even if they were all in the same django project, you'd probably still want a well defined api between them whether or not that was implemented as a rest api or just python functions
Maybe I'm biased since I don't build reusable django apps. All the django apps I've written have been only used for one project
Kyle Mulka
@mulka
May 12 2017 05:49
django was initially designed in an environment where similar functionality had to be utilized across a number of websites that a company owned. so, they had a lot of reusable apps there. I don't think that is true for a lot of django projects though
Mokilok
@Mokilok
May 12 2017 06:19
Thanks for your help @mulka :)
Katerina Kabardi
@kkampardi
May 12 2017 06:56
Hi folks :) I have posted a few days ago a quest about upgrading to new style middleware. In case someone is interested, here is what I found digging the docs

As far as I can see django provides us with a deprecation Middlewaremixin:
https://docs.djangoproject.com/en/1.10/topics/http/middleware/#upgrading-middleware

By using the deprecation middleware we can still support older (>= 1.10) versions, although it seems to be a bit hacky(for me at least).

Also after some digging I assume that the MiddlwareMixin will stick around until django version 2.0 where:

'Support for old-style middleware using settings.MIDDLEWARE_CLASSES will be removed.

https://docs.djangoproject.com/en/dev/internals/deprecation/

Roel
@roelzkie15
May 12 2017 09:29
hi! im using django with angularjs, i would seek some advice if it is good to handle the rendering of template to django via url alone? or let angularjs routing system handle the template rendering? I will appreciate your response all thanks.
Katerina Kabardi
@kkampardi
May 12 2017 09:32
@badcoder28 you can check out this tutorial, I think that it demonstrates both django and angular routing
Roel
@roelzkie15
May 12 2017 09:39
I already visited this one but i had trouble since it is written in typescript/coffescript.
Katerina Kabardi
@kkampardi
May 12 2017 09:41
the I quess you have also tried this one?
Roel
@roelzkie15
May 12 2017 09:46
yes that was my first tutorial learning djangular and i was able to build an app thanks to it, however thinkster only allows angularjs routing to handle the template rendering which we are not allowed to leverage the full potential of django template functionality.
or maybe i just missed something, anyway it was a really nice tutorial indeed..
but back to my topic i would like to seek some advice if it good to let django handle the template rendering alone or just only let angularjs routing system handle it? or mix them both?
Roel
@roelzkie15
May 12 2017 10:55
@kkampardi i think i have a good idea now.. i had to leave the UI to angularjs and just let django handle database and communicate both using RESTAPI (drf in my case)
Katerina Kabardi
@kkampardi
May 12 2017 10:57
@badcoder28 I agree, let angular handle the front end and django the backend!
The Angular controllers should better handle all public-facing routes, will in turn make $http calls against the API URLs and each will deliver one Angular partial.
,you can still use the Django ORM model relationships when constructing your API data (with django DRF)
Katerina Kabardi
@kkampardi
May 12 2017 11:04
DRF will provide all data you need in each view in the JSON feed that Angular consumes in that view. So you're using the ORM for back-end data construction,
Roel
@roelzkie15
May 12 2017 11:06
@kkampardi yea right! glad angularjs is very fitting for django with restframework :)
Katerina Kabardi
@kkampardi
May 12 2017 11:07
it is a bit more complex than doing straignt django, and maybe you will miss some django goodies when building the front end
but I guess that's the cost of building a web application rather than a web site :)
good luck!
Roel
@roelzkie15
May 12 2017 11:08
i think i will not worry about it anymore angularjs has even more potential in UI part haha
oh yes! its a web application :)
i send you some email maybe we can chat via gmail if i have some question ill chat you hope that is ok :)
Katerina Kabardi
@kkampardi
May 12 2017 13:39
sure @badcoder28