Any way to get architecture document from django framework - django

I m writting two applications in django framework, and i would like to know if there are any tools available with which i can get entire architecture diagram of the project itself?
Kindly suggest.

Related

Python Web Frameworks For Production Level

I have been using Flask for Building REST API on the development level. I want to create REST API at Production Level. So which Python web framework would be Best?
These frameworks I saw while searching:
CherryPy
Flask
Django
Pyramid
TurboGears
Pylons
Web2py
Falcon
Bottle
Etc.
Django has a big support for REST API. According to my own experience I'd advice Django.
See more here: https://www.django-rest-framework.org/
For a REST API, I would use FastAPI. It has a strong reputation.
I have used it for several projects, and I like it because it fairly easily lets you do the right thing without much work. For instance, it relies upon pedantic to ensure the proper data types for what you are sending/receiving.

What should be the directory structure for a REST API in Django?

I am starting with developing REST API's with the Djano framework. Previously I have worked extensively with Java related frameworks specifically with SpringBoot.
If I take an example of a REST API in Java based framework below is the directory structure that I have mostly used :
So something mostly on the lines of a MVC Design Pattern.
Also in java mostly each class is written on a new file, however the tutorials that I have been looking around writes multiple classes within one file, is this the best practice around Django?
Also I see that in Django we create a project and then inside it we create an app. Are these app equivalent of package in java?
Also, in SpringBoot and other java related frameworks we normally follow a Top-Down approach, where a Controller recieves a call which is further passed on to the Service where all business logic resides which then further calls DAO(Repository) for CRUD and the corresponding result is passed from DAO to Service back to Controller which generates the formatted response.
What I have moslty seen in Django is all the logic is written on views which calls Model for CRUD. Don't we follow SOLID priciples here?
If I take an example of a library management system, How will one design that around the Django framework?
This is a great question, but I'm not sure that StackOverflow is the right place to ask it, as there is no clear-cut answer. That said, I'm trying to give it a shot.
Django also follows the MVC design pattern, but the naming is a bit different.
Django Models -> MVC Models
Django Views -> MVC Controllers
Django Templates -> MVC Views
It is often referred to as MTV instead of MVC. But that's not the end of the story, because many people think it is a bad idea to put too much business logic in the views, for reasons like testability and reusability. There are two common approaches to this issue:
fat models: you put all your business logic inside the models
services: you have separate modules containing methods/classes for your business logic
Personally, I have worked with both and had better experiences with the services approach.
The equivalent to a DAO in Django is probably the Django ORM. Note that this is really only an abstraction layer for the supported relational databases. If you want to use another datasource like a NoSQL DB or a REST API, you have to roll your own solution or look for third-party packages.
Java can only have one public class per file and they must have the same name. Python does not have this limitation, so it is indeed a best-practice to have multiple classes per file (.py files are called modules). If a module/file becomes too large, you can turn it into a package (a directory with a __init__.py file) containing several modules (and/or sub-packages).
The differentation between app and project can be confusing, so I have written a whole article about Django's naming scheme. A Django app is a Python package, but they are usually organized by domain. E.g. in a library management system, your library project might have an app catalogue to manage the inventory, and a checkout app to manage the process of checking out books.
Finally, if you are specifically aiming to build a REST API, I highly recommend you have a look at Django REST Framework.

Integration of cloudant with django

I am new to cloudantdb and django. Is there any way to integrate cloudantdb with danjgo framework. Is it possible to connect cloudant with django?
As you may be aware, Cloudant is built on Apache CouchDB, so if you can't find references for Cloudant, it's usually worth also searching for CouchDB. I don't really use Django, but a quick search throws up the following references:
http://leok.me/2013/05/02/what-you-need-to-know-couchdb-django/
https://lethain.com/an-introduction-to-using-couchdb-with-django/
http://eflorenzano.com/blog/2008/11/10/using-couchdb-django/
https://djangopackages.org/grids/g/couchdb/
Most if not all solutions on the web are very outdated.
The solution used by IBM in a capstone project on Coursera was:
Use SQLite backend in your Django app
Create Cloud Functions for communicating with Cloudant
Create REST API definitions in your Django app that utilize the Cloud Functions to communicate with Cloudant
I don't know if it's the best solution, but it works. I do feel like SQLite is redundant at this point but without it, I couldn't get the app to work.

How to migrate Django project to Google App Engine

I am looking for a guide to migrate Django project to Google App Engine and use Google's datastore. The most of the guides I found were linked to Django-Appengine using Django-nonrel (but I want to use GAE's native support).
Going through GAE getting started guide, it says:
Google App Engine supports any framework written in pure Python that speaks CGI (and any WSGI-compliant framework using a CGI adaptor), including Django, CherryPy, Pylons, web.py, and web2py. You can bundle a framework of your choosing with your application code by copying its code into your application directory.
I understand that I won't be able to use some features of Django in that case (majorly the admin feature) and would also need to restructure the models.
From other reading, I also found that latest SDK of GAE now includes Django 1.3 on Python 2.5.
I tried to put all files from my Django application to a GAE project, but couldn't get it all to work together.
Please provide some basic guide using which I may migrate my Django project to Google App Engine's code.
Thanks.
For an existing Django app, using django-nonrel is the simplest approach; it is very popular so you should be able to find help with specific errors you get quickly.
Another approach is written up in this article: http://code.google.com/appengine/articles/pure_django.html -- it goes the other way, taking an App Engine app that uses Django for dispatch, templates, and forms, but not for models, and describes how to make it run in a native Django environment. Maybe you can glean some useful hints for your situation from it.
I've used django-nonrel, which behaves pretty much like django, except that operations with JOINs will return errors. I've basically worked around this by avoiding ManyToMany fields, and essentially building that functionality manually with an intermediate table.
So far I've ran into two problems with Django-nonrel:
1. No access to ancestor queries, which can be run in a transaction. There's a pending pull request for this feature though.
2. You can't specify fields that are not indexed. This could significantly increase your write costs. I have an idea to fix this, but I haven't done so yet.
(Edit: You CAN specify fields that are not indexed, and I've verified this works well).
2 (new). Google is pushing a new database backend called ndb that does automatic caching and batching, which will not be available with django-nonrel.
If you decide not to use django-nonrel, the main differences are that Django models do not run under App Engine. You'll have to rewrite your models to inherit from App Engine's db.Model. Your forms that use Django's ModelForm will need to inherit from google.appengine.ext.db.djangoforms instead. Once you're on App Engine, you'd have to port back Django if you ever take your app somewher else.
If you already have a Django application you might want to check this out. You won't work with App Engine's datastore but Google Cloud SQL might fit your needs.

What is a simple way to make a basic website with graph database backend for newbie?

Graph database systems like ne04j seem to becoming very popular of late. I am a newbie user who is trying to set-up a website that needs to display some data which is best displayed using a graph database (essentially i will visualize this on the website).
I am designing this website using CMS Drupal but i am open to changing to other CMS or in worst case a web application framework like Django. Can anyone suggest me a basic template, website or extension to a CMS that enable graph databases or a good way to start learning web app development using graph databases for a noob ?
Well, if you're curious about using Drupal to manage graphs, I'd recommend looking over these contributed modules:
http://drupal.org/project/graphapi
http://drupal.org/project/charts
http://drupal.org/project/views_charts
http://drupal.org/project/charts_graphs
There is http://structr.org/, a CMS built on Neo4j and very Open and capable. Other bindings, you might take a look at REST bindings and neo4j embedded bindings to get going.
If you're looking for even more alternatives for charting in Drupal, then you may want to start from the Comparison of charting module, which includes information and links about quite a lot of charting related modules in Drupal.
If you're aware of other modules not included in it, please update that docu if you can, or let me know about it.