Do I need to have a django website in order to use django rest framework, or can I use DRF by itself as a standalone app? Sorry but it is not so obvious to me. thanks for the help.
There are some parts you can use without Django though it might need to be installed.
This question feels like this isn't the real question. Why would you need DRF without Django ?
Well It's not that common but you can use Django framework's modules and classes in standalone scripts by importing Django.
For that you will need to add at the beginning of your code:
import django
django.setup()
django rest framework is a wrapper of django from rest APIs. django is required for django rest framework
Related
I have developed a Django e-commerce platform and then realized that I need to use FastAPI with it in order for my website to accept payments from the square payment system.
I have looked through their documentation about how to do it, and they use fast API. However, I have no experience using Fast API at all.
Is there a way for me to set up this fast API functionality without changing my Django project (so that it runs "together" with my Django app)? Or maybe there is another way which you would recommend me to use?
Yes there is django ninja having a similar Interface like FastAPI.
It also uses the same concept of routes and model definition with pydantic.
So you should be able to adopt the given example easily to the ninja api which works well in django.
Try django-mini-fastapi.
This is a django adapter for FastAPI, you could get most of FastAPI function working without re-writing your whole legacy django project.
Disclaimer: I'm the author of that repo. Also I've used this library on a production grade EC site without any problem.
Lets say we have one django project that has two apps - FooApp & BarApp.
Each app talks to its own database. Meaning they both manage their own set of models. Is it possible to manage the deployments of these apps independently? It's okay for them to be deployed on same server within the same nginx process as long as I am able to make changes to the apps without bringing down the other as well.
I understand that these can very well be separate projects and they can communicate with each other using RESTful APIs. For my needs, I want to avoid that REST interaction for the time being.
The django documentation [here][1] describes a django project and django app as follows
Django project:
The term project describes a Django web application.
Django App:
The term application describes a Python package that provides some set
of features.
So if the app is simply a python package, and the django project is really the one that defines how these apps are managed via the settings module, then I suppose there is no straight forward way of accomplishing what I want. Or is there anything I can do?
TIA
[1]: https://docs.djangoproject.com/en/dev/ref/applications/
I have been developing a django application, and now i want to give to someone for testing but i want to keep the sourcecode hidden/compiled so they can't modify it, is there a way to package a django application and still use Apache for serving it? Or any other solution for packaging a django application.
Thanks
OK.. i am starting a project in django 1.4 and i want MongoDB as my backend. after a half a day of google search, i figured out that mongoengine is a best option(as it is an active project and provides a django like orm)
Now the problem is
1. I cant find any good step-by-step setup guide to integrate mongoengine with a django project.
I understand, using mongoengine means that i am replacing django orm and there is no need to do syncdb. now this project have a multi-tenant architecture (*.domain.com) which i am gonna resolve using a middleware..also a considerable part of this project will work on django admin.
Question: will replacing django orm with mongoengine going to affect django admin and other operations(such as middleware, authentication etc.) ?
I am open to suggestions and criticism as well.
Django Admin is designed to work with the Django ORM only. Using MongoEngine and no Django ORM will mean you don't get the automatic admin interface. Other middleware might use the Django ORM or be sufficiently abstracted enough to allow you to plugin MongoEngine - eg: Sessions and Authentication.
There are some helpers for Django in MongoEngine - but its by no means complete or designed to be a drop in replacement for the Django ORM.
For more information see this presentation from Django Conf Finland: http://staltz.github.io/djangoconfi-mongoengine
Just in case, situation has changed and there is a solution now for this problem, namely django-mongoadmin.
A Guide to integrating Django with MongoDB
The way to connect Django with MongoDB by adding just one line of code:
First install djongo:
pip install djongo
Then run your migrations:
manage.py make migrations
manage.py migrate
and finally add to your settings file:
DATABASES = {
‘default’: {
‘ENGINE’: ‘djongo’,
‘NAME’: ‘your-db-name’,
}
}
It is as simple as that!
If you want to manipulate MongoDB using Django Admin, simply fire it up:
manage.py runserver
Goto: http://localhost:8000/admin/
Manipulate your embedded models as shown in this screenshot:
For more information do checkout the djongo documentation.
You should definitely consider the pros and cons of using a NEW framework (like MongoEngine) vs using inbuilt Django ORM. Do read at this tutorial before considering to adopt MongoEngine as suggested by other knowledgeable members! No offence!
Let me know if you agree with this approach in the comments :)
can a django application be run using paster? Or is it pylons specific?
It's pylons specific. There was a Django Paste project, but I'm not sure if it's active or how much progress was ever made.