OperationalError

36 views
Skip to first unread message

Gerald Brown

unread,
May 1, 2018, 7:56:12 PM5/1/18
to Django users
I have a Django application that I am having problems with.  In the Admin page I have 3 sections, ABC, DEF & XYZ. Each has 1 option to "Add/Change".  In 2 of them when I click on the option it works fine. The third gives me the following error "
1054, "Unknown column 'xyz_xyz.first_name' in "field list"

The Exception location is: /home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/MySQLdb/connections.py in query,
line 277


On another system (both running the same code) I was also getting a different error also in site-packages/MySQLdb but I was
able correct that by installing 2 DEV packages and then
installing MySQLClient, which I also did on this computer. The other
system does NOT give this error.

Any ideas, suggestions, solutions on how to solve this error and any other errors in the Django code?

Thanks.

Anthony Flury

unread,
May 2, 2018, 3:00:55 AM5/2/18
to django...@googlegroups.com, gsbr...@gmail.com
At first glance it looks like you haven't applied a migration to this
computer.

at the command line on this computer  - in the man project directory :

If you have not copied the migration scripts from your development
machine do this first :

$ python manage.py makemigrations

and then do this :

$ python manage.py migrate

--
--
Anthony Flury
email : *Anthon...@btinternet.com*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>

*On 02/05/18 00:56, Gerald Brown wrote:
> I have a Django application that I am having problems with.  In the
> Admin page I have 3 sections, ABC, DEF & XYZ. Each has 1 option to
> "Add/Change".  In 2 of them when I click on the option it works fine.
> The third gives me the following error "
> *1054, "Unknown column 'xyz_xyz.first_name' in "field list" *The
> Exception location is:
> */home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/*MySQLdb*/connections.py
> in query, line 277* On another system (both running the same code) I
> was also getting a different error also in *site-packages/MySQLdb* but
> I was able correct that by installing 2 DEV packages and then installing MySQLClient, which I also did on this computer. The other
> system does NOT give this error.
>
> Any ideas, suggestions, solutions on how to solve this error and any other errors in the Django code?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/74790172-8bf5-43b6-9bad-bab68ae11a4a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/74790172-8bf5-43b6-9bad-bab68ae11a4a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--
--
Anthony Flury
email : *Anthon...@btinternet.com*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*

Gerald Brown

unread,
May 2, 2018, 5:08:39 AM5/2/18
to Anthony Flury, django...@googlegroups.com

Thanks for the reply.

I have done the makemigrations/migrate numerous times.  Each time it says there is an error in the previous migration file so I have to comment out most of the file.  I then just deleted all of the self generated migration files and started fresh.

I was also getting some weird characters in my files like ">>>>random letters & numbers.  I deleted all of those & ran the migrations again.

The weird thing is that now when I click on the link it says "unknown column telephone in field list", previously it was first_name that was unknown.

I have this application running on a "similar" computer and it has NO problems with this area so maybe there are some other applications running that cause the problem even though this one is in a virtualenv.

Matthew Pava

unread,
May 2, 2018, 9:17:59 AM5/2/18
to django...@googlegroups.com

“>>>>random letters & numbers”

 

That looks like merge conflicts with Git.  You’ll want to fix those up, not just by deleting those lines, but by verifying the code does what you want it to.

You may want to just delete all of your migrations files and start anew if they’re not important to you.

--

You received this message because you are subscribed to the Google Groups "Django users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

Gerald Brown

unread,
May 3, 2018, 2:22:16 AM5/3/18
to django...@googlegroups.com

Been there. Done that. Many times!!!  Still can't find the field list that it is complaining about.

What is really weird is that the same code runs on 2 other computers without any errors.

Gerald Brown

unread,
May 3, 2018, 6:13:35 AM5/3/18
to django...@googlegroups.com

I finally discovered what I think is the cause of my problem.     DJANGO MIGRATIONS ARE NOT WORKING. On the system that has the problem is where I made migration to change some of the field names.  The fields that were not found where the ones that did get changed but the old unchanged names were still there.  On another system that is working NONE of the fields names were changed so it didn't have any unknown fields. Both systems had migrations run against the model file where some fields had changes made and the other one NO changes were made and on a third machine all changes were made.

Who knows what evil lurks in the heart of the computer? The Shadow knows!!!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Gerald Brown

unread,
May 3, 2018, 8:22:04 AM5/3/18
to Django users

FINALLY. SUCCESS!!! What I ended up doing to correct the problem was to drop the whole database (NO RECORDS YET). When I tried to run migrations it said there were no changes.  I then had to run makemigrations <table name> and migrate <table name> so I am now back in business!!!

Now does anyone know of an easy way to create PDF documents in Django???

Thanks to all for the suggestions and ideas!!!

On Thursday, May 3, 2018 at 6:13:35 PM UTC+8, Gerald Brown wrote:

I finally discovered what I think is the cause of my problem.     DJANGO MIGRATIONS ARE NOT WORKING. On the system that has the problem is where I made migration to change some of the field names.  The fields that were not found where the ones that did get changed but the old unchanged names were still there.  On another system that is working NONE of the fields names were changed so it didn't have any unknown fields. Both systems had migrations run against the model file where some fields had changes made and the other one NO changes were made and on a third machine all changes were made.

Who knows what evil lurks in the heart of the computer? The Shadow knows!!!


On Wednesday, 02 May, 2018 07:56 AM, Gerald Brown wrote:
I have a Django application that I am having problems with.  In the Admin page I have 3 sections, ABC, DEF & XYZ. Each has 1 option to "Add/Change".  In 2 of them when I click on the option it works fine. The third gives me the following error "
1054, "Unknown column 'xyz_xyz.first_name' in "field list"

The Exception location is: /home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/MySQLdb/connections.py in query, 
line 277

On another system (both running the same code) I was also getting a different error also in site-packages/MySQLdb but I was
able correct that by installing 2 DEV packages and then installing MySQLClient, which I also did on this computer.  The other
system does NOT give this error.

Any ideas, suggestions, solutions on how to solve this error and any other errors in the Django code?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

Matthew Pava

unread,
May 3, 2018, 9:31:47 AM5/3/18
to django...@googlegroups.com

I use PhantomJS with Django to create PDFs.  I just pass in the URL with the session variable (to maintain authentication) and a few other parameters into a customized Rasterize.js script.

Is it an “easy” way?  I wouldn’t say so, but it works for us.

 

It gets really crazy when you start asking, “Does anyone know of an easy way to print in Django?”  It’s not easy, but it can be done in an appropriate environment.

 

From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf Of Gerald Brown
Sent: Thursday, May 3, 2018 7:22 AM
To: Django users
Subject: Re: OperationalError

 


FINALLY. SUCCESS!!! What I ended up doing to correct the problem was to drop the whole database (NO RECORDS YET). When I tried to run migrations it said there were no changes.  I then had to run makemigrations <table name> and migrate <table name> so I am now back in business!!!

Now does anyone know of an easy way to create PDF documents in Django???

Thanks to all for the suggestions and ideas!!!

On Thursday, May 3, 2018 at 6:13:35 PM UTC+8, Gerald Brown wrote:

I finally discovered what I think is the cause of my problem.     DJANGO MIGRATIONS ARE NOT WORKING. On the system that has the problem is where I made migration to change some of the field names.  The fields that were not found where the ones that did get changed but the old unchanged names were still there.  On another system that is working NONE of the fields names were changed so it didn't have any unknown fields. Both systems had migrations run against the model file where some fields had changes made and the other one NO changes were made and on a third machine all changes were made.

Who knows what evil lurks in the heart of the computer? The Shadow knows!!!

 

On Wednesday, 02 May, 2018 07:56 AM, Gerald Brown wrote:

I have a Django application that I am having problems with.  In the Admin page I have 3 sections, ABC, DEF & XYZ. Each has 1 option to "Add/Change".  In 2 of them when I click on the option it works fine. The third gives me the following error "

1054, "Unknown column 'xyz_xyz.first_name' in "field list"
 
The Exception location is: /home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/MySQLdb/connections.py in query, 
line 277
 
On another system (both running the same code) I was also getting a different error also in site-packages/MySQLdb but I was
able correct that by installing 2 DEV packages and then installing MySQLClient, which I also did on this computer.  The other
system does NOT give this error.
 
Any ideas, suggestions, solutions on how to solve this error and any other errors in the Django code?
 
Thanks.
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

 

--

You received this message because you are subscribed to the Google Groups "Django users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.


To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Anthony Flury

unread,
May 3, 2018, 3:09:07 PM5/3/18
to django...@googlegroups.com
Django 2.0 docs suggest using reportlab :

https://docs.djangoproject.com/en/2.0/howto/outputting-pdf/

I had some success with : pupeteer -
http://django-puppeteer-pdf.readthedocs.io/en/latest/ - which works by
having a CBV type framework - so you subclass a PDF template view - and
that will autogenerate a PDF for you - you just need to have unique urls
for the PDFs.



On 03/05/18 13:22, Gerald Brown wrote:
>
> FINALLY. SUCCESS!!! What I ended up doing to correct the problem was
> to drop the whole database (NO RECORDS YET). When I tried to run
> migrations it said there were no changes.  I then had to run
> makemigrations <table name> and migrate <table name> so I am now back
> in business!!!
>
> Now does anyone know of an *easy* way to create PDF documents in Django???
>
> Thanks to all for the suggestions and ideas!!!
>
> On Thursday, May 3, 2018 at 6:13:35 PM UTC+8, Gerald Brown wrote:
>
> I finally discovered what I think is the cause of my problem.
> *DJANGO MIGRATIONS ARE NOT WORKING.*On the system that has the
> problem is where I made migration to change some of the field
> names.  The fields that were not found where the ones that did get
> changed but the old unchanged names were still there.  On another
> system that is working NONE of the fields names were changed so it
> didn't have any unknown fields. Both systems had migrations run
> against the model file where some fields had changes made and the
> other one NO changes were made and on a third machine all changes
> were made.
>
> /Who knows what evil lurks in the heart of the computer? *The
> Shadow knows!!!* /
>
>
> On Wednesday, 02 May, 2018 07:56 AM, Gerald Brown wrote:
>> I have a Django application that I am having problems with.  In
>> the Admin page I have 3 sections, ABC, DEF & XYZ. Each has 1
>> option to "Add/Change".  In 2 of them when I click on the option
>> it works fine. The third gives me the following error "
>> *1054, "Unknown column 'xyz_xyz.first_name' in "field list" *The
>> Exception location is:
>> */home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/*MySQLdb*/connections.py
>> in query, line 277* On another system (both running the same
>> code) I was also getting a different error also in
>> *site-packages/MySQLdb* but I was able correct that by installing
>> 2 DEV packages and then installing MySQLClient, which I also did on this computer. The other
>> system does NOT give this error.
>>
>> Any ideas, suggestions, solutions on how to solve this error and any other errors in the Django code?
>>
>> Thanks.
>>
>> --
>> You received this message because you are subscribed to the
>> Google Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To post to this group, send email to
>> django...@googlegroups.com <mailto:django...@googlegroups.com>.
>> <https://groups.google.com/group/django-users>.
>> <https://groups.google.com/d/msgid/django-users/74790172-8bf5-43b6-9bad-bab68ae11a4a%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e17d8d56-d57c-4f3d-ae6f-a004a5beda70%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e17d8d56-d57c-4f3d-ae6f-a004a5beda70%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


Gerald Brown

unread,
May 3, 2018, 7:56:07 PM5/3/18
to 'Anthony Flury' via Django users
Thanks for the reply.  Will check it out.  Just printed the documentation.
Reply all
Reply to author
Forward
0 new messages