I noticed a list comprehension bombs in the "./manage.py shell" shell that I think would
import bighelp.models
ACCT = bighelp.models.Account
ASERV = bighelp.models.AccountService
APPT = bighelp.models.Appointment
for e in ACCT.objects.all()[:1]:
appts = APPT.objects.filter(account = e)[:3]
aservs = ASERV.objects.filter(account = e)
print(f"allowed is a list of strings => {allowed}\n\n")
print(f"appts is a collection of Django objects => {appts}\n\n")
print("This way of defining servs works...\n\n")
servs = []
for a in appts:
if a.service in allowed:
servs.append(a.service)
print(f"servs = {servs}\n\n")
print("This way gives a mysterious error...\n\n")
servs = [a.service for a in appts if (a.service in allowed)]
../manage.py shell < ./erase
allowed is a list of strings => ['pet', 'cleaning']
appts is a collection of Django objects => <QuerySet [<Appointment: Appointment object (998)>, <Appointment: Appointment object (1463561)>, <Appointment: Appointment object (863)>]>
This way of defining servs works...
servs = ['cleaning', 'pet', 'cleaning']
This way gives a mysterious error...
Traceback (most recent call last):
File "../manage.py", line 8, in <module>
django.core.management.execute_from_command_line(sys.argv)
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", line 92, in handle
exec(sys.stdin.read())
File "<string>", line 26, in <module>
File "<string>", line 26, in <listcomp>
NameError: name 'allowed' is not defined