Saturday, April 28, 2018

Re: Broken?

Maybe, but while the log file has undergone some migrations in the past, it has not been much, not recently, and everything is up-to-date now.  'manage makemigrations' detects nothing.

So the question is how I can explore this.

++ kevin

On Saturday, April 28, 2018 at 7:17:24 AM UTC-7, Jason wrote:
Basically, its saying that something is expecting a string, but is instead getting a datetime object.  Sounds like something changed in your `oils/models.py` file

On Saturday, April 28, 2018 at 7:54:24 AM UTC-4, Kevin O'Gorman wrote:
I've got a working site, but I made a copy of the database in order to do some development work.
I've hit a snag that looks like a problem in the data.

The odd part is that this database is in production, and my backups have the same problem.  So I'm presuming my new code is broken in some way I don't understand.
For instance, Ive written a management command to show the problem:

from django.core.management.base import BaseCommand, CommandError

from oil.models import Packet, Signature, Log, Voter

class Command(BaseCommand):
    help = 'Quick test'
    BaseCommand.requires_migrations_checks = True


    def handle(self, *args, **options):
        voters = Log.objects.all()
        self.stdout.write(repr(voters[0]))

I'm suspecting a problem has crept into my Log table, because it works fine if I change Log on the
second line of handle() to any of the other tables.  If it runs as shown here however, I get

kevin@camelot-x:/build/comprosloco$ manage oiltest
Traceback (most recent call last):
  File "./manage", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/build/django/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/build/django/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/build/django/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/build/django/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/raid3/build/comprosloco/oil/management/commands/oiltest.py", line 15, in handle
    self.stdout.write(repr(voters[0]))
  File "/build/django/django/db/models/base.py", line 590, in __repr__
    u = six.text_type(self)
  File "/raid3/build/comprosloco/oil/models.py", line 172, in __str__
    self.accepted
TypeError: sequence item 0: expected str instance, datetime.datetime found
kevin@camelot-x:/build/comprosloco$

And I have no idea how to debug it further.  The schema of Log is
sqlite> .schema oil_log
CREATE TABLE "oil_log" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "packet" integer NOT NULL, "signature" integer NOT NULL, "action" varchar(20) NOT NULL, "criteria" varchar(150) NOT NULL, "candidates" varchar(100) NOT NULL, "accepted" varchar(10) NOT NULL, "user_id" integer NOT NULL REFERENCES "auth_user" ("id"), "timestamp" datetime NOT NULL);
CREATE INDEX "oil_log_packet_ecd59bc4" ON "oil_log" ("packet");
CREATE INDEX "oil_log_user_id_7f26e501" ON "oil_log" ("user_id");
sqlite>


Help???

--
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.
To post to this group, send email to django-users@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/92b25a7f-81ab-46c2-8729-0bdb996b9f75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment