Error("ValueError: source code string cannot contain null bytes")

Submitted 3 years, 10 months ago
Ticket #16
Views 1927
Language/Framework Python
Priority Urgent
Status Closed

After connecting my django project with mysql localhost database i had created an app after that run the command python manage.py migrate then afterwards i had auto generated models.py by using command "python manage.py inspectdb login > crudapp/models.py" after that when i run the server i got this error. kindly help i had to complete my final year project.

Submitted on Jun 06, 20
add a comment

2 Answers

Verified

is it something really urgent ?..Because you raised the ticket as urgent

Submitted 3 years, 10 months ago

Yes, i have to submit my final year project that is the reason it is urgent my due date is near

- moazamrana22 3 years, 10 months ago

what error you are getting.. ?. What does it mean auto generated model?

- Vengat 3 years, 10 months ago

oh k ..are you existing database with newly created models is it?

- Vengat 3 years, 10 months ago

Actually by using the command "python manage.py inspectdb table_name_in_database > appname/models.py" the code in the models.py was generated automatically but then when i run the command of python manage.py makemigerations and python manage.py migrate i got this error("ValueError: source code string cannot contain null bytes")

- moazamrana22 3 years, 10 months ago

can you show your Model structure and database table structure?

- Vengat 3 years, 10 months ago

i am using mysql localhost by xampp my database is fine plus when i run the command python manage.py migrate after making the connection with mysql database it inserted build in 10 tables to my database but after making an app in my project and adding the name of that app in installed_aps in settings file when i run the command for migrate i got the error that i mentioned before

- moazamrana22 3 years, 10 months ago

may be try delete the models.py file content and recreate the same content and save the file. i hope you are using some texteditor ,just try this and let us know

- scott 3 years, 10 months ago

ok i'll try

- moazamrana22 3 years, 10 months ago

i think this could be the some text converter issue.

- scott 3 years, 10 months ago

dont create the models again.. just copy , delete & paste the content.

- scott 3 years, 10 months ago

it is start working but i am getting this warning plz tell me about this too. WARNINGS: ?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default' HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion,

- moazamrana22 3 years, 10 months ago

it is start working but i am getting this warning plz tell me about this too. WARNINGS: ?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default' HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion,

- moazamrana22 3 years, 10 months ago

Awesome.. This is more related to Database issue. Please submit the new ticket , respective techions will guide you

- scott 3 years, 10 months ago

Also, if everything looks good from this ticket perspective, then close this ticket.

- scott 3 years, 10 months ago

Sure i will bro you guys are just amazing it took me 2 minutes to handle the issue with your help. Thanks alot.

- moazamrana22 3 years, 10 months ago

We are glad to help you. As you can always support us Donate . If you want :)

- scott 3 years, 10 months ago

Can you close the ticket?

- Vengat 3 years, 10 months ago

models.py from __future__ import unicode_literals from django.db import models class SalesAnalysis(models.Model): sid = models.BigIntegerField(db_column='Sid', primary_key=True) # Field name made lowercase. pid = models.BigIntegerField(db_column='Pid') # Field name made lowercase. item_name = models.CharField(db_column='Item_Name', max_length=100) # Field name made lowercase. quantity_sold = models.BigIntegerField(db_column='Quantity_sold') # Field name made lowercase. price = models.DecimalField(db_column='Price', max_digits=10, decimal_places=0) # Field name made lowercase. cost = models.DecimalField(db_column='Cost', max_digits=10, decimal_places=0) # Field name made lowercase. profit = models.DecimalField(db_column='Profit', max_digits=10, decimal_places=0) # Field name made lowercase. date = models.DateField(db_column='Date') # Field name made lowercase. def __str__(self): return self.name class Meta: managed = False db_table = 'sales_analysis' unique_together = (('sid', 'pid'),)

Submitted 3 years, 10 months ago


Latest Blogs