0

I am a newbie with Django trying a simple code to upload and delete a file. Following the instructions given at the accepted answer of Need a minimal Django file upload example, I was able to create a successful version to upload a file. However, while trying to delete individual files, I did some blunder, and later fixed it.

The problem is that the files I deleted while testing the first version of deletion code no longer exist as document files, but their IDs still exist somewhere in the memory (I can't figure out where). Although I managed to fix the code, I still get 'Delete' buttons next to the already deleted files (without names), and I can get document IDs when the user presses these buttons.

I have tried restarting the server and deleting the 'Media' folder from storage, but these buttons still exist. I still can't figure out where these reference IDs are stored. I just want a fresh version of the page to be launched without the buttons corresponding to already deleted files.

Any help would be really appreciated. Thanks in advance.

Community
  • 1
  • 1
BajajG
  • 2,134
  • 2
  • 25
  • 32

1 Answers1

0

They are stored in the database. You can access the database with python manage.py dbshell. If you haven't configured anything custom here it's probably SQLite. Here you can look up the correct table by entering .tables. Then you can use SQL to lookup and delete the model records which contain the non existing file references: SELECT * FROM my_table;, DELETE FROM my_table WHERE id = my_id;.

Lucas Moeskops
  • 5,445
  • 3
  • 28
  • 42
  • Thanks, I didn't have Sqlite3 installed on my 64-bit system, so I installed SqliteBrowser to delete the records from the database. – BajajG Jun 24 '16 at 16:22