GeoNode / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
https://geonode.org/
Other
1.45k stars 1.13k forks source link

Issue connecting PostgreSQL database with Geonode #6555

Closed villa101101 closed 3 years ago

villa101101 commented 4 years ago

Expected Behavior

Migration should be done

Actual Behavior

error while migrating in Django

Steps to Reproduce the Problem

sudo systemctl stop tomcat

Initialize GeoNode

DJANGO_SETTINGS_MODULE=geonode.local_settings paver reset DJANGO_SETTINGS_MODULE=geonode.local_settings paver setup DJANGO_SETTINGS_MODULE=geonode.local_settings paver sync DJANGO_SETTINGS_MODULE=geonode.local_settings python manage.py collectstatic --noinput

python manage.py migrate

Specifications

Screenshot 2020-10-20 at 1 48 09 PM Screenshot 2020-10-20 at 1 49 30 PM Screenshot 2020-10-20 at 1 49 13 PM

I the error said I need to do the migration so I did the migration and had a different error. This is with the latest set of instructions on the docs

singh-atenekom commented 3 years ago

Hi @villa101101 It looks like the migrations have not fully applied on sqlite database. Something has broken during installation. Probably you can remove development.db in base directory und execute the above command once again. This will create a fresh copy of development sqlite db.

villa101101 commented 3 years ago

I tried redoing the installation from scratch using the new set of instructions but had a similar issue.

Expected Behavior

migration should be performed

Actual Behavior

connection error

Steps to Reproduce the Problem

Prepare the GeoNode Spatialite database

  1. ./paver_dev.sh setup
  2. ./paver_dev.sh sync

Specifications

Screenshot 2020-12-08 at 10 18 50 AM
singh-atenekom commented 3 years ago

Now you have different error. You have setup now postgres DB. Postgres db is not connected to django. Check if postgres database is running. If it is running, then you need to go to postgres database and create a user and password. You can create user:geonode and pass:geonode and set DATABASE_URL=postgres://geonode:geonode@127.0.0.1:5432/geonode.

If you don't need postgres db, then you don't need to set DATABASE_URL. sqlite3 DB comes as default with geonode.

I would say stay with sqlite DB it should work out.

villa101101 commented 3 years ago

The Postgres db is not running, but there is not step in the current documentation to address setting up the Postgres db.

https://docs.geonode.org/en/master/install/advanced/project/index.html#ubuntu-18-04

t-book commented 3 years ago

@villa101101 https://docs.geonode.org/en/master/install/advanced/core/index.html#configure-dbs-core Don't forget paver can run with spatialite. the link describes how to setup postgis which you could use with paver as well.

villa101101 commented 3 years ago

I have installed PostgreSQL and added the appropriate users. When I try to start the server I get this error:

[2020-12-09 16:01:13,110: DEBUG/MainProcess] Timer wake-up! Next ETA 0.9987038810213562 secs. Internal Server Error: / Traceback (most recent call last): File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/defaulttags.py", line 1021, in find_library return parser.libraries[name] KeyError: 'markdownify'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/core/handlers/base.py", line 145, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/core/handlers/base.py", line 143, in _get_response response = response.render() File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/response.py", line 106, in render self.content = self.rendered_content File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/response.py", line 81, in rendered_content template = self.resolve_template(self.template_name) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/response.py", line 63, in resolve_template return select_template(template, using=self.using) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/loader.py", line 42, in select_template return engine.get_template(template_name) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/backends/django.py", line 34, in get_template return Template(self.engine.get_template(template_name), self) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/engine.py", line 143, in get_template template, origin = self.find_template(template_name) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/engine.py", line 125, in find_template template = loader.get_template(name, skip=skip) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/loaders/base.py", line 30, in get_template contents, origin, origin.template_name, self.engine, File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/base.py", line 156, in init self.nodelist = self.compile_nodelist() File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/base.py", line 194, in compile_nodelist return parser.parse() File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/base.py", line 478, in parse raise self.error(token, e) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/base.py", line 476, in parse compiled_result = compile_func(self, token) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/loader_tags.py", line 266, in do_extends nodelist = parser.parse() File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/base.py", line 478, in parse raise self.error(token, e) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/base.py", line 476, in parse compiled_result = compile_func(self, token) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/defaulttags.py", line 1078, in load lib = find_library(parser, name) File "/home/geonode/.virtualenvs/my_geonode/lib/python3.6/site-packages/django/template/defaulttags.py", line 1025, in find_library name, "\n".join(sorted(parser.libraries)), django.template.exceptions.TemplateSyntaxError: 'markdownify' is not a registered tag library. Must be one of: account activity_tags admin_list admin_modify admin_static admin_tree admin_tree_list admin_urls announcements_tags avatar_tags base_tags bootstrap_tags cache client_lib_tags dialogos_tags floppyforms floppyforms_internals geonode_mapstore_client_tags groups_tags guardian_tags humanize i18n l10n layer_tags leaflet_tags log mptt_admin mptt_tags pagination_tags pinax_ratings_tags polymorphic_admin_tags polymorphic_formset_tags proxy_lib_tags social_tags socialaccount socialaccount_extra static staticfiles tz upload_tags user_messages user_messages_tags "GET / HTTP/1.1" 500 233668

villa101101 commented 3 years ago

This issue still persist

gannebamm commented 3 years ago

Hello @villa101101 The codebase you use seems to be old? Somewhere above It is stated you use version 3.0 which is an old version and you should update to the latest stable 3.x /3.1. If you want to start developing you can follow my workshop here: https://github.com/gannebamm/geonode-workshop

Since development should target the master branch that one is used in the examples provided there. You will use paver and in the second part PostgreSQL to get a working development environment.

villa101101 commented 3 years ago

Thank you for the link. It is proving useful. I am running this Geonode on a ubuntu and I wanted to know the steps to take for "reset dev environment and sync it again" section on a ubuntu server instead of using Pycharm

villa101101 commented 3 years ago

I thought the issue was resolved but when I tried to run the server it was still pointing to the sqlite db.

Exception Type: OperationalError

no such table: django_site /root/.virtualenvs/geonode/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py in execute, line 383 /root/.virtualenvs/geonode/bin/python 3.8.5 ['/opt/geonode', '/opt/geonode', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/root/.virtualenvs/geonode/lib/python3.8/site-packages', '/root/.virtualenvs/geonode/src/django-mapstore-adapter', '/root/.virtualenvs/geonode/src/django-geonode-mapstore-client', '/opt/geonode']

gannebamm commented 3 years ago

From the workshop documentation:

# load the dev.env variables
set -o allexport; source dev.env; set +o allexport
# load the postgreSQL.env variables
set -o allexport; source postgreSQL.env; set +o allexport

# sync the postgreSQL databases
paver sync

You have to export the environmental variables before running paver commands like paver sync | start | stop. Be sure that your runserver command (paver start) does use the PostgreSQL DB as backend - by exporting the env variables.