Jacob maintains many popular Django packages including django-shop, a popular e-commerce solution. We discuss the challenges of handling payments, web components, and more.
Carlton Gibson 0:06
Hi, and welcome to another episode of Django chats. I'm Carlton Gibson joined as ever by Will Vincent, how you doing? Well,
Will Vincent 0:10
I'm good. Hi, Carlton. Hello.
Carlton Gibson 0:12
And this week, we've got Jacob Rief with us who's going to talk to us about all things. django CMS and Django sharp. Hello Jacob. How you doing?
Jacob Rief 0:18
I'm fine. It's great.
Carlton Gibson 0:20
Thanks for coming on the show. And touching start having me. very welcome. Both of you start by talking about how you got into programming, how you're going to say Python how you got into Django. That might be you know, always interesting. Well,
Jacob Rief 0:34
I was when I was 14, my father. He did a lot of physics and programming in Fortran. And so I somehow got into programming through him. And then I used basic, Pascal and C and c++ and assembler. And
later on, we
required a scripting guide. To access C code that was in 1997. So it was my first Python experience. What version of Python later on 1997. was, that was a 1.5.
Carlton Gibson 1:15
Okay, cool. Thanks.
Jacob Rief 1:17
And it was a really, it was very unknown at that time. I, I tried with tickle at that time to do to have a scripting language to access code written in c++. But a colleague of mine convinced me to switch to Python. And we never regretted that decision at that time.
Later on, then I
went to web programming and web applications and I retried pi sent to us there. And that was not so successful because it was at the time when my Python mod Python was waivable. And that didn't work out very well at that time. And so I landed in the PHP world. Of course, I wrote a lot of code in PHP. And it really got me into web programming. But I never really liked the language. And then in 2010, I retried Python. And a retried together with Django, and then I immediately fell in love. And I just remained there. And now since nine years, I'm only using Python exclusively,
Will Vincent 2:39
right in Django, that that's an amazing that's an amazing story to start with Python over 20 years ago, and then sort of wait for a framework to catch up with the need.
Jacob Rief 2:48
Yes, it was, it was tough. It was 20 years with interruptions in between I used other language, even returned back to c++ and C and and even better At that time, and but my main focus nowadays is placement. And I'm currently doing a lot of stuff around Django, CMS, and therefore, of course, everything I do is is done in Python.
Carlton Gibson 3:17
Right. And so can you tell us a little bit about django CMS there because it's one of the big packages in the ecosystem, but perhaps some of our listeners don't know what django CMS is, or Yeah,
Jacob Rief 3:26
actually, I came to django CMS through Django shop. I had to, I was asked to build a shop system in 2010. And I had to do an addition to a PHP project and I really didn't like it the way it was done. And then we, I we required something where we needed a lot of kind of very, very runs on the products. And so since I was looking for, since I was working for Django in Django, I was I was looking for a shop system shop framework. In Django, I think that was in 2011, or 2012, or something like that. And at that time, I found out such Mo, which at the time was a shop framework built on Django and Django shop in Django sharp really seemed to be very, really, really simple. But straightforward, how it was implemented. And so I, I started to use Django shop. And then I saw that the company behind Django shop was dvo, and they had a CMS, which was even much more mature than Django shop at that time. So I integrated django CMS with Django shop for that first project I have done with Django shop. Okay, so
Carlton Gibson 4:59
the So django CMS gives you the normal page models and things like this. You can define an article page or a news page or whatever type page type and then Django shop gives you the kind of product models is that would that be a fair way of describing?
Jacob Rief 5:14
Yeah, Django sharp is
first of all the product models a cart, where you can put your models then some card modifiers, so that you can change the prices at the at the checkout. And then, of course, the ordering process and some plugins to adopt a payment service providers and DNS, a view over all the orders you you have done initially in the shop system
Will Vincent 5:50
he used there. I'm wondering, so the shopping cart itself, that's from just a UI perspective, that's a very complicated thing that I think until you build one, you don't see how many variations there are. I'm curious what sort of learnings you've had working. You know, aside from the code, which also becomes complex. There's a lot of different ways to do a shopping cart. And I often find anecdotally, developers who've built out an e commerce site, they always say that figuring out the shopping cart piece, more than any other step in the processes is where they spend their time and what they find a challenge. I wonder if that resonates with you just on this on Django shop?
Jacob Rief 6:31
Well, the shopping cart actually have to say, from the history, history point of view, I use Django sharp and then Django, the main developer, a devio, who was responsible for Django sharp left the company and I at that time, have already done two sharp systems with with Django sharp and I was dare to do this. Third one. And then I reuse the code base, which at the time was not maintained very well. And I added all my own stuff. And then devio in 2014, they turned over the project to me. So, the project which initially started a DVR now, I'm the core maintainer of jungle shop, and therefore, I was able to convert that shop system into a shop system, how I, how I liked it. So, that that was the that was the history and since 2014, I am the core maintainer. I have I have other guides, which helped me to to maintain the code and to add some additions with principally, I'm, I'm saying where we were proceeding
Carlton Gibson 8:02
How'd you find the SLT contributors? Do you find you find it easy to get new people on board and to get cocoa nation?
Jacob Rief 8:09
No, not at all? No, not at all. It's there is one guy from Paris. His name is Nicolas and he helps a lot. And others are just smaller contributors. We just do a small fixes or so but no big no big issues,
Carlton Gibson 8:30
because it's a difficult challenge now to maintain a project and keep it keep it alive for such a long period of time.
Jacob Rief 8:36
Yeah, that's, that's quite challenging. Yeah.
Will Vincent 8:40
For you personally, what would you say is the the current motivation to keep it going? Are you still actively building shopping carts professionally is it just it's an interesting space. I mean, that's always I'm building
Jacob Rief 8:52
shopping carts professionally and i and i do consulting around Django, CMS. And a lot of the code I use for django CMS is also part of Django shop. So there is a big synergy between those two projects. One of the biggest components of Jenga shop is a django CMS cascade, which is a plug in system for Django, CMS. And by maintaining that, that's deployed in many different companies. And by maintaining that a lot of code which is used for Junker shop is in there actually, it's Django shop itself without without cascade is not that is not that big.
Carlton Gibson 9:49
And can you use Django shop separately or is it does it have a hard dependency on Django, CMS,
Jacob Rief 9:54
there are people which use it separately. I never do it. Cuz I'm just used to it and I don't want to. I don't want to miss the functionality of django CMS.
Carlton Gibson 10:09
Fine. Well, so well, while we're on that topic, I'd wonder because like a lot of the mindshare now at the moment is with Django wagtail, which is the other, perhaps a newer entrant into the CMS space in Django. And I guess I'd also if I'm a newcomer, and I'm looking at the CMS options, and I've seen wagtail I've seen the buzz around it. What is it about django CMS that I should look at what's good about it? What are its strong points, would you say,
Jacob Rief 10:35
in my opinion, one of the strongest points is that you can attach your own applications onto pages onto CMS pages. I actually am not aware how wagtail works, I never used it. So I don't know if you can if you can also do that. And that's from my point of view. It's one of the really nice features of Django, CMS. And another one is that it's, it's just a really good citizen in the Django world. It just uses the Django admin for everything to administer the pages. It uses the same template template language. It uses all the components in Django, which are available. It has. It uses many libraries, which we have to use anyway. For instance, Django fighter or easy thumbnails are those library libraries, which you need to build to organize and to resize pictures. So it's just all very well integrated. And so Django shop plays into that same ecosystem and it uses same base libraries as django CMS
Carlton Gibson 11:59
right? He's kind of familiar, you would you would say?
Will Vincent 12:04
Yes. You know, another thing I was impressed by looking at Django sharp is the ability to do views, either as HTML or as restful endpoints. I'm curious. Was that there from the beginning? How was that added? Because that's a really nice feature since most Django sites, you know, I'm thinking of some of the third party projects I have where I don't have built in API support, and I should. So how did that come about? And what are your thoughts on, I guess, maybe a restful approach versus a, you know, static, or relatively static HTML page?
Jacob Rief 12:38
Yeah, that was one of one of the features which have been required and one of the shop systems that we have some more interactive, interactive components in, for instance, in the cart, and so on, and therefore I introduced Django rest framework to Django shopping. I've built everything around. Django rest framework. So all all the data which is transferred between the server and the client is always word Jason, or it's HTML rendered as template which is done. So you can or render it statically or just use the Jason. And therefore, for instance, the cart can be just updated on the fly if you just change any. If you change the items in the cart, it just recompute everything and it just regenerates the whole cart and you don't have to refresh the whole page, something which is seen very often in auto shop frameworks,
Will Vincent 13:47
right? I think I mean, Shopify has this built in I probably most most customers would expect that functionality this day and age and actually that leads into you also maintain or run Django Angular Third Party project, which is quite popular as well
Jacob Rief 14:03
with Django Angular was
I created Django Angular together with a shop. And there, I just wanted to use the form validation in Django in Angular, which was dear. And I searched a way to, to not have to rewrite the validation on the client side as on the server side. And so you can just use a Django model or a Django form, and just render it so that the client side validation is, is integrated into the Django forms. And so even if you have if
Will Vincent 14:48
that's really nice, yeah,
Carlton Gibson 14:50
Jacob Rief 15:21
that's that's exactly what I was trying to achieve. So that I can declare a form in Django, and was dead form declaration, I can just create the whole client site validation and even if the client even if, for instance, passwords cannot be validated on the client for obvious obvious reasons. So if you have a validation which has to be performed by the server, use the same channel to inject error messages. So those errors then are added Then are added to the form. So that you just view them without having to reload the whole page. And just to show them in there. So it's kind of similar to a REST endpoint. But I actually don't use the rest framework in there. Because it's the rest framework came later. And I did not use that at that time when I when I introduced the introduced Django Angular was was the forums. Something else which I did something else in Django, Angular is the if you have a button, and you want to have some kind of feedback, you can write your click handler so that you can chain all the things which have to be done. For instance, if you click a button you want that you want to take and then you want To send your data to the server, and then you want to wait, and then you want to do something else. And so that's also part of Django, Django Angular, so that, that these things can be integrated into one line of code was was a chain of promises, which then are concatenated.
Carlton Gibson 17:21
I mean, that sounds perfect for you know, so many use cases, even if you the thing that comes to mind is that whether or not people are using Angular, but if you're not fussed about which framework you're using, then, you know, to be able to just embed that with your form definition.
Jacob Rief 17:39
Carlton Gibson 18:59
because when components are the standard so that it applies across all the browsers. And so
Jacob Rief 19:06
Carlton Gibson 19:38
Jacob Rief 19:53
We have to somehow we have to also if you look at the Django admin which is mainly written using jQuery, that would be a great job to get rid of jQuery and to use native components in there. You can do almost everything you can do with, with, with jQuery nowadays with web components.
Carlton Gibson 20:16
Yeah, it's a slow job of file by file, removing that use of jQuery. And, you know, bringing it up to, you know, what, the standards these days.
Will Vincent 20:25
Well, so there's, you have so many open source projects. The last one I want to make sure we talked about was the Django WebSocket Redis. Because Carlton and I have talked a lot about async and WebSockets. On the show, and I guess I'm curious how that came about, and what are your thoughts on how that might bleed into the current async capabilities coming into Django 3.0 Plus,
Jacob Rief 20:48
well, that was preceded a little bit. Andrew Godwin's channels project and therefore, it's it's somehow popular Already became somewhat popular because it's easier to set up the channels. But it's using a completely different approach. More or less, it's, you have two entry points into Django, you have one async entry point, which actually is using g vent, which is a kind of pseudo threading model, but you have only one thread and and you have patched all blocking calls are patched so that they behave like async calls. And then you have Django and so and in order to so that they can communicate, I use Redis. So Redis is connecting the both the back parts of Django with with WebSocket Redis. So that the red it's the WebSocket part can communicate with the browser. And the Django part can communicate to the web socket parts through Redis that's the whole idea. And it was inspired by a talk from Roberto Drs. He gave on euro, Python and 2013. The talk is about how to integrate WebSockets in you whiskey. You whiskey is one of the most popular application runner, which used by Django. And then, after I've signed this, seen that talk, I decided to try to integrate that idea he gave on the talk into Django, it was more or less, it took me two weeks to fulfill and then that was a project later on some. Someone migrated that project to Python three, and it's still used quite a lot. It seems and some company They rely on it. And
Will Vincent 23:02
those companies support the project. I was
Carlton Gibson 23:03
going to ask because several times you've mentioned companies,
Will Vincent 23:06
I, how do we go? Because we
Jacob Rief 23:10
passed over, I had no time anymore to maintain the project. And I passed over the right permissions on GitHub and on pi API, because I I could not handle that. Together with Django sharp and the other projects I've done
Carlton Gibson 23:28
well what about on those projects like Django shell but you ain't you know, you it is it funded from the project work that you do so you can maintain it part of the project work or other companies don't depending on it that will directly sponsor.
Jacob Rief 23:42
The WebSocket project was sponsored later, some cons I got some money for consulting and for integrating it. I once ported it to a Hiroko installation for one French company I had some other some other requests for consulting but
nothing, nothing really big
Carlton Gibson 24:10
because this is the juggle, right? This is this is where it's like all the labor that goes in You mean you know, if you if all the things that we talked about in the last 20 minutes you've done that represents a massive amount of your, of your labor and your life was put out there. And then the difficulty that we talked about quite regularly on the show is how to make that work sustainable.
Jacob Rief 24:30
Well, with some conferences Currently, I'm working for the University of Innsbruck, and they are converting their own content management system to Django, CMS. So you have a steady income from there and I can in the evening, I can do work on my other projects and other libraries. They just have been created through the need I required for jungle shop when I when I wrote shop installations. And so I separated them always into smaller projects so that they can be reused by people, which did not require any Django shop functionality. For instance, the admin sortable tool was one of those side projects, which is now really, really popular in the Django world. I think it's one of my most popular ones from looking at the download. Because it just, it just does one thing and that's it. It does that well. And so it's so usable by many, many other projects. So it has a lot of dependencies.
Will Vincent 25:54
Yeah. I wanted to actually ask you on. So back to Django shop on payment provider. If you had any thoughts on as a developer, which ones are easier to use, I mean, stripe Braintree, PayPal, there's a bunch of others. I wonder if I mean, I have some thoughts on this. But I'm curious, since you have a lot more experience, you know which ones do it right. And where do you see the pain points when integrating with a payment provider?
Jacob Rief 26:20
I've done a few integrations. And
after seeing the API from stripe, I have to say that that's done. Done. Right. So stripe is really doing the best job I've ever seen. They have the best API, by far, the best documentation.
Will Vincent 26:44
Well, that's the one I I demonstrate in my, in my book, and I agree, and yet, I think they could do a better job. I mean, they for what they have to they have connected checkout and check out at least they're switching to a new API, which isn't I guess I guess the main thing I come up against is the difference between documentation and tutorials. And even stripe as good as it is doesn't have that many good tutorials. I mean, in fact, I've, they have a section of tutorials and a couple things I've written for different frameworks have been linked there. So, in general, I find the, all these companies I mean, you know, hosting companies for Roku to which does a good job. There's a need for tutorials, and I'm constantly I have some friends who work at stripe and I really like stripe, but I always tell them, why don't you just have a demonstration and pick four major frameworks of checkout of connector that you you know, have one engineer spend a day a week to maintain? I think that would be helpful.
Jacob Rief 27:43
I can't comment on this. I just like the API and for me, the reference manual is just enough. So I never looked at any tutorial, stripe tutorial.
Will Vincent 27:57
Right, right. Well, I yeah. You Probably wouldn't need to. Yeah, I agree. stripe is interesting, just as a business stripe when they started out because a company I worked at back in 20 2011, I think Quizlet we're one of the first companies to use the stripe and they were billing themselves as developer friendly. And now of course differently for everyone. But certainly at the time, both on the developer side versus PayPal, and then even on the user side, as a business user, PayPal back then you had to submit a request, wait for an email hours later, and stripe, you know, just gave it to you right away. Though, since we were an early user with stripe, I would email the team and be like, Hey, I could use a monthly consolidation here for my accountant. So it's been really interesting for me to see stripe grow over the years. And I like the idea of if you focus on developers early on, that pays off down the line.
Jacob Rief 28:54
Actually, I implemented for a client of mine a payment service provider from Germany, and they had the back in their Python API. And then they asked how to solve it, because they could not find any reasons. It was a server side exception. And there was no, I didn't get any feedback. And then I tried out stripe. And in half a day, everything was implemented. So it was really a really, really short time to to implement and before I spent a few days for it to implement another service payment provider, which just didn't, never went into into production.
Will Vincent 29:42
Right. Well, and I think part of this is the power within companies is shifting more and more to developers were in the past. And I say this because I was on the business side of that company. Quizlet you just wouldn't necessarily let the developers choose what they want to use. But more and more, I think developers are having a say in business and technical decisions we have with us.
Carlton Gibson 30:03
The the my experience with stripe was exactly this. We're in a position where there was a committee discussion going on about payment providers. And we'd get on the dev team we got long colons, stripe Doc's calm, where we can implement that. And we put it together in about while they're discussing it. And it was like, well, you, and we've got it implemented and implemented beats, you know, everything else, because it was like, well, this is already working. So we can have this or we can have the other one that you'll talk. Yeah.
Will Vincent 30:31
Well, I would say though, I'm still, you know, all these credit card companies. I mean, PayPal is amazingly resilient, and that many parts of the world still can use PayPal and can't use others. So a lot of times you have to add in PayPal, even though it's still not as fun to do as stripe For example,
Jacob Rief 30:49
one of the nice things about stripe is that you can just use the same form you have. You're in control of the form, and you just send content of the forum where you have the credit card information to stripe, and then you get a token from stripe and that token then can be reused in your server side implementation to finalize your payment. So you your application ever sees any part of the credit card. And so you don't have to be PCI DSS compliant, which you otherwise would be would have to be if if you would see the credit card numbers. That's something I've not seen any other payment service provider, they always redirect you to their site. Then the customer has to type in his credit card. Information and then it's your reader declined is redirected back to the
Carlton Gibson 31:57
yeah and the debugging experience. There is around
Jacob Rief 31:59
in that phase, you never know what happens. You might lose the client. And and you don't see you don't see any. Anything from what what's happening. And that was tripe, you don't have those problems,
Will Vincent 32:16
right. Well, I remember Patrick Collison, the CEO who came to our office, mentioning that very thing. And that was the thing I was asking him about, you know, why don't we have to do this? The same thing we have to do with PayPal and other ones. And I mean, I think what basically stripe takes on that risk at the cost of usability for users, and then they have to rely on being much better at their own fraud detection, because they're assuming that basically client risk, which is how they're able to not force companies to be PCI, go through those steps themselves, which is a brilliant idea, but also requires that you really are better at your fraud prevention, whichever way I think the whole Sorry, go ahead.
Jacob Rief 32:59
No, just just proceed.
Will Vincent 33:01
Oh, I was just gonna say it's if you look at the payment space, it's interesting that it really all comes down to that balance between they want to have as many people using their platform as possible but not, you know, trip the fraud wires where they're blocked. And so it's that tension where in many things in business, you know, you could say we're only going to accept companies and individuals who will never have a false fraud, or you know, have a false payment. But really, you want to be a little more aggressive on that and find that tipping point where you're opening up to more, more individuals and more companies and figuring out that acceptable level of fraud. So it's an interesting balance, I guess, I would say, and I think I know, internally, a lot of what stripe prides themselves on in addition to the documentation API as being better at calculating those things. Then, you know, other companies, that's sort of the secret sauce, because if they don't get that, right, they're gonna lose money. Long term
Jacob Rief 33:59
one The previous questions where you said that integrating a cart in a shopping framework is was one of the most hardest parts. Others told you in Django shop, I grabbed the idea which was already there. And that was called the shark card modifiers. And it's actually a way to program to change prices on the way you proceed to the checkout. So from my point of view, it's even quite easy because because it's everything you can, if you have to add some for instance, some additional costs for your credit card payment. Let's say because you have a you have to you have to add a percentage dear or you have to add a fixed amount for shipping costs or you have to add a Variable amount for shipping costs depending on the weight you have in the cart and so on. By using those cart modifiers, in Django shop, it really becomes easy, and they're all integrated into the process. Every time you do a change, everything is recomputed. And then it's sent back through the rest interfaces. So you always get an updated cart was updated information on the carts total. So in from my point of view, it's, it's not so difficult to implement the framework, it might be difficult to implement the card modifiers because they can get quite complicated. But that's a part which is which I leave out intentionally to search to the third party providers, and for instance, the payment service providers, they can add their hooks. So The cart modifiers can jump into those hooks and then at some additional costs, for instance, also have not only payment service providers but also shipping service providers in jungle shop as well. So you can calculate the weight and just ask the shipping provider and and tell the address, the destination address. And the shipping provider will tell you how much that cost will be. So all this computation is done. Not in Django shop but outside of Django shop
Carlton Gibson 36:34
with a plug in system or so that sounds super powerful. So nipping back to wills point about tutorials if I if I wanted to get started with Django shop, where would I go?
Jacob Rief 36:44
Well, the documentation is I there is some documentation there is a cookie cutter template and probably you should use that one and just create a project for yourself. It it Some product models, and you usually have to adopt them yourself. One of the major selling points of Django shop is that you have your own products. So you can design your own products, according to their physical properties. And then you use the Django admin to administer those products. So what you can do is to have lots, lots of variations built into the product. And you can and you don't have to rely on attribute value pair tables where you can define properties and so on. So, you use for each property you create your own own row in in the table or your own field and in a Django model. And so your models, they stay slim and they stay readable. And that's in my point of view. Nice. If you if you go to the Django admin, then you only get what you have to fill out. You don't get any fields, which are just always empty or never used. I've seen other shop frameworks that have, for instance, three different price fields.
Carlton Gibson 38:35
And even the commercial offerings, you have this same thing of this key value, you have to define this property and the value and it's like, it's well, it's difficult and laborious. And
Jacob Rief 38:44
yeah, and that's and that's something that's a problem you don't have in Django shop you only have the fields you need. And therefore if you start, I have a I have three different sample models. There are models which are based on a polymorphic base so that you can do variations of the product. Or you can just if you have, if you just want to sell once one single type of product, you don't need a polymorphic base class. And then you can just proceed from there and add remove fields, add fields, however you want. And the Django admin will just reflect the fields and you just reuse the Django admin to get your back end in Django shop. four to two.
Carlton Gibson 39:39
So it's worth it. If I if I'm integrating with an existing site, it's worth using the cookie cutter project, experimenting with the sample models and then moving into my existing project.
Jacob Rief 39:49
That's my intention. Yes. Okay, super. And one, and if you have product variations, let's say you have a T shirts and They are they have different sizes and they have different colors and they have different Additions on them. You you implement into your own into the product, you implement the decision if this is a variation of itself, or if it's a new product. So, because in the cart if you if you add the product twice in the cart, you want to have it shown or as two different products or you want to have shown it as just an increase in the quantity of the product. And by putting that functionality from the shop framework into the product. The quote does this question. The product can decide if it's if it's equal or if it's
variation of itself.
Carlton Gibson 41:03
Anything else you particularly want to mention or cover? Yeah, cool.
Jacob Rief 41:07
Yeah, that's something else in Django shop where I also wanted to add some hooks in there is, if you if you have orders in order to you, the order is there, then you have to wait until the money is arriving, then you have to go to your stock and just to pick up the goods, and then you have to pack the goods and you to give that to a send to a courier courier. And all these steps are not, again, not implemented into Django, the Django shop framework itself, but you have a kind of order workflow. We're together With a with a Phoenix, Django FSM, which is a Django finit state machine, you can just program if your order reached that state, then you then those other actions are available. And so you can reprogram the whole ordering process even with even with aborts. And even if something comes back, because somebody sends back a good state they didn't want, you can all integrate that into into that order. framework. And so it's all part of the programmer, which then uses the giant Jenga sharp framework and it's not. So the framework itself remains relatively small. Fine,
Carlton Gibson 42:59
isn't sounds a lot Look at we should do an episode on some of these other packages because dango FSM is great for controlling finite state machines using the Django ORM for persistence, it's super. Okay. Well, I think we're kind of running out of time here now. So Jakub, thank you for coming on the show. And thank you for all the work you do on all these super packages. It's, you know, your absolute store to the community. It's really been good chatting to
Jacob Rief 43:24
you. Okay, thanks.
Will Vincent 43:25
Yes, thank you. Okay, everyone. You can always find new episodes at Jango chat, calm and reach out to us at chat chango on Twitter. Bye bye.