Postgresql connection to Django

Asked

Viewed 75 times

1

Good afternoon, I’m having a problem connecting Django with Postgresql

I installed psycopg2 on Jango, changed the connection in Settings.py to connect with postgre and when I give the runserver it runs me returning the ip but on the "Page not found (404)"

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('DB_NAME','apiWikkiDjango'),
'USER': os.environ.get('DB_USER','postgres'),
'PASSWORD': os.environ.get('DB_PASS','root'),
'HOST': 'localhost',
'PORT': '5432',
}
}

By clicking on the IP provided from that error, but by doing the tests like get, post, etc on Postman, everything works normal.

My main url:

My main url is like this:

urlpatterns = [
    url(r'^produto$', ProdutoList.as_view()),
    url(r'^produto/(?P<pk>[0-9]+)$', ProdutoDetalhes.as_view()),

    url(r'^pedido$', PedidoList.as_view()),
    url(r'^pedido/(?P<pk>[0-9]+)$', PedidoDetalhes.as_view()),

    url(r'^usuario$', UsuarioList.as_view()),
]

The other url looks like this:

urlpatterns = [
    path('admin/', admin.site.urls),
    url(r'^api/', include('api.urls'))
]

Essa é a pagina que vejo ao clicar no ip

  • Do you have a page mapped in the project’s urls.py? You have a Swagger installed that wants to display the urls in the browser?

  • According to the message you accessed the URL without giving the path, and your.py url is only mapped to admin/ and ^api/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.