makemigration for clean project

Hi all,
I created standard django project, i added standard app with name ‘authentication’, i changed DB config to postgreqsl, I have done inspect for read models from db and write into authentication>models.py, i added autentication to my installed app list, now i want to make migration but “source code string cannot contain null bytes error”

what should i do?

Copy and paste the complete traceback here

Traceback (most recent call last):
File “D:\Django\project\manage.py”, line 22, in
main()
File “D:\Django\project\manage.py”, line 18, in main
execute_from_command_line(sys.argv)
File “C:\Python311\Lib\site-packages\django\core\management_init_.py”, line 442, in execute_from_command_line
utility.execute()
File “C:\Python311\Lib\site-packages\django\core\management_init_.py”, line 416, in execute
django.setup()
File “C:\Python311\Lib\site-packages\django_init_.py”, line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File “C:\Python311\Lib\site-packages\django\apps\registry.py”, line 116, in populate
app_config.import_models()
File “C:\Python311\Lib\site-packages\django\apps\config.py”, line 269, in import_models
self.models_module = import_module(models_module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Python311\Lib\importlib_init_.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “”, line 1204, in _gcd_import
File “”, line 1176, in _find_and_load
File “”, line 1147, in _find_and_load_unlocked
File “”, line 690, in _load_unlocked
File “”, line 936, in exec_module
File “”, line 1074, in get_code
File “”, line 1004, in source_to_code
File “”, line 241, in _call_with_frames_removed
SyntaxError: source code string cannot contain null bytes

can you share your DB config

‘default’: {
‘ENGINE’: ‘django.db.backends.postgresql’,
‘NAME’: ‘old_database’,
‘USER’: ‘user1’,
‘PASSWORD’: ‘User124082023’,
‘HOST’: ‘localhost’,
‘PORT’: ‘5432’,
}

py manage.py inspectdb > authentication/models.py

worked fine.
Is that means the DB config is working?

Is this some old DB that you are using

only the name is this, it is postgreqsl 14, up and run

There seems to be a damaged source file that contain an invalid character.

thank you so much, but i just installed python + django

@addwebsolution isn’t referring to software you’ve installed, but to your project itself. That error you are getting is most frequently seen when a source code file has gotten corrupted somehow.

Since you have directed the output of an inspect command into your models.py file, that would be the file I would check.

thank you so much, i deleted my project, and created from first, also i checked without Inspect, the result was same,

I see you’re using Python 3.11. What version of Django are you using?

C:\Windows\System32>django-admin --version
4.2.4

How are you creating your project?

What precisely do you mean by:

1- django-admin startproject my_project_name
2- cd my_project_name
3- py manage.py startapp authentication
4- config DB… in setting.py file
5- python manage.py inspectdb > authentication/models.py
6- verify manually models with DB tables
7- add app (authentication) to installed apps in setting.py
8- python manage.py makemigrations >>> Error

I’m having the exactly same problem. Did you finally find a way to solve it?