Clear things up pls

I am fairly new to Django and I am learning it to create a web application that will have a website and a mobile app. I am struggling to understand how it all fits in together and I would love it if someone can just tell me if I am on the right track.

I am using REST Framework because I need the API for the app to use. So I want to know if I have to use the framework for the website itself? Reason why I ask is that the website is on the server so it is not going to call the API because it does not need to. It can access the database directly so why would it need to call the API? Also if I use the REST Framework for the website itself then I have to do a bunch of extra work rendering templates, which I don’t have to do if I just use the custom user model I created and create views to make the user register and login?

I have looked at 20 different videos and everybody does the authentication in a different way so it’s a little confusing and I really don’t want to use the username way because then again you have to do a bunch of extra work to check the user names and even give the user suggestions on what user name to use. It’s annoying when try to register on a site and you get told a number f times the username already exists, especially if you have a common name like John Smith :laughing:

Wow, a lot of questions here - let’s take a stab at some of them, shall we?

Always keep in mind that DRF (Django REST Framework) is an add-on package to Django. It supplements the facilities provided by the core framework. It does not “replace” or “hide” or in any way inhibit usage of any other component or app.

Along the same lines, the DRF doesn’t provide anything that you couldn’t write yourself - after all, it’s just another app. (Although, given the scope, quality and value of it, saying it’s just another app is selling it short except in the most narrow of terms.) The real value of the DRF is that it saves you the time and effort of trying to recreate that functionality.

So, use DRF where it’s appropriate, use core Django where it’s appropriate. And sometimes, using core Django to create API interfaces is appropriate too.

Authentication is an intricate and complex topic. There are no simple answers because there are a huge number of variations of needs and requirements. Using emails as a user name is a common alternative, but that has problems as well.
Any and every site allowing email addresses for identification absolutely needs to allow for secondary addresses for all purposes, or, now, even phone numbers for text messages. People do lose access to email accounts and phone numbers over time.


1 Like

Hi Ken

Thank you for the thorough answer and I also went on to do a lot of reading about this topic and decided to build my entire application using a web service (REST API) as the back end and a framework like Vue or Angular for the front end.

I get very little time to work on this app but I have given myself ONE year to complete it and build it exactly the way I have in my mind and in my plan. I will continue posting questions here and I thank you for always answering me with proper information.

Hi Calvin,

As a side note - not that it’s directly relevant to your questions but is perhaps related - I’ve got a pet side- project that I’m working on that is a hybrid app. There’s going to be a fair part of it that is pure Django. There are going to be two or three pages that will have a Vue-based front end as sort of “mini-apps” that will communicate through a websocket API. There will also be a couple of stand-alone processes that will also need to communicate to the server through an API. Probably going to use DRF for the latter, haven’t made any firm decisions on the former yet.


Hi Ken

Yes I like Vue and really want use that for my app. My app is basically 2 parts with the first part being a bunch of static pages I create in Django admin with the advice you gave me in the very beginning where I did not want to use flat pages. The second part is the really big part and it’s a one page application where everything happens on the one page and you can access it after logging in. Today I actually got to do a lot of work and made a lot of progress and I understand django and DRF a lot better. But yeah some of the things still coming is highly complicated and so is my project, but I feel good and confident I can do it. Thanks for the help Ken and good luck with your project. More questions to come I guarantee :smile: