In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
A friend emailed me about the setting of django environment variables. He should want to set up a separate module under the django project to synchronize the relevant data to the database.
In this way, by running the file, you can use the simple model operation ready-made by django to achieve the purpose of synchronizing data. Here is a screenshot of his question:
From the error prompt, it should be that the environment variable is not set properly, which makes it impossible to make use of django-related modules and data.
My reply to him was:
Import os, sys
Dirname = os.path.dirname (_ _ file__) # current working directory
Sys.path.append (dirname)
Import settings # Assumed to be in the same directory.
Setup_environ (settings)
From django.db import connection
In this way, the current file can call the relevant modules and properties of the system. I hope it will be helpful to you.
For more information about from and import import methods, see:
Http://www.iplaypython.com/jinjie/from-import.html
Http://docs.python.org/2.7/tutorial/modules.html#importing-from-a-package
Http://hi.baidu.com/weiweisuo1986/item/ab85001259d059dabf9042ce
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 223
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.