I am facing circulation error while migrating my app.
when i run this:
(virEnv)abc#abc-All-Series:~/vissa_poc$ python manage.py migrate forms
**I get this:**
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 106, in handle
plan = executor.migration_plan(targets)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 54, in migration_plan
for migration in self.loader.graph.forwards_plan(target):
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/db/migrations/graph.py", line 60, in forwards_plan
return self.dfs(node, lambda x: self.dependencies.get(x, set()))
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/db/migrations/graph.py", line 124, in dfs
self.ensure_not_cyclic(start, get_children)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/db/migrations/graph.py", line 112, in ensure_not_cyclic
raise CircularDependencyError(", ".join("%s.%s" % n for n in cycle))
django.db.migrations.graph.CircularDependencyError: vissa.0001_initial, forms.0001_initial
I may suggest that you are trying to use ManyToMany field with 'through' option.
To fix it you need to do the next:
Comment a whole line where you use ManyToMany+through by putting # at the beginning of the line
makemigrations of_all_apps_you_need (also the one where the line from p1 exist)
uncomment the line from p1
makemigrations the_app_where_the_line_from_p1_exist
migrate
Related
I'm newbie in django&co world... these last few days it was working the dbshell but I don't really know what I touched because it is producing it to crash... I would be greatfull for any clue. Attaching the error.
I'm trying to make a rest API with django, mongodb connected by djongo.
(DjangoProject) C:\Users\Skootik\alchemyml_services>python manage.py dbshell
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Skootik\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\Skootik\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Skootik\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Skootik\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\management\base.py", line 353, in execute
output = self.handle(*args, **options)
File "C:\Users\Skootik\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\management\commands\dbshell.py", line 22, in handle
connection.client.runshell()
File "C:\Users\Skootik\Anaconda3\envs\DjangoProject\lib\site-packages\django\db\backends\base\client.py", line 12, in runshell
raise NotImplementedError('subclasses of BaseDatabaseClient must provide a runshell() method')
NotImplementedError: subclasses of BaseDatabaseClient must provide a runshell() method
I'm trying to build a search engine into a django blog application and when I ran the command:
>>> manage.py build_solr_schema
I got this error:
Traceback (most recent call last):
File "C:\Users\KOLAPO\Google Drive\Python\Websites\mysite\manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
utility.execute()
File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\haystack\management\commands\build_solr_schema.py", line 29, in handle
schema_xml = self.build_template(using=using)
File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\haystack\management\commands\build_solr_schema.py", line 57, in build_template
return t.render(c)
File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\template\backends\django.py", line 64, in render
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\template\context.py", line 287, in make_context
raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than Context.
What's wrong?
Note: I'm using Solr and Django-haystack for the search engine
I think this issue has been fixed by pull request 1504, but it looks like there hasn't been a release since then.
this error comes up when I try to makemigrations for my python project.
I don't where to look because i have 5 apps with 5 models and views !
does it have relation with attributes with the same name in different models ?
(i added related_name='+' to avoid conflict names).
My django version is : 1.11.3
this is what my terminal returned when i tried to makemigrations :
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 150, in handle
loader.project_state(),
File "/home/user/.local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 323, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
File "/home/user/.local/lib/python2.7/site-packages/django/db/migrations/graph.py", line 409, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "/home/user/.local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 92, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "/home/user/.local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 149, in state_forwards
delay = not old_field.is_relation
AttributeError: 'NoneType' object has no attribute 'is_relation'
In my case, this was caused by issues with the migrations. The easiest way to fix this, was to reset the migrations for the affected apps using django-reset-migrations: https://github.com/valdergallo/django-reset-migrations
I think something is wrong about your migrate files, check them if all exist and implemented. I think some your exist migration files are gone
When trying to make migrations in Django I get the following error. Can any help me understand what the problem is and how it possibly can be solved?
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/john/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/john/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/john/env/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/john/env/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/john/env/lib/python3.5/site-packages/django/core/management/commands/makemigrations.py", line 150, in handle
loader.project_state(),
File "/home/john/env/lib/python3.5/site-packages/django/db/migrations/loader.py", line 323, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
File "/home/john/env/lib/python3.5/site-packages/django/db/migrations/graph.py", line 409, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "/home/john/env/lib/python3.5/site-packages/django/db/migrations/migration.py", line 92, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "/home/john/env/lib/python3.5/site-packages/django/db/migrations/operations/fields.py", line 289, in state_forwards
delay = not field.is_relation
UnboundLocalError: local variable 'field' referenced before assignment
I'm using Django 1.11.1 and Python 3.5.
I was upgrading from Django 1.6 to 1.7. Python 2.7 is installed which is compatible with Django 1.7. While I did run the code python manage.py makemigrations, I got the following error message:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/m akemigrations.py", line 111, in handle
convert_apps=app_labels or None,
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/autodetector.py", line 42, in changes
changes = self._detect_changes(convert_apps, graph)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/autodetector.py", line 109, in _detect_changes
self.old_apps = self.from_state.render(ignore_swappable=True)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 67, in render
model.render(self.apps)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 312, in render
body,
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 284, in __new__
new_class._prepare()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 344, in _prepare
signals.class_prepared.send(sender=cls)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/dist-packages/model_utils/fields.py", line 57, in prepare_class
% sender.__name__
AssertionError: To use StatusField, the model 'ShellRequest' must have a STATUS choices class attribute.
Reading the blogpost here, I couldn't figure out where to start. If anyone can give me a guideline how to deal with this issue would be appreciated.
The choices class field attribute is probably what you're looking for.
If you are using django-model-utils, the choices section of the package doc might help too.