Hi,
--
-- I'm using django 1.8.4.
1. I have added a field "deleted" to a couple of models so that when the delete button is pressed, to all intents and purposes the record will have been deleted, although it should still be accessible through the Admin site.
2. To make this happen in a way that can't be easily accidentally ignored I have overiden "get_queryset in this manner
class AnnotationManager(models.Manager):
def get_queryset(self):
return super(AnnotationManager, self).get_queryset().filter(deleted=False)
and then had
objects = managers.AnnotationManager()
in the Model
3. I am also using AutoSlugField. To make sure that doesn't give an integrity error I have had to add another manager AllAnnotationManager and get the AutoSlugField to use it by adding the following keyword argument
manager=managers.AllAnnotationManager()
This works fine as far as integrity is concerned
4. However, if I run makemigrations, I get the following errors
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/core/management/commands/makemigrations.py", line 125, in handle
migration_name=self.migration_name,
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 43, in changes
changes = self._detect_changes(convert_apps, graph)
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 186, in _detect_changes
self.generate_altered_fields()
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 849, in generate_altered_fields
new_field_dec = self.deep_deconstruct(new_field)
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 67, in deep_deconstruct
for key, value in kwargs.items()
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 67, in <dictcomp>
for key, value in kwargs.items()
File "/Users/dantagg/envs/cr_3.4/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 61, in deep_deconstruct
path, args, kwargs = deconstructed
ValueError: too many values to unpack (expected 3)
The 5 deconstructed values that are causing the problem are
False
conciliation_resources_db.managers.AllAnnotationManager
None
()
{}
The object whose deconstruct method is causing the problem is
<class 'conciliation_resources_db.managers. AllAnnotationManager'>
Why is the manager's deconstruct method being called and how do I stop it?
Dan
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street, London, EC2A 3EP, Company no: 05766374
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPZHCY5%3Dc_kZiKY6wjcQkc17bzeTgwYQAxCSYckhvxpEkZqp-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment