What should I version while doing an API versioning in Django - django

Currently, I am doing an API versioning for our project. We have 10 apps and 45 API endpoints. Each app has models, tasks, utils, constants, serializers, views and urls files. Now, I have created an apis app which contains version folder e.g v1, v2 etc. and each version folder contains serializers, views, utils and urls files.
Now, I need to know what should I consider for versioning? should I version the tasks, utils and constants also? And how should I do versioning for models?
Please guys help me to sort out this.

Related

Project structure for API only Django project

I want to create a Django based backend providing an API using django-rest-framework only. The admin interface is the only visual interface I need for end users. The API shall be used by/integrated with a JS frontend. The backend consists of several parts like configuration, visualization, etc. According to design best practices I'd first create a Django project my_project with django-admin startproject my_project . and add an app per part with python manage.py startapp configuration, python manage.py startapp visualization, etc. (In the django-rest-framework quickstart there is generated one Django app.)
To me it's not clear how I have to adopt the Django design best practice of using apps to RESTful API based JS frontend integration. In case I want to integrate the backend with a JS frontend how should I structure my codebase? Should I create apps configuration, visualization, ... (I don't create template based views) and define corresponding models with a single RESTful API. Where should I place the API sources w.r.t. project structure? How should I map the API to models?
DRF extends Django views and sort of replaces forms with serializers. So you can use exactly the same structure with Django. Or if you like, you can move the DRF modules to a separate api package either for each app or project-wide. It all depends on you. But to keep it simple since it's an API only project, you can just use the normal Django app structure with DRF modules flat in the apps

Is it possible to access the Models/Database Entries that are present in a different project? [DB names are same in settings]

I am working on 3 different Django Projects named frontend,API,Backend. I have successfully implemented a custom Admin Interface as Backend, A middle layer for API request/Response and a Front End for consuming those APi's [without using Python & Django] (Only HTML,CSS,Javascript, Jquery, ajax)
Now the Problem is that I do not know a way to use all these together. Someone told me that these can be run at once like a single project. How can I access the DB present in the API project's Models to use in Backend and Front End?
Can providing the same DB name in API and Backend Solve the problem? How can I integrate my Backend to the API?

Django + Vue with multiple apps

There are plenty of tutorials and helpful posts how to use Django and Vue properly (in various options) all over the Internet.
But I didn't find a single one who describes how to create a Django application which consists of more than one app, each having it's own part of the Vue frontend.
I am creating a Django application with a Vue frontend, and it will have a lot of apps that can be plugged into the main system very easily (using a custom framework). But this only is the backend. I'd like to enable each Django app for having a "plugin" part of the frontend as well: e.g. a set of Vue components that are rendered "dynamically" in the frontend when this app is added in INSTALLED_APPS.
How can I provide "plugin hooks" in Vue to load those components? All the things I have seen (dynamic/lazy component loading with webpack using webpack-loader, etc.) is not what I want. It only describes how to load a component that is predefined later in the http request timeline.
How am I supposed to "merge" all the components? Can I simply create components in static folders and let ./manage.py collectstatic do the magic?
It doesn't matter if the application is a SPA or maybe I have to use Django templates (with Vue components included) - both would be a viable method.
Maybe this even is a webpack question and should be: How do I bring Vue (or React, etc) to collect its sources from different subdirectories like foo_app/static/, blah_app/static/, bar_app/static - is there a way to tell Vue/Webpack/etc to search in myproject/*/static for Vue components to merge?
And can I include "all components" (dynamical amount) than in another component, which is needed for such a system?
Can anyone enlighten me here - is that completely impossible? Or am I thinking in the wrong direction?
Thanks.
I have a couple of VueJS apps in my django site and I'm planning to add more.
I bundle them with webpack with the help of django-webpack-loader.
https://github.com/owais/django-webpack-loader

Include only part of ember addon in ember app

Currently I'm working on a project which uses Ember and requirejs. My plan is to migrate the project to ember-cli, but I'm facing some problems.
My app consists of multiple apps and one shared folder in which I put shared code of all other apps (like models, adapters, serializers, helpers, routes etc.). Not all of this code is used by every app, they only require what they need.
My plan is to create multiple ember apps of the apps mentioned above and move the shared code to an ember addon. Now I am wondering if it is possible to only include a part of this ember addon into the applications (only what they need). I did not find any relevant information in the docs for this use case.
Any ideas would be appreciated.
I ended up using the addon folder within my addon to share most of the files. This files can be imported from all apps and when building only the imported files are included into the final build file.

Django app as REST-based service

According to the documentation, an app is a module which deals a well defined operation.
Is it correct to think about an app as a REST-based service? or is it mandatory to use some framework like piston or tastypie to create a RESTful web service around an app?
Generally, no. Django app is really just a python module, with some interfaces to django internals like models, urls, admin discovery etc.
To implement REST, you still have to manage network communications via views, and this is where you either write your own code or use the help of tastypie/piston/etc.
Please do have a look at django-rest-framework, I just stepped over from tastypie to this new framework, works great!
http://django-rest-framework.org/
Especially the class based views and the browsable api! and may other advantages (e..g. to upload images)
And to answer your question:
The rest-base service is an extra entry to your webapp.
I made some api's for some projects using the django-rest-framework, most project members were surprised they got a webapp as an extra, while it was actually the other way around. You make a django app (with views models and urls) and on top off that you make the api.