Avatar ·

PyCharm, remote project and environment.

📁 вопрос, пример, django, боты, ии, проект

Good day everyone.

I have a remote Django project. I am configuring PyCharm to work with it via SFTP. Changes to files are reflected on the server (copied when modified).

Question. How can I read the environment from the server and also run the project on the server?

For example, there is a module on the server that is not installed on the local machine. How can I make autocomplete work for this module and prevent it from showing errors? Is it possible to make PyCharm think it is on the server, not on my machine? Because currently, SFTP is of little use to me (only automatic code copying).

Thank you.

Avatar ·

It's worth starting with how not to do it. For example, you should not iterate over objects in the database one by one:

for question in all_questions:    most_viewed_question = MostViewedQuestion.query.filter_by(question_id=question.question_id).first()

this loop is a definite no-no-no. This behavior should be avoided at all costs - it is MUCH better to query a million rows at once than to query one row a million times. If you need to get all MostViewedQuestion objects, it is better to do it with a single query:

most_viewed_questions = MostViewedQuestion.query.filter_by(question_id.in_=questions)

In this case, the need for

Log in to leave an answer

Интересные статьи