Re: [Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+--
 Reporter:  kaselis|Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.9rc1
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by shaib):

 https://docs.djangoproject.com/en/1.9/releases/1.9/#urls

 Because before 1.9, urls were not imported until the first request came in
 (and thus, not at all for migrations)

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.6a212946dfde73cd893686acd695e9a3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+--
 Reporter:  kaselis|Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.9rc1
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by kaselis):

 Thanks, it works fine with a change. I don't understand though why it was
 working in 1.8.7 version.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.402f3319100915e24b1c484a4791a058%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+--
 Reporter:  kaselis|Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.9rc1
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by knbk):

 {{{
 File "/home/rapolas/temp/mysite/myapp/forms.py", line 9, in ReportForm
 initial=[item for item in Item.objects.all()])
 }}}

 Like I said, this executes a query when the form is imported. You need to
 change it to `initial=Item.objects.all()`.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.e9797c29d3904f5b65e0372bb6eed865%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+--
 Reporter:  kaselis|Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.9rc1
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by kaselis):

 {{{
 #!div style="font-size: 80%"
 {{{
 (venv)➜  mysite $  python manage.py migrate
 Traceback (most recent call last):
   File "manage.py", line 10, in 
 execute_from_command_line(sys.argv)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 350, in
 execute_from_command_line
 utility.execute()
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 342, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/management/base.py", line 348, in run_from_argv
 self.execute(*args, **cmd_options)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/management/base.py", line 398, in execute
 self.check()
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/management/base.py", line 426, in check
 include_deployment_checks=include_deployment_checks,
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/checks/registry.py", line 75, in run_checks
 new_errors = check(app_configs=app_configs)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/checks/urls.py", line 10, in check_url_config
 return check_resolver(resolver)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/checks/urls.py", line 19, in check_resolver
 for pattern in resolver.url_patterns:
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/utils/functional.py", line 33, in __get__
 res = instance.__dict__[self.name] = self.func(instance)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/core/urlresolvers.py", line 417, in url_patterns
 patterns = getattr(self.urlconf_module, "urlpatterns",
 self.urlconf_module)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/utils/functional.py", line 33, in __get__
 res = instance.__dict__[self.name] = self.func(instance)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 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/rapolas/temp/mysite/mysite/urls.py", line 20, in 
 from myapp import views
   File "/home/rapolas/temp/mysite/myapp/views.py", line 4, in 
 from .forms import ReportForm
   File "/home/rapolas/temp/mysite/myapp/forms.py", line 5, in 
 class ReportForm(forms.Form):
   File "/home/rapolas/temp/mysite/myapp/forms.py", line 9, in ReportForm
 initial=[item for item in Item.objects.all()])
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/db/models/query.py", line 258, in __iter__
 self._fetch_all()
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/db/models/query.py", line 1074, in _fetch_all
 self._result_cache = list(self.iterator())
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/db/models/query.py", line 52, in __iter__
 results = compiler.execute_sql()
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/db/models/sql/compiler.py", line 852, in execute_sql
 cursor.execute(sql, params)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/db/backends/utils.py", line 79, in execute
 return super(CursorDebugWrapper, self).execute(sql, params)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/db/backends/utils.py", line 64, in execute
 return self.cursor.execute(sql, params)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/db/utils.py", line 95, in __exit__
 six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/home/rapolas/temp/mysite/venv/local/lib/python2.7/site-
 packages/django/db/backends/utils.py", line 64, in execute
 return 

Re: [Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+--
 Reporter:  kaselis|Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.9rc1
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by shaib):

 I took a look through your code, and could not find a reason for your
 forms to be imported in the migration.

 Could you save us the trouble of running it, and just paste your fill
 traceback?

 Thanks.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.9e5aa18134bbb257b233e33ecba04ed7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+--
 Reporter:  kaselis|Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.9rc1
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by kaselis):

 Have you tried the attached project? It doesn't have any DB inside, and
 migrations work fine with 1.8 django, but fails with 1.9rc2. So in order
 to reproduce - download the project, install django 1.8, run ./manage
 migrate. Works fine. Remove db.sqlite3, install django 1.9rc2, run
 ./manage migrate. Migrations fail.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.79949e4ce19612edbfcf2a2557cee62b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+--
 Reporter:  kaselis|Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.9rc1
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by knbk):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => invalid
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 You cannot query the database when a file is imported. When you use
 `initial=Item.objects.all()`, the query will be lazy, and it won't result
 in an error. If you need to evaluate the queryset before passing it to
 initial, you need to do so in the `__init__` method of your form.

 This probably works fine on 1.8 because you have an existing database in
 your 1.8 setup. It won't work if you deploy in a new 1.8 environment
 without an existing database.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.326de58c74a9f7be279ca277433947fb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+
 Reporter:  kaselis|  Owner:  nobody
 Type:  Uncategorized  | Status:  new
Component:  Uncategorized  |Version:  1.9rc1
 Severity:  Normal |   Keywords:
 Triage Stage:  Unreviewed |  Has patch:  0
Easy pickings:  0  |  UI/UX:  0
---+
 It requires some setup to reproduce it, but essentially: create a new
 project, create a new app, create a simple form, for example:

 {{{
 #!div style="font-size: 80%"
 {{{
 from .models import Item

 class ReportForm(forms.Form):
 items = forms.ModelMultipleChoiceField(
 queryset=Item.objects.all(),
 widget=forms.CheckboxSelectMultiple,
 initial=[item for item in Item.objects.all()])
 }}}
 }}}

 Import that form in the view and that view in urls and migration starts to
 fail, complaining about missing table (django.db.utils.OperationalError:
 no such table: myapp_item). It does work fine in django 1.8. Attaching
 sample project. Tested on django 1.9rc2 (dropdown doesn't have that
 version to select)

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.3de7a8d8eb4bd361780e8e47ef6fbb8a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25837: migration fails when there is initial option set on form field

2015-11-30 Thread Django
#25837: migration fails when there is initial option set on form field
---+
 Reporter:  kaselis|  Owner:  nobody
 Type:  Uncategorized  | Status:  new
Component:  Uncategorized  |Version:  1.9rc1
 Severity:  Normal | Resolution:
 Keywords: |   Triage Stage:  Unreviewed
Has patch:  0  |  Easy pickings:  0
UI/UX:  0  |
---+
Changes (by kaselis):

 * Attachment "mysite.tar.gz" added.

 Sample project

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.582159aacd6931d62f65d0532e74aff9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.