1

I'm moving Django project to new server.

I'm newbie in Django, and I don't know where should be upload folder. There are all images which should be displayed on website. In config file I haven't seen upload folder I could specify, so I'm guessing it always should be the same location for django projects or I just can't find it.

Locations are saved in database. When I've put uploaded files into media folder, so url was like domain.co.uk/media/upload/media/images/year/month/day/image_name.ext and the same is on the old website, images on website ware still missing.

All images are visible if I put url by hand, but django doesn't seems to see files.

Also I check django log file:

2012-05-30 09:13:33,393 ERROR render:  Thumbnail tag failed: [in /usr/lib/python2.6/site-packages/sorl_thumbnail-11.12-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py (line 49)]
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/sorl_thumbnail-11.12-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py", line 45, in render
    return self._render(context)
  File "/usr/lib/python2.6/site-packages/sorl_thumbnail-11.12-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py", line 97, in _render
    file_, geometry, **options
  File "/usr/lib/python2.6/site-packages/sorl_thumbnail-11.12-py2.6.egg/sorl/thumbnail/base.py", line 50, in get_thumbnail
    cached = default.kvstore.get(thumbnail)
  File "/usr/lib/python2.6/site-packages/sorl_thumbnail-11.12-py2.6.egg/sorl/thumbnail/kvstores/base.py", line 25, in get
    return self._get(image_file.key)
  File "/usr/lib/python2.6/site-packages/sorl_thumbnail-11.12-py2.6.egg/sorl/thumbnail/kvstores/base.py", line 123, in _get
    value = self._get_raw(add_prefix(key, identity))
  File "/usr/lib/python2.6/site-packages/sorl_thumbnail-11.12-py2.6.egg/sorl/thumbnail/kvstores/cached_db_kvstore.py", line 26, in _get_raw
    value = KVStoreModel.objects.get(key=key).value
  File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 132, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 344, in get
    num = len(clone)
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 82, in __len__
    self._result_cache = list(self.iterator())
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 273, in iterator
    for row in compiler.results_iter():
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 86, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
DatabaseError: (1146, "Table 'thumbnail_kvstore' doesn't exist")
2012-05-30 09:13:33,396 DEBUG execute:  (0.000) SELECT `freetext_freetext`.`id`, `freetext_freetext`.`key`, `freetext_freetext`.`content`, `freetext_freetext`.`active` FROM `freetext_freetext` WHERE (`freetext_freetext`.`active` = True  AND `freetext_freetext`.`key` = office-closed-message ); args=(True, u'office-closed-message') [in /usr/lib/python2.6/site-packages/django/db/backends/util.py (line 44)]
2012-05-30 09:13:33,399 DEBUG execute:  (0.000) SELECT `menus_menu`.`id`, `menus_menu`.`name`, `menus_menu`.`slug`, `menus_menu`.`base_url`, `menus_menu`.`description`, `menus_menu`.`enabled` FROM `menus_menu` WHERE (`menus_menu`.`enabled` = True  AND `menus_menu`.`slug` = about ); args=(True, u'about') [in /usr/lib/python2.6/site-packages/django/db/backends/util.py (line 44)]
2012-05-30 09:13:33,401 DEBUG execute:  (0.000) SELECT `menus_menuitem`.`id`, `menus_menuitem`.`menu_id`, `menus_menuitem`.`title`, `menus_menuitem`.`url`, `menus_menuitem`.`order` FROM `menus_menuitem` INNER JOIN `menus_menu` ON (`menus_menuitem`.`menu_id` = `menus_menu`.`id`) WHERE `menus_menu`.`slug` = about  ORDER BY `menus_menuitem`.`order` ASC; args=(u'about',) [in /usr/lib/python2.6/site-packages/django/db/backends/util.py (line 44)]
2012-05-30 09:13:33,404 DEBUG execute:  (0.000) SELECT `freetext_freetext`.`id`, `freetext_freetext`.`key`, `freetext_freetext`.`content`, `freetext_freetext`.`active` FROM `freetext_freetext` WHERE (`freetext_freetext`.`active` = True  AND `freetext_freetext`.`key` = contactdetails-footer ); args=(True, u'contactdetails-footer') [in /usr/lib/python2.6/site-packages/django/db/backends/util.py (line 44)]

I checked database and there is no table calls thumbnail_kvstore, but I have database backup, and in backup files this table doesn't exist.

All uploaded files I get are in media/uploads/media/.

Also I'm getting errors on some pages:

Syntax error. Expected: ``thumbnail source geometry [key1=val1 key2=val2...] as var``
/usr/lib/python2.6/site-packages/sorl_thumbnail-11.12-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py in __init__, line 72
In template /var/www/vhosts/domain.co.uk/sites/apps/shop/products/templates/products/product_detail.html, error at line 34
{% thumbnail image.file "800x700" detail as zoom %}

Maybe some modules I install are not in the right version. Dont know how to fix it.

Im using, CentOS 6, mod_wsgi, apache, python 2.6.

Update 1.0:

On the old server was Django 1.3, on the new one is Django 1.3.1

Update 1.1:

I think i know where is the problem. I tried python manage.py syncdb and this is output:

Syncing...
Creating tables ...
The following content types are stale and need to be deleted:

    orders | ordercontact

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

    Type 'yes' to continue, or 'no' to cancel: no
Installing custom SQL ...
Installing indexes ...
No fixtures found.

Synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > django.contrib.messages
 > django.contrib.admin
 > django.contrib.admindocs
 > django.contrib.markup
 > django.contrib.sitemaps
 > django.contrib.redirects
 > django_filters
 > freetext
 > sorl.thumbnail
 > django_extensions
 > south
 > currencies
 > pagination
 > tagging
 > honeypot
 > core
 > faq
 > logentry
 > menus
 > news
 > shop
 > shop.cart
 > shop.orders

Not synced (use migrations):
 - dbtemplates
 - contactform
 - links
 - media
 - pages
 - popularity
 - testimonials
 - shop.brands
 - shop.collections
 - shop.discount
 - shop.pricing
 - shop.product_types
 - shop.products
 - shop.shipping
 - shop.tax
(use ./manage.py migrate to migrate these)

Next I run python manage.py migrate, and thats what i get:

Running migrations for dbtemplates:
 - Migrating forwards to 0002_auto__del_unique_template_name.
 > dbtemplates:0001_initial
 ! Error found during real run of migration! Aborting.

 ! Since you have a database that does not support running
 ! schema-altering statements in transactions, we have had
 ! to leave it in an interim state between migrations.

! You *might* be able to recover with:   = DROP TABLE `django_template` CASCADE; []
   = DROP TABLE `django_template_sites` CASCADE; []

 ! The South developers regret this has happened, and would
 ! like to gently persuade you to consider a slightly
 ! easier-to-deal-with DBMS.
 ! NOTE: The error which caused the migration to fail is further up.
Traceback (most recent call last):
  File "manage.py", line 13, 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/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/management/commands/migrate.py", line 105, in handle
    ignore_ghosts = ignore_ghosts,
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/migration/__init__.py", line 191, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 221, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 292, in migrate_many
    result = self.migrate(migration, database)
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 125, in migrate
    result = self.run(migration)
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 99, in run
    return self.run_migration(migration)
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 81, in run_migration
    migration_function()
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 57, in <lambda>
    return (lambda: direction(orm))
  File "/usr/lib/python2.6/site-packages/django_dbtemplates-1.3-py2.6.egg/dbtemplates/migrations/0001_initial.py", line 18, in forwards
    ('last_changed', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/db/generic.py", line 226, in create_table
    ', '.join([col for col in columns if col]),
  File "/usr/lib/python2.6/site-packages/South-0.7.3-py2.6.egg/south/db/generic.py", line 150, in execute
    cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 86, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1050, "Table 'django_template' already exists")

Also i run python manage.py migrate --list, and uotput is:

 dbtemplates
  (*) 0001_initial
  (*) 0002_auto__del_unique_template_name

 contactform
  (*) 0001_initial
  (*) 0002_auto__add_callback
  (*) 0003_auto__add_field_callback_notes
  (*) 0004_auto__add_field_callback_is_closed__add_field_callback_closed
  (*) 0005_auto__add_field_callback_url
  (*) 0006_auto__add_contact
  (*) 0007_auto__add_field_contact_category
  (*) 0008_auto__add_field_contact_url

 links
  (*) 0001_initial
  (*) 0002_auto__add_field_category_enabled__add_field_category_order

 media
  (*) 0001_initial
  (*) 0002_auto__del_field_image_external_url__add_field_image_link_url__del_fiel
  (*) 0003_add_model_FileAttachment
  (*) 0004_auto__chg_field_file_slug__chg_field_image_slug
  (*) 0005_auto__chg_field_image_file
  (*) 0006_auto__chg_field_file_file

 pages
  (*) 0001_initial
  (*) 0002_auto__chg_field_page_meta_description__chg_field_page_meta_title__chg_
  (*) 0003_auto__add_field_page_show_in_sitemap
  (*) 0004_auto__add_field_page_changefreq__add_field_page_priority

 popularity
  (*) 0001_initial

 testimonials
  (*) 0001_initial
  (*) 0002_auto__add_field_testimonial_is_featured

 brands
  (*) 0001_initial
  (*) 0002_auto__add_field_brand_template
  (*) 0003_auto__chg_field_brand_meta_description__chg_field_brand_meta_title__ch
  (*) 0004_auto__add_field_brand_url
  (*) 0005_auto__del_field_brand_image__add_field_brand_logo

 collections
  (*) 0001_initial
  (*) 0002_auto__add_field_collection_discount
  (*) 0003_auto__chg_field_collection_meta_description__chg_field_collection_meta
  (*) 0004_auto__add_field_collection_is_featured
  (*) 0005_auto__add_field_collection_order

 discount
  (*) 0001_initial
  (*) 0002_added_field_discount_description
  (*) 0003_auto__add_field_discountvoucher_automatic
  (*) 0004_auto__add_field_discountvoucher_collection
  (*) 0005_auto__del_field_discountvoucher_collection
  (*) 0006_auto__chg_field_discountvoucher_expiry_date

 pricing
  (*) 0001_initial
  (*) 0002_auto__add_pricingrule

 product_types
  (*) 0001_initial
  (*) 0002_auto__add_field_producttype_meta_title__add_field_producttype_meta_des
  (*) 0003_auto__add_field_producttype_summary__add_field_producttype_description

 products
  (*) 0001_initial
  (*) 0002_auto__del_field_product_is_featured
  (*) 0003_auto__chg_field_product_meta_keywords__chg_field_product_meta_descript
  (*) 0004_auto

 shipping
  (*) 0001_initial
  (*) 0002_auto__add_field_shippingmethod_includes_tax__add_field_shippingmethod_
  (*) 0003_auto__add_field_shippingmethod_order
  (*) 0004_auto__del_field_shippingmethod_tax_rate__del_field_shippingmethod_incl
  (*) 0005_auto__del_field_shippingrule_enabled

 tax
  (*) 0001_initial
  (*) 0002_auto__add_field_taxrate_internal_name
  (*) 0003_initial_internal_names
  (*) 0004_auto__add_unique_taxrate_internal_name
  (*) 0005_force_unique_taxrate_name
  (*) 0006_auto__add_unique_taxrate_name

After that some images source were something like this:

 src="cache/1e/bd/1ebd719910aa843238028edd5fe49e71.jpg"

but some are still src="" or even doesn't display img tag
Also I have checked database, and table thumbnail_kvstore has been created.

Is any1 could help me with syncdb pledase?

miszczu
  • 1,179
  • 4
  • 19
  • 39
  • Can you check if your version of django has changed between the 2 servers? – zsquare May 30 '12 at 11:27
  • Yes, on the old server was Django 1.3, on new is Django 1.3.1. Unfortunately i haven't got access to the old server. I was only able to download all files which i need to create the same website on another server. – miszczu May 30 '12 at 11:36
  • 1
    How are your serving your static data? Using Apache? Or through the Django itself? It's rather unrelated to the case, but you log says, that your database isn't properly synced with your modules (there's a missing `thumbnail_kvstore` table). – Wojciech Żółtak May 30 '12 at 13:06
  • I have 7 files with database, each backup was made in a different day, and on each of this file table `thumbnail_kvstore` doesn't exist. Static data i'm serving through Django. – miszczu May 30 '12 at 13:13

0 Answers0