django


In django I have created field and added some entries to the field afte


In Django I have created a field named pincode and added some entries like 876786876, 8768768776.
After some time I added a unique argument but it showed some error so I removed the field from the model but still shows some error when running
python manage.py migrate
The error:
Operations to perform:
Synchronize unmigrated apps: haystack
Apply all migrations: admin, contenttypes, polls, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying polls.0007_auto_20141104_2055...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/commands/migrate.py", line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/migrations/executor.py", line 63, in migrate
self.apply_migration(migration, fake=fake)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/migrations/executor.py", line 97, in apply_migration
migration.apply(project_state, schema_editor)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/migrations/migration.py", line 107, in apply
operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/migrations/operations/fields.py", line 139, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/backends/schema.py", line 473, in alter_field
self._alter_field(model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/backends/sqlite3/schema.py", line 190, in _alter_field
self._remake_table(model, alter_fields=[(old_field, new_field)])
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/backends/sqlite3/schema.py", line 135, in _remake_table
self.quote_name(model._meta.db_table),
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/backends/schema.py", line 99, in execute
cursor.execute(sql, params)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/backends/sqlite3/base.py", line 485, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: column pincode is not unique
It would appear you have duplicate fields in that column. The UNIQUE constraint can't be added until the data in the table already conforms to the constraint.
If you don't care about your data, just TRUNCATE or DROP the table. If you do care about the data, you'll need to identify the duplicated rows and ensure that the field in question is unique.
I you don't mind, delete the file of your database (in case you're using SQLite) and syncdb again, sometimes migrating don't "delete" the table columns, if you dont want to loose your info try to dump it before into a json and load it after syncdb with loaddata

Related Links

How to list models (via single view), inherited from the one base model, that they are displayed in accordance with the implementation
“CSRF Failed: CSRF token missing or incorrect.” in Django Rest: UpdateModelMixin
Using django-registration package (hmac method), how to assign a user to a specific user model?
Execute task once when starting uwsgi-emperor app
Using a registration form to add to custom user fields (django)
Chaining filters
Django: Form submission clears the data of inlineform in template rendering if error in form validation
Packet loss on Docker-Celery configuration running on Azure
How can I update two models in one serializer in Django Rest Framework?
Django - How to Modularize a large web Application?
Showing a related fields attribute
Django: how to set the path for the environ variable “DJANGO_SETTINGS_MODULE”
How to squash recent Django migrations?
How not to call clean method in django model when editing?
Django OneToMany adding to set throws index out of range
django celery unit tests with pycharm 'No module named celery'

Categories

HOME
checkstyle
spark-streaming
ns-3
mstest
socket.io
alarm
ms-access-2016
bitbucket-api
visual-studio-emulator
ado.net
regular-language
jquery-ui
azure-container-service
webix
flume
recordrtc
qpython
jquery-ui-sortable
google-schemas
little-proxy
openstreetmap
commonjs
windows-ce
gource
eip
symbol
altera
scsi
aws-sdk
dreamweaver
vuejs
forgot-password
jersey-1.0
foreign-keys
undertow
r-mice
roslyn
pchart
perlbrew
ckfinder
tiki-wiki
jquery-multiselect
angularjs-components
underscore.js
realm-mobile-platform
google-earth
catch-unit-test
servicestack-text
video-capture
openproject
p4merge
apache-stanbol
outputcache
vaadin-elements
double-click
lampp
tinymce-3
pair-programming
truezip
bbpress
ampps
centrifuge
mongodb-php
lua-telegram-bot
gcloud-ruby
createprocess
dynatree
zen-cart
cgi-bin
vacuum
snackbar
mraid
uvc
android-broadcast
public-html
openbabel
adehabitathr
grouping-sets
android-cookiemanager
webfinger
rickshaw
machine-instruction
linkedin-jsapi
imagefilter
rmysql
alternate
cfcache
windows-embedded-standard
jammer
oocss
cocoalibspotify-2.0
hidapi
script#
actiondispatch
virtual-pc
twisted.web
asplinkbutton
sqlclr
curb
fragmenttransaction
objectquery
thttpd
wiimote
gobject-introspection
fsevents
lr
mbeans
quotation-marks
nhprof
commerceserver2007
request-headers
dsl-tools
firefox-3
java1.4

Resources

Encrypt Message