0

My django views.py somehow got corrupted. The live django site is still just fine. Is there some way to restore the version of views.py that is currently live?

My last backup is 3 days ago. Otherwise, I'm out 3 days of work.

  • This is why you should use a version control system like Git. – xyres Jun 11 '23 at 02:46
  • You are absolutely right. That does not address my question, however. – Dr. Sarah Jun 11 '23 at 02:53
  • 1
    You can try and decompile the `views.pyc` bytecode file which should be cached in the `__pycache__` folder. See: https://github.com/rocky/python-decompile3 – xyres Jun 11 '23 at 06:14
  • Thanks so much! Since I have Python3.10, I had to use [pycdc](https://stackoverflow.com/questions/71278961/how-can-i-decompile-pyc-files-from-python-3-10) instead. It had some warnings and got in an infinite loop printing 6 lines before it crashed. I suspect it's confused by the django code. Still, I got about half of the file back and cobbled together a reasonable approximation with vscode diff. With my unit tests, I should be able to recreate the rest pretty efficiently. Thanks again! – Dr. Sarah Jun 11 '23 at 18:38

1 Answers1

0

if you use PyCharm File->LocalHistory normally has recent versions even without Git

Razenstein
  • 3,532
  • 2
  • 5
  • 17