Google App data store and GQL in Django - django

Is there a way to use GQL and Google App engine data store with Django? If yes then how to use it, I have searched on web but I am unable to find any satisfying answers to this problem?

In case of both cloud-sql and django-nonrel we dont use GQL as query language. They use SQL and MySql. But I wanted to use GQL in Django. So when I looked at documentation of Google app data store and GQL for google app engine webapp2 I found out that it has nothing to do with webapp2, instead it was for python. So only thing which I changed to make it working for Django was the method of rendering the request.

Related

Displaying data retrieved through GraphQL in a Django website

(Disclaimer : I'm just getting started with Django, and with web dev in general)
I have a backend app that stores different kinds of resources. Some are public and some are private. The application is accessible only to identified users. A GraphQL API allows me to access the resources.
On another server, I'd like to create a website that will be accessible to everyone. I want to use Django to create it.
The website will display a list of resources tagged as "public" in the backend app, with a pagination system and, say, 20 resources by page. The CSS will differ from the backend app and there will be a search section.
From what I understand, I should be able to retrieve the data through the GraphQL API, but I'm a bit confused here. All the documentation and tutos I can find about Django and GraphQL seem to be about setting up a GraphQL API server with Django. All I want to do is to build custom queries and to display them on my different html pages.
How can I do that? Where should I start?
You should connect your project with a GraphQL client. As per my research, I have found that there are implementations and examples for graphene-mongoengine in Flask (Flask has a direct GraphQL client).
Mongoengine Flask with GraphQL Tutorial
For Django you can check this out
Edit- I was able to get the data from my database with python-graphql-client. Now I am able to display them in my template.
Let me know if this helps

How to use Django ORM with cloud NDB?

I am trying to create an django project in which database is handled by cloud NDB. I checked out the cloud ndb documentation here and it only specifies the middleware that I need to include in my settings.py file. I want to use django ORM facility but I don't know how to do that with cloud NDB. I don't even know if I can use it so any answers are welcome.
Thank you for help.

Airflow database querying

I am having a flask application which uses airflow data.I would like to access the airflow database from my flask application and query the data.I am able to run raw SQL query.But i should have a solution how to use SQL alchemy query technique in it. For example if i need the dag table data. I should be able to run Dag.query.all() to get all dag data.
Airflow uses SQLAlchemy (currently 1.1.x for the Airflow 1.10 trunk) to manage its models, so you can interact with and query them using the standard SQLAlchemy API as documented in the tutorial.
https://docs.sqlalchemy.org/en/rel_1_1/orm/tutorial.html
You can access your database using a standard database connection string from any Python code, such as your Flask app, as described in the above tutorial as well.
There are examples of various the database connection URL formats supported by create_engine() here.
https://docs.sqlalchemy.org/en/rel_1_1/core/engines.html#database-urls
You can find more info such as the fields on a particular model in Airflow's models.py file.
https://github.com/apache/incubator-airflow/blob/master/airflow/models.py
You can find more SQLAlchemy documentation here.
https://docs.sqlalchemy.org/en/rel_1_1/

How to use API Auth using Django MongoEngine REST?

I'm building an API REST using Django and MongoDB with django-rest-framework-mongoengine package from https://github.com/umutbozkurt/django-rest-framework-mongoengine
How can I use Django Rest Framework API TokenAuthentication if this package does not use Django's built in ORM ?
I solve it by handling TokenAuthentication or any other type of DRF auth using Django's build in ORM with MySQL database (Just to handle API authentication). I use MongoDB as my primary system database. So yes, i'm using two databases, one for auth API and the other for transactions.
Don't know if this is the best way to achieve this but it works.
I hope this helps to anyone who's trying or thinking to work with this architecture :)

django, google app engine and google drive api

I'm trying to create a simple django project (website) that authenticates the user using OAuth2 and returns a list of files from my google drive account using the drive api v2.
the problem is that I can't get the authentication working, the exception is:
'WSGIRequest' object has no attribute 'redirect'
if someone has managed to get some application going using django mtv file structure get give me some references or a sample project please reply
The sample application can be accessed at: http://helloworldbyionut.appspot.com/home/
If you use app engine, easiest way to do oauth is to use oauth_required decorator. It does all the Oauth2 steps automatically.