I am working to develop on the website an application that built a picke file containing an object of a class defined on that project with specific data. I did not create that application and have no much knowledge of how pickle works.
Now I want to move this app to a web version and I decided to go with django. To do not repeat the proces of creating those models I thought of directly load the pickle file in views.py and use the object already to make some operations. However, I am not sure how to make this load process as directly making the query:
def load_regional_model():
try: with open(r"C:Users...picklefile.pkl", 'rb') as f: model = pickle.load(f) print("Model loaded successfully") return model except Exception as e: print(f"An error occurred: {e}") print(f"Error type: {type(e).__name__}") return None
throws error:
An error occurred: No module named 'model' Error type: ModuleNotFoundError
I started my django project from zero so I did not add any of the code from the app which creates the pickle. Should I? What am I missing?
user26700062 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.