Forums

Weird Mezzanine behaviour

I'm working with the latest versions of Django and Mezzanine and I'm trying to deploy a working CMS. So far all is working well, but only when I'm logged in as admin through Mezzanine (for creating blogs, etc.). All rich text pages are hidden when I'm not logged in as admin.

I tried to debug this by running the website locally on my machine (python manage.py runserver), but I cannot recreate the issue. It only happens when I run the code on pythonanywhere.com. Here are two screen shots to get an idea of what is happening.

Working (when logged in as admin in for Mezzanine): http://imgur.com/avFtZ,VE7MP#1

Not working (when logged out as admin for Mezzanine): http://imgur.com/avFtZ,VE7MP#0

Any ideas? If code needs to be posted, let me know what you need.

Cheers, Eli

I have been able to debug the problem at bit more. When I go with the default Mezzanine pages during creation, all the pages (including the rich text pages) show up when not signed in as as admin. But, if I make changes afterward they do not show up when not signed in as admin. Could it be permission errors?

This problem does not occur when I'm using sqlite3. It could be related to MySQL?

I'm using Django version 1.4.3 and Mezzanine 1.3, which were installed through virtualenv.

Thanks

Last report - It looks like it is related to MySQL, but I'm not expert on this. Any input would be greatly appreciated. I did try this on another server (not pythonanywhere.com) with a postgresql DB and did not have this error.

Note: The same error pops up using either Django 1.3.4 (default with pythonanywhere) and Django 1.4.3.

output below

Would you like to install some initial content? Eg: About page, Blog, Contact form, Gallery. (yes/no): Please enter either 'yes' or 'no': yes

Creating initial content (About page, Blog, Contact form, Gallery) ...

Problem installing fixture '/usr/local/lib/python2.7/site-packages/mezzanine/forms/fixtures/mezzanine.json': Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 174, in handle obj.save(using=using) File "/usr/local/lib/python2.7/site-packages/django/core/serializers/base.py", line 165, in save models.Model.save_base(self.object, using=using, raw=True) File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base result = manager._insert(values, return_id=update_pk, using=using) File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert return insert_query(self.model, values, **kwargs) File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 1436, in insert_query return query.get_compiler(using=using).execute_sql(return_id) File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql cursor = super(SQLInsertCompiler, self).execute_sql(None) File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql cursor.execute(sql, params) File "/usr/local/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute return self.cursor.execute(sql, params) File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute return self.cursor.execute(query, args) File "/usr/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in execute self.errorhandler(self, exc, value) File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (ebressert$astro.forms_form, CONSTRAINT page_ptr_id_refs_id_1d5610fd FOREIGN KEY (page_ptr_id) REFERENCES pages_page (id))')

Traceback (most recent call last): File "manage.py", line 28, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 429, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-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/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(args, options.dict) File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(*args, options) File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle return self.handle_noargs(options) File "/usr/local/lib/python2.7/site-packages/mezzanine/core/management/commands/createdb.py", line 17, in handle_noargs syncdb.Command().execute(options) File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(args, options) File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle return self.handle_noargs(options) File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs emit_post_sync_signal(created_models, verbosity, interactive, db) File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal interactive=interactive, db=db) File "/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send response = receiver(signal=self, sender=sender, named) File "/usr/local/lib/python2.7/site-packages/mezzanine/core/management/__init__.py", line 54, in create_pages gallery = Gallery.objects.get() File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py", line 132, in get return self.get_query_set().get(*args, kwargs) File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 349, in get % self.model._meta.object_name) mezzanine.galleries.models.DoesNotExist: Gallery matching query does not exist.

Interesting, thanks for posting that. I don't know what what might cause that, but a bit of googling around suggests that it could be caused by having an existing database in place when it tries to load the initial fixtures.

Do you think you could try again with a fresh DB?

Thanks for the reply. I've tried to do this with a fresh link multiple times with fresh DBs. I'll try again to see what happens.

Found one part of the bug, which is a result of Django version < 1.4.x: http://stackoverflow.com/questions/6178816/django-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fails

Still trying to understand why the links to the rich text pages do not show up after manually creating them through Mezzanine's admin page.

The mysterious problem about the pages not loading is fixed. The page content is "published" at some given time and date with Mezzanine using the Django timezone-aware datetimes. When I tinkered with this, everything worked. Consider this problem fixed.

Thanks for updating! That makes a lot of sense.