Friday, July 29, 2016

Re: django 1.9, migrations certainly don't suck

On Fri, Jul 29, 2016 at 08:01:05AM -0700, Jorge Cadena wrote:
>
>
> Traceback (most recent call last):
> File "manage.py", line 10, in <module>
> execute_from_command_line(sys.argv)
> File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
> utility.execute()
> File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 345, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 348, in run_from_argv
> self.execute(*args, **cmd_options)
> File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 398, in execute
> self.check()
> File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 426, in check
> include_deployment_checks=include_deployment_checks,
> File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 75, in run_checks
> new_errors = check(app_configs=app_configs)
> File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 13, in check_url_config
> return check_resolver(resolver)
> File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 23, in check_resolver
> for pattern in resolver.url_patterns:
> File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 417, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 410, in urlconf_module
> return import_module(self.urlconf_name)
> File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
> __import__(name)
> File "/home/ariatel_web/dashboard.ariatel.com.co/dashaboar_ariatel/urls.py", line 20, in <module>
> from apps.did.views import CountryViewSet, AreasViewSet
> File "/home/ariatel_web/dashboard.ariatel.com.co/apps/did/views.py", line 15, in <module>
> from .forms import BuySearchForm
> File "/home/ariatel_web/dashboard.ariatel.com.co/apps/did/forms.py", line 11, in <module>
> class BuySearchForm(forms.Form):
> File "/home/ariatel_web/dashboard.ariatel.com.co/apps/did/forms.py", line 12, in BuySearchForm
> country = forms.ChoiceField(choices=[ (d.country_name, d.country_name) for d in DidCountry.objects.filter(is_active=True) ], required=False)

This line here is the problem – you should never evaluate querysets at
module level, in this case you should either use a function as the
choices argument to ChoiceField, or use a ModelChoiceField.

--
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/20160729151636.GY16002%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment