2

I am facing this error:

ValueError: source code string cannot contain null bytes

whenever I create a splite3 database and use it.

Below are the steps i follow:

  1. Create the database using db browser.
  2. Run python manage.py inspectdb > customer.py
  3. Run the server with python manage.py runserver

I get this error when I run the server. Could someone please help me with this?

5
  • Please provide the full traceback. Commented Sep 11, 2018 at 10:41
  • Does the server run without the file customer.py, meaning, does the error only happen when this file is present? Commented Sep 11, 2018 at 10:44
  • i don't now why but when I remove the app declaration on Installed app in setting.py the error disappear. Commented Sep 11, 2018 at 17:27
  • To answer your question yes the error happen only when customer.py is generated (automatically) they might be some correction to perform on the models before migration Commented Sep 11, 2018 at 17:27
  • I meet this issue again. After generating models by cmd "python manage.py inspectdb > customer.py", I have this error. I still can't fix. Hope someone have an answer. Commented Oct 24, 2018 at 13:36

2 Answers 2

1

open the file in IDLE or notepad and save it again with UTF-16 Encoding

Sign up to request clarification or add additional context in comments.

Comments

0

This could be an encoding error. You can try this:

  1. Copy the code generated by inspectdb (Ex: models.py)
  2. Open a text editor or notepad (select UTF-8)
  3. Save the file
  4. Replace the old file with this new one

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.