Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2023-04-03 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  Akshat
 |  verma
 Type:  Bug  |   Status:  assigned
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Akshat verma):

 * owner:  (none) => Akshat verma
 * status:  new => assigned


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018746cd4388-3287a30d-7f09-4dea-bc6e-42842b015b4a-00%40eu-central-1.amazonses.com.


Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2023-04-03 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  Akshat
 |  verma
 Type:  Bug  |   Status:  assigned
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  1 => 0
 * needs_tests:  1 => 0
 * easy:  1 => 0
 * needs_docs:  1 => 0
 * has_patch:  1 => 0
 * ui_ux:  1 => 0


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070187469125db-b4be9647-8c72-438f-b4f8-860efec77bbb-00%40eu-central-1.amazonses.com.


Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2023-04-03 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  Akshat
 |  verma
 Type:  Bug  |   Status:  assigned
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  1|UI/UX:  1
-+-

Old description:

> When creating a custom field that inherits from ForeignKey and sets the
> to field there are issues with deconstruction.
>
> Simplified example (models.py)
>
> {{{
> from django.db import models
> from django.contrib.auth.models import User
>

> class UserField(models.ForeignKey):
>
> def __init__(self, *args, **kwargs):
> kwargs['to'] = User
> super(UserField, self).__init__(*args, **kwargs)
>
> def deconstruct(self):
> name, path, args, kwargs = super(UserField, self).deconstruct()
> del kwargs['to']
> return name, path, args, kwargs
>

> class FooBar(models.Model):
> user = UserField()
> }}}
>
> When {{{python manage.py makemigrations}}} is run the following exception
> is raised.
>
> {{{
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/core/management/__init__.py", line 385, in
> execute_from_command_line
> utility.execute()
>   File "/usr/local/lib/python2.7/dist-
> packages/django/core/management/__init__.py", line 377, 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 288, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/core/management/base.py", line 338, in execute
> output = self.handle(*args, **options)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/core/management/commands/makemigrations.py", line 111, in
> handle
> convert_apps=app_labels or None,
>   File "/usr/local/lib/python2.7/dist-
> packages/django/db/migrations/autodetector.py", line 40, in changes
> changes = self._detect_changes(convert_apps, graph)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/db/migrations/autodetector.py", line 139, in
> _detect_changes
> self.generate_renamed_models()
>   File "/usr/local/lib/python2.7/dist-
> packages/django/db/migrations/autodetector.py", line 413, in
> generate_renamed_models
> model_fields_def =
> self.only_relation_agnostic_fields(model_state.fields)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/db/migrations/autodetector.py", line 79, in
> only_relation_agnostic_fields
> del deconstruction[2]['to']
> KeyError: u'to'
> }}}
>
> It can be resolved by not removing the 'to' kwarg during deconstruction,
> however, this obviously leaves the unrequired 'to' kwarg in the
> constructor, as follows:
>
> {{{
> from django.db import models, migrations
> from django.conf import settings
> import bar.models
>

> class Migration(migrations.Migration):
>
> dependencies = [
> migrations.swappable_dependency(settings.AUTH_USER_MODEL),
> ]
>
> operations = [
> migrations.CreateModel(
> name='FooBar',
> fields=[
> ('id', models.AutoField(verbose_name='ID',
> serialize=False, auto_created=True, primary_key=True)),
> ('user',
> bar.models.UserField(to=settings.AUTH_USER_MODEL)),
> ],
> options={
> },
> bases=(models.Model,),
> ),
> ]
> }}}
>
> I've tried a few variations on this (such as supplying User as the first
> arg to the super call), however, the result is much the same or creates
> additional problems.
>
> The solution proposed at ticket:22263 may solve this problem.
>

>
> #When creating a custom field that inherits from ForeignKey and sets the
> to field there are issues with deconstruction.
>
> Simplified example (models.py)
> from django.db import models
> from django.contrib.auth.models import User
>

> class UserField(models.ForeignKey):
>
> def __init__(self, *args, **kwargs):
> kwargs['to'] = User
> super(UserField, self).__init__(*args, **kwargs)
>
> def deconstruct(self):
> name, path, args, kwargs = super(UserField, self).deconstruct()
> del kwargs['to']
> return name, path, args, kwargs
>

> class 

Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2023-04-03 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  Akshat
 |  verma
 Type:  Bug  |   Status:  assigned
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  1|UI/UX:  1
-+-
Changes (by Akshat verma):

 * cc: Akshat verma (added)
 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1
 * easy:  0 => 1
 * has_patch:  0 => 1
 * ui_ux:  0 => 1


Old description:

> When creating a custom field that inherits from ForeignKey and sets the
> to field there are issues with deconstruction.
>
> Simplified example (models.py)
>
> {{{
> from django.db import models
> from django.contrib.auth.models import User
>

> class UserField(models.ForeignKey):
>
> def __init__(self, *args, **kwargs):
> kwargs['to'] = User
> super(UserField, self).__init__(*args, **kwargs)
>
> def deconstruct(self):
> name, path, args, kwargs = super(UserField, self).deconstruct()
> del kwargs['to']
> return name, path, args, kwargs
>

> class FooBar(models.Model):
> user = UserField()
> }}}
>
> When {{{python manage.py makemigrations}}} is run the following exception
> is raised.
>
> {{{
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/core/management/__init__.py", line 385, in
> execute_from_command_line
> utility.execute()
>   File "/usr/local/lib/python2.7/dist-
> packages/django/core/management/__init__.py", line 377, 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 288, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/core/management/base.py", line 338, in execute
> output = self.handle(*args, **options)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/core/management/commands/makemigrations.py", line 111, in
> handle
> convert_apps=app_labels or None,
>   File "/usr/local/lib/python2.7/dist-
> packages/django/db/migrations/autodetector.py", line 40, in changes
> changes = self._detect_changes(convert_apps, graph)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/db/migrations/autodetector.py", line 139, in
> _detect_changes
> self.generate_renamed_models()
>   File "/usr/local/lib/python2.7/dist-
> packages/django/db/migrations/autodetector.py", line 413, in
> generate_renamed_models
> model_fields_def =
> self.only_relation_agnostic_fields(model_state.fields)
>   File "/usr/local/lib/python2.7/dist-
> packages/django/db/migrations/autodetector.py", line 79, in
> only_relation_agnostic_fields
> del deconstruction[2]['to']
> KeyError: u'to'
> }}}
>
> It can be resolved by not removing the 'to' kwarg during deconstruction,
> however, this obviously leaves the unrequired 'to' kwarg in the
> constructor, as follows:
>
> {{{
> from django.db import models, migrations
> from django.conf import settings
> import bar.models
>

> class Migration(migrations.Migration):
>
> dependencies = [
> migrations.swappable_dependency(settings.AUTH_USER_MODEL),
> ]
>
> operations = [
> migrations.CreateModel(
> name='FooBar',
> fields=[
> ('id', models.AutoField(verbose_name='ID',
> serialize=False, auto_created=True, primary_key=True)),
> ('user',
> bar.models.UserField(to=settings.AUTH_USER_MODEL)),
> ],
> options={
> },
> bases=(models.Model,),
> ),
> ]
> }}}
>
> I've tried a few variations on this (such as supplying User as the first
> arg to the super call), however, the result is much the same or creates
> additional problems.
>
> The solution proposed at ticket:22263 may solve this problem.

New description:

 When creating a custom field that inherits from ForeignKey and sets the to
 field there are issues with deconstruction.

 Simplified example (models.py)

 {{{
 from django.db import models
 from django.contrib.auth.models import User


 class UserField(models.ForeignKey):

 def __init__(self, *args, **kwargs):
 kwargs['to'] = User
 super(UserField, self).__init__(*args, **kwargs)

 def 

Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2023-04-03 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  Akshat
 |  verma
 Type:  Bug  |   Status:  assigned
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  0|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Akshat verma):

 * owner:  nobody => Akshat verma
 * status:  new => assigned


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701874683a015-ff87790a-be68-47da-bbf9-c3ab84d49447-00%40eu-central-1.amazonses.com.


Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2020-11-13 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  Nishant
 |  Sagar
 Type:  Bug  |   Status:  new
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  0|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * status:  closed => new
 * resolution:  fixed =>


Comment:

 Hi Nishant. Thanks for the input on the ticket. Can you say how/why it's
 fixed so we know that's OK to close? ("Latest docs say... and ..." — or
 such.) 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.722bc94a7b56bdee520f1d35ba967ae4%40djangoproject.com.


Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2020-11-13 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  Nishant
 |  Sagar
 Type:  Bug  |   Status:  closed
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  0|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nishant Sagar):

 * status:  assigned => closed
 * resolution:   => fixed


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.2cb446c67fe4a53733afbffed4df0437%40djangoproject.com.


Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2020-11-09 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  Nishant
 |  Sagar
 Type:  Bug  |   Status:  assigned
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  0|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nishant Sagar):

 * owner:  nobody => Nishant Sagar
 * status:  new => assigned


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.23da49fa650b0ba52b296b2641671a22%40djangoproject.com.


Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2015-03-06 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  0|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by MarkusH):

 * needs_docs:  0 => 1
 * component:  Migrations => Documentation


Comment:

 Reading through the related issues, especially https://github.com/alex
 /django-taggit/issues/206#issuecomment-37578676, I think this issue is
 more a problem with lack of documentation.

--
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/069.97a63c8ed056961154e9111334f2232f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24434: Django Custom Field inherits ForeignKey deconstruct() fails

2015-03-03 Thread Django
#24434: Django Custom Field inherits ForeignKey deconstruct() fails
-+-
 Reporter:  greenbender  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  deconstruct,migration  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * needs_better_patch:   => 0
 * component:  Uncategorized => Migrations
 * needs_tests:   => 0
 * needs_docs:   => 0
 * type:  Uncategorized => Bug
 * stage:  Unreviewed => Accepted


--
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/069.5752a60cef30a481b16f5ec53d2df348%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.