Forums

Problem with migrations

I have been trying to host a chat app by migrating a different application. After adding the app name and south to the INSTALLED APP on settings.py, I ran syncdb, which worked properly. After that I ran the command convert_to_south. The following is the bash response for the command:-

Creating migrations directory at '/home/valer/.local/lib/python2.7/site-packages/django_ajax_chat-0.2-py2.7.egg/djangoChat/migrations'...
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 429, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, 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 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/convert_to_south.py", line 72, in handle
management.call_command("schemamigration", app, initial=True, verbosity=verbosity)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/schemamigration.py", line 87, in handle
migrations = Migrations(app, force_creation=True, verbose_creation=int(verbosity) > 0)
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 64, in __call__
self.instances[app_label] = super(MigrationsMetaclass, self).__call__(app_label_to_app_module(app_label), **kwds)
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 90, in __init__
self.set_application(application, force_creation, verbose_creation)
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 158, in set_application
self.create_migrations_directory(verbose_creation)
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 99, in create_migrations_directory
os.mkdir(migrations_dir)
OSError: [Errno 20] Not a directory: '/home/valer/.local/lib/python2.7/site-packages/django_ajax_chat-0.2-py2.7.egg/djangoChat/migrations'

I have installed the package django_ajax_chat-0.2 previously.

Expecting solutions. Thanks in advance....

[edited by admin for formatting]

A bit of googling suggests that it's a problem with django_ajax_chat using eggs. This person is having exactly the same problem:

https://groups.google.com/forum/#!msg/south-users/Y56DKtTnHT0/MJkJvtrXjGwJ

It sounds like the solution is to uninstall djangochat and reinstall it using the --always-unzip flag?

Thank you harry for that valuable suggestion. I have made the migrations, still I am having an unhandled exception. I am adding the error log below

2014-02-26 12:26:34,840 :Traceback (most recent call last):
2014-02-26 12:26:34,840 :  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 101, in get_response
2014-02-26 12:26:34,841 :    resolver_match = resolver.resolve(request.path_info)
2014-02-26 12:26:34,841 :  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 318, in resolve
2014-02-26 12:26:34,841 :    for pattern in self.url_patterns:
2014-02-26 12:26:34,841 :  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 346, in url_patterns
2014-02-26 12:26:34,842 :    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
2014-02-26 12:26:34,842 :  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 341, in urlconf_module
2014-02-26 12:26:34,843 :    self._urlconf_module = import_module(self.urlconf_name)
2014-02-26 12:26:34,843 :  File "/usr/lib/python3.3/importlib/__init__.py", line 90, in import_module
2014-02-26 12:26:34,843 :    return _bootstrap._gcd_import(name[level:], package, level)
2014-02-26 12:26:34,843 :  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
2014-02-26 12:26:34,844 :  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
2014-02-26 12:26:34,844 :  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
2014-02-26 12:26:34,845 :  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
2014-02-26 12:26:34,845 :  File "<frozen importlib._bootstrap>", line 1022, in load_module
2014-02-26 12:26:34,845 :  File "<frozen importlib._bootstrap>", line 1003, in load_module
2014-02-26 12:26:34,846 :  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
2014-02-26 12:26:34,846 :  File "<frozen importlib._bootstrap>", line 868, in _load_module
2014-02-26 12:26:34,847 :  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
2014-02-26 12:26:34,847 :  File "/home/vinya/dtchat/dtchat/urls.py", line 4, in <module>
2014-02-26 12:26:34,848 :    admin.autodiscover()
2014-02-26 12:26:34,848 :  File "/usr/local/lib/python3.3/dist-packages/django/contrib/admin/__init__.py", line 25, in autodiscover
2014-02-26 12:26:34,849 :    mod = import_module(app)
2014-02-26 12:26:34,849 :  File "/usr/lib/python3.3/importlib/__init__.py", line 90, in import_module
2014-02-26 12:26:34,849 :    return _bootstrap._gcd_import(name[level:], package, level)
2014-02-26 12:26:34,849 :  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
2014-02-26 12:26:34,850 :  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
2014-02-26 12:26:34,850 :  File "<frozen importlib._bootstrap>", line 1529, in _find_and_load_unlocked
2014-02-26 12:26:34,851 :ImportError: No module named 'djangoChat'
2014-02-26 12:26:34,851 :
2014-02-26 12:26:34,851 :During handling of the above exception, another exception occurred:
2014-02-26 12:26:34,851 :
2014-02-26 12:26:34,851 :Traceback (most recent call last):
2014-02-26 12:26:34,851 :  File "/bin/user_wsgi_wrapper.py", line 67, in __call__
2014-02-26 12:26:34,852 :    self.error_log_file.logger.exception("Error running WSGI application")
2014-02-26 12:26:34,852 :  File "/usr/lib/python3.3/logging/__init__.py", line 1269, in exception
2014-02-26 12:26:34,853 :    self.error(msg, *args, **kwargs)
2014-02-26 12:26:34,853 :  File "/usr/lib/python3.3/logging/__init__.py", line 1262, in error
2014-02-26 12:26:34,854 :    self._log(ERROR, msg, args, **kwargs)
2014-02-26 12:26:34,855 :  File "/usr/lib/python3.3/logging/__init__.py", line 1368, in _log
2014-02-26 12:26:34,856 :    self.handle(record)
2014-02-26 12:26:34,856 :  File "/usr/lib/python3.3/logging/__init__.py", line 1377, in handle
2014-02-26 12:26:34,857 :    if (not self.disabled) and self.filter(record):
2014-02-26 12:26:34,857 :  File "/usr/lib/python3.3/logging/__init__.py", line 687, in filter
2014-02-26 12:26:34,858 :    for f in self.filters:
2014-02-26 12:26:34,858 :  File "/bin/user_wsgi_wrapper.py", line 59, in __call__
2014-02-26 12:26:34,858 :    app_iterator = self.app(environ, start_response)
2014-02-26 12:26:34,859 :  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/wsgi.py", line 206, in __call__
2014-02-26 12:26:34,859 :    response = self.get_response(request)
2014-02-26 12:26:34,859 :  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 196, in get_response
2014-02-26 12:26:34,860 :    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2014-02-26 12:26:34,860 :  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 231, in handle_uncaught_exception
2014-02-26 12:26:34,860 :    return debug.technical_500_response(request, *exc_info)
2014-02-26 12:26:34,861 :  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 69, in technical_500_response
2014-02-26 12:26:34,861 :    html = reporter.get_traceback_html()
2014-02-26 12:26:34,861 :  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 323, in get_traceback_html
2014-02-26 12:26:34,862 :    c = Context(self.get_traceback_data())
2014-02-26 12:26:34,862 :  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 281, in get_traceback_data
2014-02-26 12:26:34,862 :    frames = self.get_traceback_frames()
2014-02-26 12:26:34,863 :  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 428, in get_traceback_frames
2014-02-26 12:26:34,863 :    pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name)
2014-02-26 12:26:34,863 :  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 379, in _get_lines_from_file
2014-02-26 12:26:34,864 :    source = loader.get_source(module_name)
2014-02-26 12:26:34,864 :  File "<frozen importlib._bootstrap>", line 605, in _requires_frozen_wrapper
2014-02-26 12:26:34,865 :ImportError: importlib._bootstrap is not a frozen module

What are the possible reasons for this exception??? Good wishes to all.....

[edited by admin: formatting]

The important bit is this, I think:

ImportError: No module named 'djangoChat'

How did you install the package django_ajax_chat-0.2?

First, I extracted the package. It had files including the folder djangoChat. In that folder, a setup file was present. I ran the command "python setup.py install --user"....

Expecting a solution for the problem. Thank you...

OK. What do you get if you run manage.py shell and try to import djangoChat?

Okey, I am having a little bit confusion here. I used "import djangoChat" and "from djangoChat import * ". Both of them returned nothing. Is this the normal behaviour of python shell when we import something? BTW, the errors are still there...

When imports don't say anything, it means they worked. I see in your tracebacks that one refers to python27 and the other refers to python33 so my guess is that you're running some stuff in python 2 and some stuff in python 3. Make sure you're consistent otherwise you'll be installing modules under one and then trying to use them under the other where they're not installed.

Thank you glenn for that remark. Now, just to make sure, when I ran the command "python manage.py sql djangoChat" I got the response as follows:-

BEGIN; CREATE TABLE "djangoChat_message" ( "id" integer NOT NULL PRIMARY KEY, "user" varchar(200) NOT NULL, "message" text NOT NULL, "time" datetime NOT NULL, "gravatar" varchar(300) NOT NULL ) ; CREATE TABLE "djangoChat_chatuser" ( "id" integer NOT NULL PRIMARY KEY, "user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id"), "userID" integer NOT NULL, "username" varchar(300) NOT NULL, "is_chat_user" bool NOT NULL, "gravatar_url" varchar(300) NOT NULL, "last_accessed" datetime NOT NULL ) ;

Then I opened the shell and ran 1) "from djangoChat import *" 2}"djangoChat_message.objects.all()

The response was:-

djangoChat_message.objects.all()

NameError Traceback (most recent call last) /usr/local/lib/python2.7/dist-packages/django/core/management/commands/shell.py in <module>() ----> 1 djangoChat_message.objects.all()

NameError: name 'djangoChat_message' is not defined

Is this also caused by the version problem that you mentioned before??? Please let me know. Regards to you...

It looks like djangoChat does not define djangoChat_message. That's what

NameError: name 'djangoChat_message' is not defined

means. What made you think there would be something called djangoChat_message?

Sorry about that. The command which I intended to use was Message.objects.all(). The result was:- out[2]: [], which is normal. I couldn't create a default dataset because I couldn't import the 'timezone' class using "from django.utils import timezone"

Since all the data sets are present, still I cannot import the class djangoChat, what will be the possible reasons..?

Hi valer, is there some kind of documentation or tutorial that you're trying to follow, for djangoChat? It's hard to tell what it is you're trying to achieve...

I downloaded the package from the following link:- https://pypi.python.org/pypi/django-ajax-chat

I followed the ReadMe on the package, and used south for migrations. It worked fine on my PC....

So what, exactly, is currently not working?

Let me summarize the steps I have taken to build the app.

1) Uploaded the django-ajax-chat zip file and extracted it.

2) Used the command "python setup.py install --user" to install the app.

3) Created a new django project and app.

4) Added the app name and djangoChat to the settings.py file.

5) Ran the syncdb command and created a sueruser account.

6) updated the urls.py file by adding url(r'^chat/',include("djangoChat.urls"))

7) When I ran the app, the url for the admin works fine, but when I given chat as url, it shown an error message, citing the url is not is not on the file urls.py.

8) So, I used migrations. After that, I refreshed the web app to recieve an Unhandled Exception. When I checked the error log, I got the import error, djangoChat is not an imported module.

Where exactly I might be wrong. Also, I am new to django.

It sounds like there was a problem at step 6 or 7, when you tried to add the urls? Can I see more information on that error?

Also, at step 8, can we see the error logs?

Finally, how did you configure your web app on PythonAnywhere? Did you use "manual configuration"?

No, I haven't used manual configuration. I ran the setup for django-ajax-chat locally and created a new django project(Python 3.3). Then I updated the settings.py, urls.py files just as I done on my PC. When I ran the program on browser, without using south, I got the usualdjango window, citing 'It worked'. After that, I given the url for admin '/admin', which also worked fine. I got the administrator page and I logged in and out. after that, I added '/chat' to the url, which resulted in:-

Page not found (404) Request Method: GET

Using the URLconf defined in chattest.urls, Django tried these URL patterns, in this order:

^admin/

The current URL, , didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

Which was I specified in the respective file.

Then I thought that it has something to do with migrations. So, I added south and ran syncdb, which resulted in the error that I gave you on my second post.

That looks like for some reason your code isn't picking up whatever urls.py file you had the /chat URL defined in.

One question -- and sorry if it's a silly one -- did you reload the app after you updated settings.py, urls.py, and so on?

Well giles, you were right about urls.py. Just the version inconsistencies. I just had to chane the imports a bit, adding defaults and so. It works fine now. Thank you all for helping me out...

Excellent, glad to hear it finally worked :-)