# makemigration for clean project

**URL:** <https://forum.djangoproject.com/t/makemigration-for-clean-project/23332>\
**Category:** Mystery Errors\
**Created:** [August 24, 2023, 9:11am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332 "2023-08-24T09:11:54Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 24, 2023, 9:11am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/1 "2023-08-24T09:11:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 24, 2023, 9:20am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/2 "2023-08-24T09:20:00Z")

</div>

Copy and paste the complete traceback here

---

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 24, 2023, 10:03am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/3 "2023-08-24T10:03:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 24, 2023, 10:07am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/4 "2023-08-24T10:07:32Z")

</div>

> [@Reza](#):
>
> DB config to postgreqsl

can you share your DB config

---

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 24, 2023, 10:09am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/5 "2023-08-24T10:09:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 24, 2023, 10:12am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/6 "2023-08-24T10:12:02Z")

</div>

py manage.py inspectdb \> authentication/models.py

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

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 24, 2023, 10:15am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/7 "2023-08-24T10:15:47Z")

</div>

> [@PeimarReza](#):
>
> ‘NAME’: ‘old\_database’,

Is this some old DB that you are using

---

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 24, 2023, 10:18am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/8 "2023-08-24T10:18:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 24, 2023, 10:28am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/9 "2023-08-24T10:28:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 24, 2023, 10:31am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/10 "2023-08-24T10:31:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 24, 2023, 1:21pm UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/11 "2023-08-24T13:21:45Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 24, 2023, 2:21pm UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/12 "2023-08-24T14:21:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 24, 2023, 2:26pm UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/13 "2023-08-24T14:26:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 24, 2023, 3:20pm UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/14 "2023-08-24T15:20:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 24, 2023, 7:41pm UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/15 "2023-08-24T19:41:55Z")

</div>

How are you creating your project?

What precisely do you mean by:

> [@Reza](#):
>
> and created from first

---

<div class="post-metadata">

**Author:** ![Reza](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/reza/32/15557_2.png) [@Reza](https://forum.djangoproject.com/u/Reza)\
**Post date:** [August 25, 2023, 1:34pm UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/16 "2023-08-25T13:34:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![agrillo91](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/agrillo91/32/24259_2.png) [@agrillo91](https://forum.djangoproject.com/u/agrillo91)\
**Post date:** [October 1, 2024, 6:51am UTC](https://forum.djangoproject.com/t/makemigration-for-clean-project/23332/17 "2024-10-01T06:51:33Z")

</div>

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