DJANGO-ValueError: invalid literal for int() with base 10: 'admin'?

Learning Django by the tutorial. But faced with an error which I am suffering for over 4 hours continuously and the rules of Google. But to no avail.

I have a DJango 1.9

In app blog models is written as follows:

class Article(models.Model):
 title = models.CharField(max_length=200)
 text = models.TextField()
 user = models.ForeignKey(User)


The attempt to migrate the database (migrate) the following error code:

ValueError: invalid literal for int() with base 10: 'admin'

In the video it all works, but I have not. Already reviewed a few times anyway.
July 9th 19 at 13:46
2 answers
July 9th 19 at 13:48
You somewhere 'admin' in the number are trying to promote.
Would better your code.
Now, in your application's model:

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

# Create your models here.
class Article(models.Model):
title = models.CharField(max_length=200)
text = models.TextField()
user = models.ForeignKey(User)

def _str_(self):
return self.title - Damaris.Fisher commented on July 9th 19 at 13:51
: more models nothing. - Damaris.Fisher commented on July 9th 19 at 13:54
In the Project the following URLS:

mapping includes = [
url(r'^admin/', admin.site.urls),
#url(r'^blog/', blog.urls),
] - Damaris.Fisher commented on July 9th 19 at 13:57
: and error better give - Nathan_Gaylord commented on July 9th 19 at 14:00
: WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.
Operations to perform:
Apply all migrations: sessions, blog, admin, auth, contenttypes
Running migrations:
Rendering model states... DONE
Applying blog.0002_article_user...Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\django_manage.py", line 41, in
run_module(manage_file, None, '__main__', True)
File "C:\Python35\lib\runpy.py", line 182, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "C:\Python35\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:/djangoprojects/MyBlog\manage.py", line 10, in
execute_from_command_line(sys.argv)
File "C:\Python35\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "C:\Python35\lib\site-packages\django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python35\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python35\lib\site-packages\django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "C:\Python35\lib\site-packages\django\core\management\commands\migrate.py", line 200, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "C:\Python35\lib\site-packages\django\db\migrations\executor.py", line 92, in migrate
self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)
File "C:\Python35\lib\site-packages\django\db\migrations\executor.py", line 121, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "C:\Python35\lib\site-packages\django\db\migrations\executor.py", line 198, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Python35\lib\site-packages\django\db\migrations\migration.py", line 123, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Python35\lib\site-packages\django\db\migrations\operations\fields.py", line 62, in database_forwards
field
File "C:\Python35\lib\site-packages\django\db\backends\sqlite3\schema.py", line 229, in add_field
self._remake_table(model, create_fields=[field])
File "C:\Python35\lib\site-packages\django\db\backends\sqlite3\schema.py", line 111, in _remake_table
self.effective_default(field)
File "C:\Python35\lib\site-packages\django\db\backends\base\schema.py", line 210, in effective_default
default = field.get_db_prep_save(default, self.connection)
File "C:\Python35\lib\site-packages\django\db\models\fields\related.py", line 915, in get_db_prep_save
return self.target_field.get_db_prep_save(value, connection=connection)
File "C:\Python35\lib\site-packages\django\db\models\fields\__init__.py", line 728, in get_db_prep_save
prepared=False)
File "C:\Python35\lib\site-packages\django\db\models\fields\__init__.py", line 968, in get_db_prep_value
value = self.get_prep_value(value)
File "C:\Python35\lib\site-packages\django\db\models\fields\__init__.py", line 976, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: 'admin' - Damaris.Fisher commented on July 9th 19 at 14:03
: Fastest you the file migration does not fit with your database. Try to delete the database and migration files, and execute commands makemigrations, migrate again - Nathan_Gaylord commented on July 9th 19 at 14:06
: flush command will help? or is it only cleans? Work using pycharm with sqlite - Damaris.Fisher commented on July 9th 19 at 14:09
better to delete the file physically. - Nathan_Gaylord commented on July 9th 19 at 14:12
July 9th 19 at 13:50
You probably have already created entries in the model. Check is there any entry in database. If there is then delete it. This is only a guess, need more code.

Find more questions by tags DjangoPython