Jump to content

[Krydos] Django+Postgres (migration) and Logging


Recommended Posts

Posted (edited)

I have a django api running on heliohost on the domain anasbashir.helioho.st. And I got wsgi access also got postgres enabled. But how can I access the postgres. 

 

I want to be able to migrate the django models into database, for that either I need remote access to the postgres or terminal access to the server. 

 

The manage.py file is located in /httpdocs/manage.py

And the command to migrate is python manage.py migrate. 

 

Secondly, where do I access the traceback log if any error occurs, I couldn’t find it. Additionally, if I wanted to log something using python’s logging module, where can I log to, and how can I access it. 

 

Edit: I wanted to mention that I did find the logs. Just that I couldn’t find any traceback in it.

Edited by an4s911
  • an4s911 changed the title to Django+Postgres (migration) and Logging
Posted

Tracebacks usually dump into the Plesk Logs section if there is one. They're a bit hard to read because of how Plesk formats them, but they're usually there. If you can't find what you need, just let us know and Krydos can check the backend for any additional logs.

As for Postgres, there is no management tool and it does not support remote access by default. You have to either install something like Adminer, or request remote access to it so you can connect from a desktop tool like pgadmin and configure it that way.

What is the name of the database and database user that needs remote access? 

Posted (edited)

The name of the database is: an4s911_anas
and the user is: an4s911_admin

Also give me info on how I can connect to it from my Django app. Should I just use localhost? Will that work?

Edited by an4s911
add user info
Posted
3 minutes ago, wolstech said:

If you can't find what you need, just let us know and Krydos can check the backend for any additional logs.

Yeah, I couldn't find them. In plesk I opened logs. I only get the Requests and Http status codes. I don't see the trackeback of the errors.

Posted

To access it from a Django app running on our server, yes just localhost. To access it remotely, you’ll use the server host name (tommy.heliohost.org).

Escalating to Krydos.

  • Like 1
Posted
6 hours ago, an4s911 said:

The name of the database is: an4s911_anas
and the user is: an4s911_admin

Remote access enabled.

host=65.19.154.90
port=5432
user=an4s911_admin
dbname=an4s911_anas
password=<set in Plesk>

 

6 hours ago, an4s911 said:

I don't see the trackeback of the errors.

[Mon Apr 28 23:41:41.088433 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]     return _bootstrap._gcd_import(name[level:], package, level)
[Mon Apr 28 23:41:41.088443 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Mon Apr 28 23:41:41.088454 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
[Mon Apr 28 23:41:41.088464 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
[Mon Apr 28 23:41:41.088473 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
[Mon Apr 28 23:41:41.088482 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
[Mon Apr 28 23:41:41.088491 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
[Mon Apr 28 23:41:41.088509 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
[Mon Apr 28 23:41:41.088519 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "/home/anasbashir.helioho.st/httpdocs/library_app/migrations/0001_initial.py", line 7, in <module>
[Mon Apr 28 23:41:41.088529 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]     class Migration(migrations.Migration):
[Mon Apr 28 23:41:41.088538 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "/home/anasbashir.helioho.st/httpdocs/library_app/migrations/0001_initial.py", line 59, in Migration
[Mon Apr 28 23:41:41.088549 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]     'constraints': [models.CheckConstraint(condition=models.Q(('is_borrowed', False), ('returned_date__isnull', True), _connector='OR'), name='borrow_returned_implies_not_borrowed_check'), models.UniqueConstraint(condition=models.Q(('is_borrowed', True)), fields=('book',), name='borrow_unique_active_borrow_per_book')],
[Mon Apr 28 23:41:41.088561 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Mon Apr 28 23:41:41.088572 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584] TypeError: CheckConstraint.__init__() got an unexpected keyword argument 'condition'

 

Posted

Thanks a lot for giving me remote access for the postgres.

47 minutes ago, Krydos said:
[Mon Apr 28 23:41:41.088433 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]     return _bootstrap._gcd_import(name[level:], package, level)
[Mon Apr 28 23:41:41.088443 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Mon Apr 28 23:41:41.088454 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
[Mon Apr 28 23:41:41.088464 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
[Mon Apr 28 23:41:41.088473 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
[Mon Apr 28 23:41:41.088482 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
[Mon Apr 28 23:41:41.088491 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
[Mon Apr 28 23:41:41.088509 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
[Mon Apr 28 23:41:41.088519 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "/home/anasbashir.helioho.st/httpdocs/library_app/migrations/0001_initial.py", line 7, in <module>
[Mon Apr 28 23:41:41.088529 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]     class Migration(migrations.Migration):
[Mon Apr 28 23:41:41.088538 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]   File "/home/anasbashir.helioho.st/httpdocs/library_app/migrations/0001_initial.py", line 59, in Migration
[Mon Apr 28 23:41:41.088549 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]     'constraints': [models.CheckConstraint(condition=models.Q(('is_borrowed', False), ('returned_date__isnull', True), _connector='OR'), name='borrow_returned_implies_not_borrowed_check'), models.UniqueConstraint(condition=models.Q(('is_borrowed', True)), fields=('book',), name='borrow_unique_active_borrow_per_book')],
[Mon Apr 28 23:41:41.088561 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584]                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Mon Apr 28 23:41:41.088572 2025] [wsgi:error] [pid 1035813:tid 1035826] [remote x.x.x.x:58584] TypeError: CheckConstraint.__init__() got an unexpected keyword argument 'condition'

Where can I see this log? I looked for it all over the logs section in Plesk, couldn't find it.


Another question is, how can I use environment variables when deploying?

Posted
21 minutes ago, an4s911 said:

Where can I see this log?

Plesk doesn't do a very good job of filtering Passenger and WSGI logs. It's only accessible to root admins because it has a lot of private info from other accounts in the same file.

22 minutes ago, an4s911 said:

Another question is, how can I use environment variables when deploying?

Create a file named .env and use the python module dotenv to load it.

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...