Rebuilding old (2010) django project in 2012 - python

I am trying to make an old Django project run again.
Update #1: I removed the arguments extra_thumbnails and size so the server is running. But now I don't have proper thumbnails of my pictures...
image = ImageWithThumbnailsField(
upload_to='images',
thumbnail={'size': (120, 120)},
extra_thumbnails={
'icon': {'size': (32, 32), 'options': ['crop', 'upscale']},
'large': {'size': (640, 640)},
}
now looks only:
image = ImageField(
upload_to='images')
--
After seemingly having solved issues with old sorl.thumbnail versions and deprecated expressions I now get this error when running
python manage.py runserver
I also tried to copy & paste my old files into a new Django project and get the exactly same error. Maybe someone here has a clue where the problem lies?
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x2a80510>>
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in inner_run
self.validate(display_num_errors=True)
File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/lib/python2.7/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/lib/python2.7/dist-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/usr/lib/python2.7/dist-packages/django/db/models/loading.py", line 61, in _populate
self.load_app(app_name, True)
File "/usr/lib/python2.7/dist-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/me/Documents/wdws/wdws/../wdws/cityofwindows/models.py", line 73, in <module>
class Image(models.Model):
File "/home/me/Documents/wdws/wdws/../wdws/cityofwindows/models.py", line 83, in Image
'large': {'size': (640, 640)},
File "/usr/lib/python2.7/dist-packages/django/db/models/fields/files.py", line 233, in __init__
super(FileField, self).__init__(verbose_name, name, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'extra_thumbnails'
I need to re-build the project just for visual documentation locally... so also any hints on how to quickly re-run outdated django-projects are very welcome!!
Thanks a lot!
(using Ubuntu 12.04)

A guess into the dark: Remove the keyword argument extra_thumbnails in the field definition FileField in the file cityofwindows/models.py
If this does not solve the problem, please post the cityofwindows/models.py file.

You probably uses another version of Django. Install Django 1.0 (https://www.djangoproject.com/download/1.0.4/tarball/) is the easiest why, but not the best. You'd better update your project with the standards of the version 1.3 (see 1.4)

Related

How to solve indexerror when running manim examples?

I just start learning manim and Im not so good at python.
when I was running manim examples given by the manim kindergarten, there was a error about index but I really don't know how to solve it.
As follows
manimgl example_scenes.py OpeningManimExample
Here is the information
Traceback (most recent call last):
File "D:\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "D:\Python310\Scripts\manimgl.exe\__main__.py", line 7, in <module>
File "C:\Users\10447\Desktop\manim\manimlib\__main__.py", line 25, in main
scene.run()
File "C:\Users\10447\Desktop\manim\manimlib\scene\scene.py", line 148, in run
self.construct()
File "C:\Users\10447\Desktop\manim\.\example_scenes.py", line 14, in construct
intro_words = Text("""
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\text_mobject.py", line 425, in __init__
super().__init__(
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\text_mobject.py", line 130, in __init__
super().__init__(text, height=height, **kwargs)
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\string_mobject.py", line 68, in __init__
super().__init__(
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\svg_mobject.py", line 76, in __init__
self.init_svg_mobject()
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\svg_mobject.py", line 104, in init_svg_mobject
submobs = self.mobjects_from_file(self.get_file_path())
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\string_mobject.py", line 115, in mobjects_from_file
submobs = super().mobjects_from_file(file_path)
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\svg_mobject.py", line 132, in mobjects_from_file
return self.mobjects_from_svg(svg)
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\svg_mobject.py", line 187, in mobjects_from_svg
mob = self.path_to_mobject(shape)
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\svg_mobject.py", line 240, in path_to_mobject
return VMobjectFromSVGPath(path, **self.path_string_config)
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\svg_mobject.py", line 306, in __init__
super().__init__(**kwargs)
File "C:\Users\10447\Desktop\manim\manimlib\mobject\types\vectorized_mobject.py", line 113, in __init__
super().__init__(**kwargs)
File "C:\Users\10447\Desktop\manim\manimlib\mobject\mobject.py", line 110, in __init__
self.init_points()
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\svg_mobject.py", line 314, in init_points
self.handle_commands()
File "C:\Users\10447\Desktop\manim\manimlib\mobject\svg\svg_mobject.py", line 352, in handle_commands
if self.has_new_path_started():
File "C:\Users\10447\Desktop\manim\manimlib\mobject\types\vectorized_mobject.py", line 502, in has_new_path_started
return self.consider_points_equal(points[-3], points[-2])
IndexError: index -3 is out of bounds for axis 0 with size 0
It seems that the problem is about vectorized_mobject.py.
I've search all google but it seems no one has the same problem like mine.
In the docs of manim kindergarten I found no solution.
Hopefully some here once had the same problem and please let me know how to solve it.
Really thanks if someone could help me.
If you want to use Manim. I'd suggest you install ManimCE version from Manim Community. As it is more stable.
If you want to use, Manimgl to reproduce the animations from 3b1b videos.
Make sure you have FFmpeg and latex properly installed (Using
Miktex? make sure you enable it to install tex packages on it's own
or install all the latex packages).
Create a python virtual environment. Enable the venv you have just created.
Install manim using pip with pip install manimgl. Don't install it from
the source, as there are still some bugs at the time of writing.
If you followed all the steps correctly then running manimgl example_scenes.py OpeningManimExample should work.

Django Help - Basic Setup and Basic Functionality

Done my due diligence and still having issues. Here is my goal. I'm using Django with Python to create a website with some custom coded features. The problem I'm having is this. I've tried these tutorials: http://matthewdaly.co.uk/blog/2013/12/28/django-blog-tutorial-the-next-generation-part-1/
http://ferretfarmer.net/2013/09/05/tutorial-real-time-chat-with-django-twisted-and-websockets-part-1/ (would prefer to use just django and no twisted but open to anything.
Next to last is: http://www.djangorocks.com/tutorials/how-to-create-a-basic-blog-in-django/starting-your-application.html for blogs
And finally: creating a company site with blog, news pasting, etc. Most of which I can get via models as i have done in the past.
I've made progress: But I'm stuck at this part. When I try to run python manage.py runserver i get a huge error like this:
ages\django\conf\__init__.py", line 113, in __i nit__
[shenk#LUCY2 mytest]$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "c:\Python27\lib\site- packages\django\core\management\__init__.py", line
338, in execute_from_command_line
utility.execute()
File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line
330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line
190, in fetch_command
klass = load_command_class(app_name, subcommand)
File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line
40, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "c:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "c:\Python27\lib\site- packages\django\core\management\commands\runserver.py",
line 14, in <module>
from django.db.migrations.executor import MigrationExecutor
File "c:\Python27\lib\site-packages\django\db\migrations\executor.py", line 6,
in <module>
from .loader import MigrationLoader
File "c:\Python27\lib\site-packages\django\db\migrations\loader.py", line 10,
in <module>
from django.db.migrations.recorder import MigrationRecorder
File "c:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 9,
in <module>
class MigrationRecorder(object):
File "c:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 23
, in MigrationRecorder
class Migration(models.Model):
File "c:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 24
, in Migration
app = models.CharField(max_length=255)
File "c:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line
1081, in __init__
super(CharField, self).__init__(*args, **kwargs)
File "c:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line
161, in __init__
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 48, in __ge
tattr__
self._setup(name)
File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 44, in _set
up
self._wrapped = Settings(settings_module)
File "c:\Python27\lib\site-pack
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be
empty.
Please excuse the formatting it is not cooperating 100%, working pretty good though.
Anyway I want to create a site with django and add on to it a bunch of hard coded basic modules which I can do. What I need help with as I believe I mentioned is why I cant do python manage.py runserver? Or the other question I had was the tutorials I found for blogs and such on Django were either out of date or did not work well. Please guide me towards the best way to create a company website with Django. For now I need basic skills similar to word press without and plugins (comments, blog, etc.) I can add more advanced functionality myself once this is working. The info on the Django Doc's only works like 20% of the time.
Any help would be appreciated, my preferred answer is a bit of an explanmation how to use it, as well as what could be causing my runserver issues.
Any response is much appreciated. I know this isn't the place, but send me a message on SO and perhaps we can work out payment in order to learn from you, get the base application done. After that I can write the other modules myself. (Yes, you'll be complicated and you can telecommute as I'm in PA outside Philly.
P.S. I'm an advanced C/C++ dev, a bit of C#, JS, Java, and mainly Python.
If you need any more info I can help. I'm great with python and even .NET MVC but django is a bit different so any guidance is appreciated.
Thanks in advance.
It says you've not configured the SECRET_KEY setting. You need to set the value of the SECRET_KEY variable in your_app_name/settings.py - if you used the command python manage.py startproject to create your Django project, it should have done this for you.
See here: https://docs.djangoproject.com/en/1.8/ref/settings/#secret-key
open settings.py
add
SECRET_KEY = "IWANTDJANGO4SUMREASON"
to the bottom
According to your error log, you've improperly configured your Django application. The SECRET_KEY setting must not be empty. Please check your settings.py which is loaded by manage.py and make sure the SECRET_KEY contains an appropriate value. That should get you somewhere further.
On the other hand, I would suggest reading the official documentation aswell as follow the official tutorial on how to get started. These are more often up-to-date and follow the official guidelines.

Pycharm 3.4.1 - "AppRegistryNotReady: Models aren't loaded yet". Django Rest framewrok

I'm using DRF and Pycharm 3.4.1 and Django 1.7. When I try to test my serializer class via Pycharm django console, it gives me the following error:
Code
from items_app.serializers import ItemSerializer
s = ItemSerializer()
print(repr(s))
then cause the following error traceback:
Traceback
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 440, in __repr__
return unicode_to_repr(representation.serializer_repr(self, indent=1))
File "/usr/local/lib/python2.7/dist-packages/rest_framework/utils/representation.py", line 75, in serializer_repr
fields = serializer.fields
File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 312, in fields
for key, value in self.get_fields().items():
File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 883, in get_fields
info = model_meta.get_field_info(model)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/utils/model_meta.py", line 68, in get_field_info
reverse_relations = _get_reverse_relationships(opts)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/utils/model_meta.py", line 129, in _get_reverse_relationships
for relation in opts.get_all_related_objects():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 498, in get_all_related_objects
include_proxy_eq=include_proxy_eq)]
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 510, in get_all_related_objects_with_model
self._fill_related_objects_cache()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 533, in _fill_related_objects_cache
for klass in self.apps.get_models(include_auto_created=True):
File "/usr/local/lib/python2.7/dist-packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 168, in get_models
self.check_models_ready()
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
AppRegistryNotReady: Models aren't loaded yet.
but when I'm using my terminal(instead of pycharm django console), It works properly! I know there is a problem with Pycharm but I don't know how to fix it!
Loading the app registry is part of the django.setup method. If the app registry is not loaded when you start using the console, the most likely reason is that it is a plain python console instead of a fully blown Django console.
Try the following code. If that solves it, you are indeed using a plain python console.
>>> import django
>>> django.setup()

Can't understand the error

Given below is the error which I am getting while running the code (which is in my previous post wx Import Error) in Python 2.6. Can anyone tell about this error? I am unable to understand it.
Traceback (most recent call last):
File "C:\Python26\music_player_v1\player_skeleton.py", line 153, in <module>
frame = MediaFrame()
File "C:\Python26\music_player_v1\player_skeleton.py", line 148, in __init__
panel = MediaPanel(self)
File "C:\Python26\music_player_v1\player_skeleton.py", line 25, in __init__
self.layoutControls()
File "C:\Python26\music_player_v1\player_skeleton.py", line 46, in layoutControls
audioTBSizer = self.buildAudioToolBar()
File "C:\Python26\music_player_v1\player_skeleton.py", line 65, in buildAudioToolBar
self.rewind = SBitmapButton(self, -1, upbmp, (48, 48))
File "C:\Python26\Lib\wx-2.8-msw-unicode\wx\lib\agw\shapedbutton.py", line 995, in __init__
self.SetBitmapLabel(bitmap)
File "C:\Python26\Lib\wx-2.8-msw-unicode\wx\lib\agw\shapedbutton.py", line 1068, in SetBitmapLabel
image = wx.ImageFromBitmap(bitmap)
File "C:\Python26\Lib\wx-2.8-msw-unicode\wx\_core.py", line 3473, in ImageFromBitmap
val = _core_.new_ImageFromBitmap(*args, **kwargs)
PyAssertionError: C++ assertion "bmp.Ok()" failed at ..\..\src\msw\dib.cpp(148) in wxDIB::Create(): wxDIB::Create(): invalid bitmap
Not sure if this is entirely related to your problem, but the SWIG-generated wrappers won't hold onto any Python objects passed to any set*() methods or the like in wx. You will need to hold onto such objects yourself or you will experience strange errors.
It looks like you have an invalid bitmap. In reading the tracebacks, it's usually the bottom traceback that's the most useful, and this one is saying that you have an "invalid bitmap".
Your application cant find an image file, put all images in one file and in your code give the exact path where to find the images.That wil solve that error.

django module already import and python egg warnings

Can anyone help me get rid of these warnings in Django please?
/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/_speedups.py:3: UserWarning: Module taggit was already imported from /var/www/html/matilah/taggit/__init__.py, but /usr/lib/python2.6/site-packages/django_taggit-0.9.3-py2.6.egg is being added to sys.path
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line 154, in <module>
handle_registrations()
File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line 151, in handle_registrations
search_sites_conf = importlib.import_module(settings.HAYSTACK_SITECONF)
File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/var/www/html/matilah/search_sites.py", line 2, in <module>
haystack.autodiscover()
File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line 106, in autodiscover
app_path = importlib.import_module(app).__path__
File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/var/www/html/matilah/disqus/__init__.py", line 5, in <module>
from django.utils import simplejson as json
File "/usr/lib/python2.6/site-packages/django/utils/simplejson/__init__.py", line 111, in <module>
import simplejson
File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/__init__.py", line 111, in <module>
File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/decoder.py", line 7, in <module>
File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/scanner.py", line 10, in <module>
File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/scanner.py", line 6, in _import_c_make_scanner
File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/_speedups.py", line 7, in <module>
File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/_speedups.py", line 4, in __bootstrap__
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 841, in resource_filename
self, resource_name
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1310, in get_resource_filename
self._extract_resource(manager, self._eager_to_zip(name))
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1332, in _extract_resource
self.egg_name, self._parts(zip_path)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 921, in get_cache_path
self.extraction_error()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 887, in extraction_error
raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg
cache:
[Errno 13] Permission denied: '/home/interworx/.python-eggs'
The Python egg cache directory is currently set to:
/home/interworx/.python-eggs
Perhaps your account does not have write access to this directory? You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.
I'm not sure if the "Module was already imported" error has to do with the "cannot extract PYTHON EGG" error.
In my WSGI I already have the following line os.environ['PYTHON_EGG_CACHE'] = rel('python-eggs') and I know for sure that works. Otherwise WSGI won't load my app. So I'm not sure what to do here.
Thanks!
When you get a message like "Perhaps your account does not have write access to this directory?" it's best to do a quick test. Try changing it to "/tmp" (which is writable by everyone) and see if things start working. If that fixes it, you can then identify a more appropriate directory and make sure that you (or the server) have write access to it.
Update: You are correct in choosing to tackle the earliest error message first. Here is a quick utility, Python Module Dump, that I wrote a few years ago for tracking down a mis-included module error. You might try inserting it at interesting points along your initialization code path and see if you can spot when the earlier import occurred.
There's a chance that your initial problem "Module was already imported" does in fact have to do with the permissions error you have going. Your best option would be to fix the permissions/ownership settings on the /home/interworx/.python-eggs directory (as stated by Peter Rowell above).
I came across this great little refresher on permissions today at the Google Code University. Wouldn't hurt to skim through this when you have some time: http://code.google.com/edu/tools101/linux/ownership_permissions.html
Just read the comments above here is my thoughts:
I think the problem is that the .wsgi file is not setting the environment variable in time. Can you please post your .wsgi file? Also, how are you grabbing the packages? Is it a script? Manually via pip?

Categories