0

I am trying to run python manage.py makemigrations and the below exception is being thrown.

please note that - 1 - I have my own User class in models.py 2 - Two model classes, one inside the app and other file outside the app. Outside models.py was generated class based on my db schema. I have used the below command to auto generate the file.

python manage.py inspectdb > models.py

Below is the error thrown upon running - python manage.py makemigrations

Traceback (most recent call last):
File "C:\Django-Foodl\Foodl\manage.py", line 22, in <module>
main()
File "C:\Django-Foodl\Foodl\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Eswar\AppData\Local\Programs\Python\Python311\Lib\site- 
packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "C:\Users\Eswar\AppData\Local\Programs\Python\Python311\Lib\site- 
packages\django\core\management\__init__.py", line 416, in execute
django.setup()
File "C:\Users\Eswar\AppData\Local\Programs\Python\Python311\Lib\site- 
packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Eswar\AppData\Local\Programs\Python\Python311\Lib\site- 
packages\django\apps\registry.py", line 116, in populate
app_config.import_models()
File "C:\Users\Eswar\AppData\Local\Programs\Python\Python311\Lib\site- 
packages\django\apps\config.py", line 269, in import_models
self.models_module = import_module(models_module_name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Eswar\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", 
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 936, in exec_module
File "<frozen importlib._bootstrap_external>", line 1074, in get_code
File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
SyntaxError: source code string cannot contain null bytes
Eswar
  • 25
  • 1
  • 9
  • There seems to be a damaged source file that contain an invalid character (`\x00`). – Klaus D. Jul 11 '23 at 04:08
  • Check your docstrings - I got this once because of a docstring- [Problems with docstring containing backslash characters](https://stackoverflow.com/q/44296354/674039) – wim Jul 11 '23 at 04:11
  • @KlausD. - Is there any way to check the exact file which contains the invalid character? I have multiple files in my project – Eswar Jul 11 '23 at 05:10
  • If I find 'x\00', what should it be replaced with? @KlausD. – Eswar Jul 11 '23 at 05:28

0 Answers0