I was having a similar error yesterday, after adding another field to my
model I ran the migrations and was giving me an error as if I was
overwriting another field.
After a time searching for an answer for me ,the solution was (and I know
this is not a good practice) delete all the migration files and run the
migrations again.

Then again, If someone knows a better solution...

Em qua, 6 de nov de 2019 às 09:37, Ahmed Shahwan <
dev.ahmed.shah...@gmail.com> escreveu:

> Hello everybody,
>
> I work on a project started from the cookiecutter-django, and I altered
> the username of the User model to use `PhoneNumberField` from
> django-phonenumber-field package instead of the ordinary `models.CharField`
> and made the necessary changes, then I issued `manage.py makemigrations`
> which worked fine.
>
> But when I run `manage.py migrate` I get this error:
>
> Traceback (most recent call last):
>   File "./manage.py", line 30, in <module>
>     execute_from_command_line(sys.argv)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 381, in execute_from_command_line
>     utility.execute()
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 375, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/core/management/base.py",
> line 323, in run_from_argv
>     self.execute(*args, **cmd_options)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/core/management/base.py",
> line 364, in execute
>     output = self.handle(*args, **options)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/core/management/base.py",
> line 83, in wrapped
>     res = handle_func(*args, **kwargs)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/core/management/commands/migrate.py",
> line 257, in handle
>     self.verbosity, self.interactive, connection.alias,
> apps=post_migrate_apps, plan=plan,
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/core/management/sql.py",
> line 51, in emit_post_migrate_signal
>     **kwargs
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/dispatch/dispatcher.py",
> line 175, in send
>     for receiver in self._live_receivers(sender)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/dispatch/dispatcher.py",
> line 175, in <listcomp>
>     for receiver in self._live_receivers(sender)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/guardian/management/__init__.py",
> line 33, in create_anonymous_user
>     User.objects.get(**lookup)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/manager.py",
> line 82, in manager_method
>     return getattr(self.get_queryset(), name)(*args, **kwargs)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/query.py",
> line 399, in get
>     clone = self.filter(*args, **kwargs)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/query.py",
> line 892, in filter
>     return self._filter_or_exclude(False, *args, **kwargs)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/query.py",
> line 910, in _filter_or_exclude
>     clone.query.add_q(Q(*args, **kwargs))
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/sql/query.py",
> line 1290, in add_q
>     clause, _ = self._add_q(q_object, self.used_aliases)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/sql/query.py",
> line 1318, in _add_q
>     split_subq=split_subq, simple_col=simple_col,
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/sql/query.py",
> line 1251, in build_filter
>     condition = self.build_lookup(lookups, col, value)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/sql/query.py",
> line 1116, in build_lookup
>     lookup = lookup_class(lhs, rhs)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/lookups.py",
> line 20, in __init__
>     self.rhs = self.get_prep_lookup()
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/django/db/models/lookups.py",
> line 70, in get_prep_lookup
>     return self.lhs.output_field.get_prep_value(self.rhs)
>   File
> "/home/ahsh/.local/share/virtualenvs/communities_dj_backend/lib/python3.7/site-packages/phonenumber_field/modelfields.py",
> line 83, in get_prep_value
>     raise ValueError("“%s” is not a valid phone number." % value.raw_input)
> ValueError: “AnonymousUser” is not a valid phone number.
>
>
> I googled for a while and don't get what's going on. Any ideas?
>
> Thanks.
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1fb0dd24-9d04-4432-ae7b-64b11f160855%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1fb0dd24-9d04-4432-ae7b-64b11f160855%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
-- 
--
Laura Pérez Vera
(+53) 53440970 - lpver...@gmail.com

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF_dEnpXXkzocoNtn%2BNn0BhOX%3DAmJbVGFjodfVDR4Tdp7_aMQg%40mail.gmail.com.

Reply via email to