Я пытался сгенерировать поддельный номер телефона с помощью Django-seed
:
вот функция, которая создает мое семя
def create_users():
seeder = Seed.seeder()
seeder.add_entity(User, 4, {
'mobile_number': PhoneNumber.from_string("+41 79 123 45 67"),
'email': lambda x: seeder.fake.email(),
'is_superuser': False,
'is_staff': False,
'is_active': True,
})
seeder.execute()
Я тоже пробовал это: 'mobile_number': "+43 79 123 XX XX"
Что бы я ни пытался, я получил эту ошибку:
Traceback (most recent call last):
File ".../pycharm/django_manage.py", line 59, in <module>
run_command()
File ".../pycharm/django_manage.py", line 46, in run_command
run_module(manage_file, None, '__main__', True)
File ".../anaconda3/lib/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File ".../anaconda3/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File ".../anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File ".../manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File ".../venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File ".../venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File ".../venv/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File ".../venv/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File ".../event_manager/management/commands/seed.py", line 21, in handle
run_seed(self, options['mode'])
File ".../event_manager/management/commands/seed.py", line 36, in run_seed
create_users()
File ".../event_manager/management/commands/seed.py", line 57, in create_users
'is_active': True,
File ".../venv/lib/python3.6/site-packages/django_seed/seeder.py", line 132, in add_entity
File ".../python3.6/site-packages/django_seed/seeder.py", line 60, in guess_field_formatters
formatter = field_type_guesser.guess_format(field)
File ".../python3.6/site-packages/django_seed/guessers.py", line 107, in guess_format
raise AttributeError(field)
AttributeError: users.User.mobile_number
Вот модель пользователя:
from phonenumber_field.modelfields import PhoneNumberField
class User(AbstractBaseUser, PermissionsMixin):
...
mobile_number = PhoneNumberField(_("Mobile phone number"), blank=True, null=True, help_text=_("International format with country code (starting with \"+\"). Ex. +43 71 123 45 XX."))
Кто-нибудь может указать, что мне не хватает?