Running Django and Neo4j on Heroku - django

I'm trying to deploy my Django app to Heroku using Neo4j's Addon.
I'm using Neo4django. Locally, in my settings.py I have the following
NEO4J_DATABASES = {
'default' : {
'HOST':'localhost',
'PORT':7474,
'ENDPOINT':'/db/data'
}
}
However, when deploying to Heroku, I change the settings to
NEO4J_DATABASES = {
'default' : {
'HOST':'<someid>.hosted.neo4j.org',
'PORT':7281,
'ENDPOINT':'/db/data/',
}
}
.. I am unable to connect to the database for authentication problems apparently.
The error at the bottom of my stack trace:
StatusException: Error [401]: Unauthorized. No permission -- see authorization schemes.
Authorization Required
.. even when I add the login and password provided by the Heroku Neo4j add-on.
Did anyone run in a similar issue before?
Thanks in advance

The Heroku-hosted Neo4j has the Gremlin plugin disabled, which is going to prevent you from running neo4django, bulbflow, or any other client-side library that requires Gremlin.
The most common solution is to run your own instance of Neo4j on AWS, and then connect to that. Please make it clear to the Neo folks that you'd like Gremlin support on Heroku- I think it was disabled because of the shared nature of the Heroku Neo4j instance, but it absolutely hobbles a number of libraries.

You can see the Neo4j config url by using heroku config --app your-app. Just use the NEO4J_URL from the environment variable in your code setup. It already contains the credentials for basic auth.

I've got this working by using graphenedb.com to host my neo4j database.
They will allow you to chose the version of neo4j that you would like hosted. If you pick 1.9.6 (or earlier), then the gremlin plugin works and so will neo4django.
You can either sign up with graphenedb via their website and create your db there or just use their heroku plugin (http://blog.graphenedb.com/blog/2014/02/06/our-new-add-on-helps-heroku-users-build-applications-on-top-of-neo4j/) which will do it all for you. The only advantage I've found of using the web interface is that you'll also get the neo4j webadmin.

Related

How do I prevent my Django Database from being overwritten

Currently I have a Django application running on my personal website from PythonAnywhere.com. When I make updates to the site I login to PythonAnywhere and git pull to update my application. When I do this the data that was entered through the website since the last update gets lost from the database when I update. What can I do to overcome this?
I am currently using the SqlLite version that comes preinstalled with the Django App. This likely could be part of the issue but need some help understanding how to overcome it.
I presume that your Django project is connecting to the SQLite database that gets generated when you create a new project and you are pushing that database in your deployment. That database won't be suitable for production and won't retain your changes, you instead need to setup a database that your application can connect to.
Here is some information on PythonAnywhere about databases:
https://help.pythonanywhere.com/pages/KindsOfDatabases/
And the Django documentation:
https://docs.djangoproject.com/en/4.0/ref/databases/

Error db.sqlite3 locked when deploying Django using option Continuous deployment in Azure App Service

When i'm deploying a Django project (tried two of them) in Azure App Services (Linux), i always get the error SQLite3 database locked: OperationalError: database is locked,when trying to log in. Has someone an idea or workaround to resolve the problem without changing to another database? I changed the default timeout as mentioned by the official django documentation: https://docs.djangoproject.com/en/2.2/ref/databases/#sqlite-notes, but the problem remain. I want to keep using sqlite database!
Thanks for your help.
App Service locks the db.sqlite3 file, preventing both reads and writes. This behavior doesn't affect an external database:
https://learn.microsoft.com/en-us/azure/devops/pipelines/languages/python-webapp?view=azure-devops#considerations-for-django
https://vscode-eastus.azurewebsites.net/docs/python/tutorial-deploy-app-service-on-linux
Test App: https://github.com/itsimplified/slick-crud-app
However, you should be able to use the following way to make the WebApp work by moving the SQLite to Azure Storage.
Please follow the below steps in order to achieve this:
Mount your Azure Storage to the WebApp:
Example:
Make necessary changes to the path of the DB file in the application:
Example:
You should also be able to see the DB file in the Storage:

deploying react and django (server side) application on googlecloud

I had created a web application.Front end is created by ReactJS and back-end(server side)is created by Django framework,
Here I am using PostgreSQL database.
The application is successfully running on my local machine by running both python manage.py runserver and npm start at a time in my terminal.
I need to deploy my entire app on google cloud using compute engine.
I already purchased a domain. I don't know how to connect these 2 platforms(Django and ReactJS) in cloud. if anyone knows deploy Django go as server-side and react as front-end in GooleCloud (using compute engine)
Even though your question is a bit broad, I think you may find these resources useful:
Getting started with Django [1]. You can compare the 4 main options to use Django in GCP.
Django Certified by Bitnami [2] is a ready to use pre-configured Django environment that deploys all the Compute Engine resources you need.
You can find more information on the Bitnami Django Stack For Google Cloud Platform here [3]
You could start using one of the pre-configured solutions and customize the VM by installing what you need afterwards. Or start with a blank VM and configure everything from scratch [4].
In a more general sense, this guide “Serving websites” [5] is a very good read to better understand all the options you have within Google Cloud Platform to host a website; more specifically, the section “Using virtual machines with Compute Engine” [6].
I’m assuming that you already know how to get Django and ReactJS work together, as you did it already in your local machine. I hope these articles are useful for you.
[1]https://cloud.google.com/python/django/#hosting_platforms
[2]https://cloud.google.com/marketplace/solution/bitnami-launchpad/djangostack?q=django
[3]https://docs.bitnami.com/google/infrastructure/django/
[4]https://cloud.google.com/compute/docs/instances/create-start-instance
[5]https://cloud.google.com/solutions/web-serving-overview
[6]https://cloud.google.com/solutions/web-serving-overview#compute-engine

Webpack prod config vs dev config issues

I am trying to reuse one webapp that's been open sourced a while ago that was written using some Django and ReactJS... Now I am a devops engineer so my skillset when it comes to JS and even Django are fairly limited so I am stuck .. My main problem is that this webapp can run just fine locally.. so I can start it and connect using http://localhost:8000 , but whenever I try and set it up on a server and make it "public" for the internal network it fails with accessing all the JS assets.
I know the problem comes with my webpack configs but I can't sort it out.. Been trying all day but I can't even find the proper documentation since it's using Webpack 2.5.
https://github.com/tsprasath/estate/tree/master/webpack
I am attaching the link to the webpack configs from the repo.. If anyone can at least point me to the right thing to look at, that would be helpful.
Thanks in advance!
I dont think its an issue with your webpack. You are trying to run your react app (which is at client side) from django server. I believe you will need to use some kind of middleware to let django know that it needs to use static files generated for react using webpack. I dont know exactly how its done, but same procedure is followed if react app needs to be served from node/express server.
Or see if this helps: https://github.com/nicholaskajoh/React-Django

Profiling django app hosted on apache2

I am having a django app which was hosted on apache2. The webapp basically makes a request to a server using thrift and renders the output on the webpage. I notice that webapp is really slow. I am not sure if it is machine problem or the API problem. I verified the API's and they are returning responses in few milliseconds. I am not sure, if django is the problem. Is there a way to profile the webapp. I am using python 2.5.2.
Please help.
Thank you
the simplest thing would be to enable logging, if you are using the latest django 1.3, it is nicely integrated with the python logging module, see:
http://docs.djangoproject.com/en/1.3/topics/logging/
here you can define a Formatter which saves the time each log message is written, see example in django docs:
http://docs.djangoproject.com/en/1.3/topics/logging/#an-example