How to choose a Wagtail image across a ParentalManyToManyField? - django

Environment:
Wagtail 1.13
Django Version: 1.11.11
Python Version: 2.7.12
I'm following the Wagtail documentation to try to add an image showcase (not a category) to a page using ParentalManyToManyField:
class HomePage(Page):
showcase_title = models.CharField(max_length=100, blank="true", default="SHOWCASE")
showcase_images = ParentalManyToManyField('wagtailimages.Image')
content_panels = Page.content_panels + [
FieldPanel('showcase_title'),
InlinePanel('showcase_images', label="Showcase images", panels=[
ImageChooserPanel('showcase_images')
]),
]
Everything is fine if I comment out the showcase_images editing panel, but I get a KeyError as soon as uncomment the panel showcase_images. In addition to the above variation of editing showcase_images, I've also tried simply InlinePanel('showcase_images'), FieldPanel('showcase_images'), InlinePanel('showcase_images', label="Showcase images", panels=[ImageChooserPanel('image')]), and probably another variation or two. Can someone propose a solution?
Environment:
Request Method: GET
Request URL: http://dev.somedomain.com:8181/admin/pages/3/edit/
Django Version: 1.11.11
Python Version: 2.7.12
Installed Applications:
[u'my_app',
u'search',
u'wagtail.wagtailforms',
u'wagtail.wagtailredirects',
u'wagtail.wagtailembeds',
u'wagtail.wagtailsites',
u'wagtail.wagtailusers',
u'wagtail.wagtailsnippets',
u'wagtail.wagtaildocs',
u'wagtail.wagtailimages',
u'wagtail.wagtailsearch',
u'wagtail.wagtailadmin',
u'wagtail.wagtailcore',
u'wagtail.contrib.wagtailstyleguide',
u'modelcluster',
u'taggit',
u'wagtailfontawesome',
u'django.contrib.admin',
u'django.contrib.auth',
u'django.contrib.contenttypes',
u'django.contrib.sessions',
u'django.contrib.messages',
u'django.contrib.staticfiles']
Installed Middleware:
[u'django.contrib.sessions.middleware.SessionMiddleware',
u'django.middleware.common.CommonMiddleware',
u'django.middleware.csrf.CsrfViewMiddleware',
u'django.contrib.auth.middleware.AuthenticationMiddleware',
u'django.contrib.messages.middleware.MessageMiddleware',
u'django.middleware.clickjacking.XFrameOptionsMiddleware',
u'django.middleware.security.SecurityMiddleware',
u'wagtail.wagtailcore.middleware.SiteMiddleware',
u'wagtail.wagtailredirects.middleware.RedirectMiddleware']
Traceback:
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/django/views/decorators/cache.py" in _cache_controlled
43. response = viewfunc(request, *args, **kw)
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/wagtail/wagtailadmin/urls/__init__.py" in wrapper
96. return view_func(request, *args, **kwargs)
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/wagtail/wagtailadmin/decorators.py" in decorated_view
31. return view_func(request, *args, **kwargs)
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/wagtail/wagtailadmin/views/pages.py" in edit
481. edit_handler = edit_handler_class(instance=page, form=form)
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/wagtail/wagtailadmin/edit_handlers.py" in __init__
269. self.children.append(child(instance=self.instance, form=self.form))
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/wagtail/wagtailadmin/edit_handlers.py" in __init__
269. self.children.append(child(instance=self.instance, form=self.form))
File "/opt/virtualenvs/gmmiTMID/lib/python2.7/site-packages/wagtail/wagtailadmin/edit_handlers.py" in __init__
693. self.formset = form.formsets[self.__class__.relation_name]
Exception Type: KeyError at /admin/pages/3/edit/
Exception Value: u'showcase_images'

InlinePanel doesn't work with ParentalManyToManyField relations, only ParentalKey relations. You'll need to set up an intermediate model to define the relation between pages and images, like BlogPageGalleryImage in the tutorial's 'images' section (but with the caption field omitted in this case, so it's just a direct association between pages and images).
(Alternatively, you can use a plain FieldPanel with ParentalManyToManyField, but this will just give you a set of checkboxes for all images in the system, rather than the the image chooser interface.)

Related

MultiValueDictKeyError when deleting related inline records in another tab

I'll try to be as concise as possible.
Background
I have a model Person which has a ForeignKey to model Document. Each Person can only have one Document but, as you may already know, each Document can be linked to many Persons.
In the Document's Admin form I have the Persons associated to the Document displayed inline. I can edit, add or delete the Persons right there.
Problem
Following these steps I get the error:
I open the Admin edit form for a Document. Let's call it Document
A. This Document has two Persons associated, let's call them John
Doe and Jane Doe. You can see them there (inline) in the form and
the fields are editable, but I don't touch them.
I open another tab and go straight to the Persons list and delete
Jane Doe.
I get back to the first tab (the Document's edit form) and click on
"Save and continue editing".
The form is sent and I get a generic error at the top (something
like) "Please, fix the following errors". But the form shows no
errors (next to the fields) to correct and, obviously, the record
for Jane Doe isn't displayed.
I click again on "Save and continue editing" and when the form is
sent I get the error "MultiValueDictKeyError: "u'person_set-1-id'"".
Ideal solution
I'd like to be able to display a custom error in the middle stage (when the first error appears, after the first save), saying something like "A person associated with this Document was deleted while you were editing it". Also, preventing the final error is highly desirable.
Error dump
MultiValueDictKeyError at /admin/persons/document/1145/
"u'person_set-1-id'"
Request Method: POST
Request URL: http://localhost:8000/admin/persons/document/1145/
Django Version: 1.7.7
Exception Type: MultiValueDictKeyError
Exception Value:
"u'person_set-1-id'"
Exception Location: /__PATH__/local/lib/python2.7/site-packages/django/utils/datastructures.py in __getitem__, line 319
Python Executable: /__PATH__/bin/python
Python Version: 2.7.15
Python Path:
['/__PATH__/test/test/apps',
'/__PATH__/test',
'/__PATH__/lib/python2.7',
'/__PATH__/lib/python2.7/plat-x86_64-linux-gnu',
'/__PATH__/lib/python2.7/lib-tk',
'/__PATH__/lib/python2.7/lib-old',
'/__PATH__/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/__PATH__/local/lib/python2.7/site-packages',
'/__PATH__/src/django-smart-selects',
'/__PATH__/lib/python2.7/site-packages',
'/__PATH__/local/lib/python2.7/site-packages/odf',
'/__PATH__/local/lib/python2.7/site-packages/odf',
'/__PATH__/local/lib/python2.7/site-packages/odf',
'/__PATH__/local/lib/python2.7/site-packages/odf',
'/__PATH__/local/lib/python2.7/site-packages/odf',
'/__PATH__/local/lib/python2.7/site-packages/odf',
'/__PATH__/local/lib/python2.7/site-packages/odf',
'/__PATH__/test']
Server time: Mar, 29 Ene 2019 11:52:18 -0300
Environment:
Request Method: POST
Request URL: http://localhost:8000/admin/persons/document/1145/
Django Version: 1.7.7
Python Version: 2.7.15
Installed Applications:
('salmonella',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'crispy_forms',
'test.apps.persons',
'captcha',
'django_countries',
'django_extensions',
'import_export',
'django_object_actions',
'widget_tweaks',
'smart_selects',
'daterange_filter',
'compressor',
'auditlog')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'auditlog.middleware.AuditlogMiddleware')
Traceback:
File "/__PATH__/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
583. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
206. return view(request, *args, **kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in change_view
1456. return self.changeform_view(request, object_id, form_url, extra_context)
File "/__PATH__/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
29. return bound_func(*args, **kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
25. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/__PATH__/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
394. return func(*args, **kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in changeform_view
1403. if all_valid(formsets) and form_validated:
File "/__PATH__/local/lib/python2.7/site-packages/django/forms/formsets.py" in all_valid
438. if not formset.is_valid():
File "/__PATH__/local/lib/python2.7/site-packages/django/forms/formsets.py" in is_valid
303. self.errors
File "/__PATH__/local/lib/python2.7/site-packages/django/forms/formsets.py" in errors
277. self.full_clean()
File "/__PATH__/local/lib/python2.7/site-packages/django/forms/formsets.py" in full_clean
325. form = self.forms[i]
File "/__PATH__/local/lib/python2.7/site-packages/django/utils/functional.py" in __get__
55. res = instance.__dict__[self.func.__name__] = self.func(instance)
File "/__PATH__/local/lib/python2.7/site-packages/django/forms/formsets.py" in forms
141. forms = [self._construct_form(i) for i in xrange(self.total_form_count())]
File "/__PATH__/local/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
868. form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
File "/__PATH__/local/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
581. pk = self.data[pk_key]
File "/__PATH__/local/lib/python2.7/site-packages/django/utils/datastructures.py" in __getitem__
319. raise MultiValueDictKeyError(repr(key))
Exception Type: MultiValueDictKeyError at /admin/persons/document/1145/
Exception Value: "u'person_set-1-id'"
UPDATE
I'm adding the definitions for models Person and Document.
class Document(models.Model):
creation_date = models.DateTimeField(auto_now_add=True)
title = models.CharField(max_length=300, null=True, blank=True)
class Person(models.Model):
first_name = models.CharField(max_length=300)
last_name = models.CharField(max_length=300)
email = models.EmailField(max_length=300)
document = models.ForeignKey(Document)
UPDATE 2
One important thing I noticed is that, in the first error page (after the first submission of Document A form) the hidden inputs like person_set-TOTAL_FORMS and person_set-INITIAL_FORMS are set to 2 while they should be set to 1 (the actual number of persons). Obviously this happens because the submitted data doesn't reflect the actual database state.

Error with prewarming VersatileImageField

I've implemented django-versatileimagefield and have gotten it to a state where I can successfully resize images in templates with the use of the following tag, for example:
As a result, I'm confident that my form.py, view.py, and template works. I have, however, recently tried to 'prewarm' the images so that when a user saves an image, a set of resized images are saved to my 'media' folder. This prevents the server from having to resize dynamically on every page load and can just grab the correctly sized image.
My problem is that when the user goes to save an image within the image upload form, they get an error.
Settings.py
VERSATILEIMAGEFIELD_SETTINGS = {
'cache_length': 2592000,
'cache_name': 'versatileimagefield_cache',
'jpeg_resize_quality': 70,
'sized_directory_name': '__sized__',
'filtered_directory_name': '__filtered__',
'placeholder_directory_name': '__placeholder__',
'create_images_on_demand': False,
'image_key_post_processor': None,
'progressive_jpeg': False
}
VERSATILEIMAGEFIELD_RENDITION_KEY_SETS = {
'image_gallery': [
('image_large', 'thumbnail__400x400'),
('image_small', 'thumbnail__900x900')
]
}
models.py
from django.db import models
from django.db.models.signals import post_save
from versatileimagefield.fields import VersatileImageField
from django.dispatch import receiver
from versatileimagefield.image_warmer import VersatileImageFieldWarmer
class ImageGallery(models.Model):
author = models.ForeignKey(User, on_delete=models.CASCADE, default=None)
image = VersatileImageField('image_gallery', upload_to=upload_location)
def __str__(self):
return self.author.username
#receiver(models.signals.post_save, sender=ImageGallery)
def warm_gallery_images(sender, instance, **kwargs):
gallery_img_warmer = VersatileImageFieldWarmer(
instance_or_queryset=instance,
rendition_key_set='image_gallery',
image_attr='image_small'
)
num_created, failed_to_create = gallery_img_warmer.warm()
Traceback
Environment:
Traceback:
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\exception.py" in inner
35. response = get_response(request)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)
File "C:\Users\jason\Desktop\jason\accounts\views.py" in imagegallery
513. instance.save()
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\base.py" in save
729. force_update=force_update, update_fields=update_fields)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\base.py" in save_base
769. update_fields=update_fields, raw=raw, using=using,
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\dispatch\dispatcher.py" in send
178. for receiver in self._live_receivers(sender)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\dispatch\dispatcher.py" in <listcomp>
178. for receiver in self._live_receivers(sender)
File "C:\Users\jason\Desktop\jason\accounts\models.py" in warm_gallery_images
177. num_created, failed_to_create = gallery_img_warmer.warm()
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\versatileimagefield\image_warmer.py" in warm
143. reduce(getattr, self.image_attr.split("."), instance)
Exception Type: AttributeError at /accounts/profile/websitesetup5/upload/
Exception Value: 'ImageGallery' object has no attribute 'image_small'
I feel like I've followed the instructions on this page, but I'm still getting this error.
http://django-versatileimagefield.readthedocs.io/en/latest/improving_performance.html#turning-off-on-demand-image-creation
I should note that I do NOT have django REST framework installed. My understanding is that it's not required for this post-save method of prewarming images.
Thanks so much!
It looks like the image_attr field should point to the model field image:
#receiver(models.signals.post_save, sender=ImageGallery)
def warm_gallery_images(sender, instance, **kwargs):
gallery_img_warmer = VersatileImageFieldWarmer(
instance_or_queryset=instance,
rendition_key_set='image_gallery',
image_attr='image'
)
num_created, failed_to_create = gallery_img_warmer.warm()

I have a GeocoderQueryError and suspect it's an issue with my API management

GeocoderQueryError at /search/
Your request was denied.
I'm seeing this issue across all versions of my application. That is locally, on staging, and on production. This leads me to believe it's something I've done in the API console since I haven't touched production and only touched the API call on staging. I have been in the API console but have only added IP addresses to "Accept requests from these server IP addresses" input in the credentials tab.
Here is the staging link: test.translgx.com
You'll only see a 500 page after searching for a ZIP code. I've included the full error report from my local installation at the bottom of the post, I hope this is helpful. If not, let me know and I'll do what I can to get the info needed to solve this.
Full disclosure, I'm a front-end guy and don't have the debugging/diagnostic skills needed to figure this out. I also don't have any back-end dev support available to me until next week. Google's support docs tell me to come here with questions so I'm hoping someone here shows mercy and points me in the right direction.
I should also note that the API key I see in production doesn't match any key in my console.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/search/?address=94133&distance=zip&truck=
Django Version: 1.9.4
Python Version: 2.7.11
Installed Applications:
('django_pdb',
u'django.contrib.auth',
u'django.contrib.contenttypes',
u'django.contrib.sessions',
u'django.contrib.sites',
u'django.contrib.messages',
u'django.contrib.staticfiles',
u'django.contrib.admin',
u'django.contrib.gis',
u'crispy_forms',
u'post_office',
u'widget_tweaks',
u'captcha',
u'geoposition',
u'cities_light',
u'templatetag_handlebars',
u'trucking_directory.common.apps.CommonConfig',
'debug_toolbar',
'django_extensions')
Installed Middleware:
(u'django.contrib.sessions.middleware.SessionMiddleware',
u'django.middleware.common.CommonMiddleware',
u'django.middleware.csrf.CsrfViewMiddleware',
u'django.contrib.auth.middleware.AuthenticationMiddleware',
u'django.contrib.messages.middleware.MessageMiddleware',
u'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django_pdb.middleware.PdbMiddleware')
Traceback:
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 149.
response = self.process_exception_by_middleware(e, request)
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 147.
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/utils/decorators.py" in inner 184.
return func(*args, **kwargs)
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/views/generic/base.py" in view 68.
return self.dispatch(request, *args, **kwargs)
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch 88.
return handler(request, *args, **kwargs)
File "/Users/me/Sites/_app/trucking-directory/trucking_directory/common/views.py" in get 261.
self.form.is_valid()
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/forms/forms.py" in is_valid 161.
return self.is_bound and not self.errors
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/forms/forms.py" in errors 153.
self.full_clean()
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/forms/forms.py" in full_clean 362.
self._clean_fields()
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/django/forms/forms.py" in _clean_fields 383.
value = getattr(self, 'clean_%s' % name)()
File "/Users/me/Sites/_app/trucking-directory/trucking_directory/common/forms.py" in clean_address 218.
locations = _get_location(data, False)
File "/Users/me/Sites/_app/trucking-directory/trucking_directory/common/forms.py" in _get_location 38.
location = g.geocode(address, exactly_one=one)
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/geopy/geocoders/googlev3.py" in geocode 217.
self._call_geocoder(url, timeout=timeout), exactly_one
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/geopy/geocoders/googlev3.py" in _parse_json 338.
self._check_status(page.get('status'))
File "/Users/me/Envs/tlx-d/lib/python2.7/site-packages/geopy/geocoders/googlev3.py" in _check_status 369.
'Your request was denied.'
Exception Type: GeocoderQueryError at /search/
Exception Value: Your request was denied.
You probably need to add an API key. If you don't have one, try the GET A KEY in the top-left corner of the Geocoding API guide. The, I think this code should work (borrowed from here):
from geopy.geocoders import GoogleV3
point = '51.523910, -0.158578'
geocoder = GoogleV3(api_key=YOUR_API_KEY)
address = geolocator.reverse(point)

Error using ModelResource: can't set attribute

I can't get my head around this error... I'm using the restframework2 branch.
Am I doing something wrong, or is this a bug in the restframework2 code?
Here's my code:
resources.py
class TemplateHoursSerializer(serializers.ModelSerializer):
class Meta:
model = TemplateHours
nested = True
start = HourField()
end = HourField()
employee = EmployeeSerializer()
class TemplateHoursResource(ModelResource):
model = TemplateHours
serializer_class = TemplateHoursSerializer
urls.py
url(r'^api/template-hours/$', TemplateHoursResource.as_view(actions={
'get': 'list',
'post': 'create'
})),
url(r'^api/template-hours/(?P<pk>[0-9]+)/$', TemplateHoursResource.as_view(actions={
'get': 'retrieve',
'put': 'update',
'delete': 'destroy'
})),
...
When I visit (or POST to) http://127.0.0.1:8000/api/template-hours/, I get this error and traceback:
AttributeError at /api/template-hours/
can't set attribute
Request Method: GET
Request URL: http://127.0.0.1:8000/api/template-hours/
Django Version: 1.4.1
Exception Type: AttributeError
Exception Value:
can't set attribute
Exception Location: C:\Users\Mathieu\Development\django_projects\hedron\Lib\site- packages\rest_framework\resources.py in wrapped, line 13
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2
Python Path:
['C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\Scripts',
'C:\\Python27\\lib\\site-packages\\setuptools-0.6c12dev_r88846-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\virtualenv-1.7.1.2-py2.7.egg',
'C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\Lib\\site-packages',
'C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\hedron',
'C:\\Python27\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages',
path(u'C:\\Users\\Mathieu\\Development\\django_projects\\hedron'),
path(u'C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\hedron\\apps'),
path(u'C:\\Users\\Mathieu\\Development\\django_projects\\hedron\\hedron\\libs')]
Server time: di, 9 Okt 2012 22:46:50 +0200
Traceback:
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\resources.py" in view
48. return self.dispatch(request, *args, **kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
77. return view_func(*args, **kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\views.py" in dispatch
324. response = self.handle_exception(exc)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\views.py" in dispatch
321. response = handler(request, *args, **kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\resources.py" in list
74. return self.root_view().list(request, args, kwargs)
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\resources.py" in root_view
68. return wrapped(self, self.root_class())
File "C:\Users\Mathieu\Development\django_projects\hedron\Lib\site-packages\rest_framework\resources.py" in wrapped
13. setattr(dest, attr, getattr(source, attr))
Exception Type: AttributeError at /api/template-hours/
Exception Value: can't set attribute
Resources and routers are not finished/supported in [the beta of] REST framework 2 yet. The docs on them are a placeholder for what I want the design to look like, but I'll be removing them from the index today. Hopefully they'll make it in for 2.0, but I don't see it as at all essential, since you can do everything you need with Views and explicit URLconfs. Resources & routers just give you a useful shortcut.

error in admin page when editing using django-multilingual-ng on django 1.3

am trying to switch my application to use multilingual-ng, unfortunutely though, there is very little documentation and FAQ's online. I hope someone would be able to tell what is going on with my practice,
following is my model
class Main(models.Model):
""" Main Class for all categories """
slug = models.SlugField()
is_active = models.BooleanField(default=True)
site = models.ForeignKey(Site)
parent = models.ForeignKey('self', blank=True, null=True)
class Translation(TranslationModel):
title = models.CharField(max_length=100)
label = models.CharField(max_length=100, blank=True, null=True)
description = models.TextField(blank=True, null=True)
disclaimer = models.TextField(blank=True, null=True)
class Meta:
unique_together = (("slug", "parent"))
def __unicode__(self):
return self.title if self.title is not None else _("No translation")
and following is my admin.py
class MainAdmin(MultilingualModelAdmin):
''' Multilingual interface for Main category '''
class ListAdmin(MultilingualModelAdmin):
''' Multilingual interface for Main category '''
admin.site.register(Main, MainAdmin)
admin.site.register(List, ListAdmin)
When I access my admin panel, I can see the model, list of items, add new items but when I try to edit an existing item or delete one I get the followng error
Environment:
Request Method: GET
Request URL: http://mazban.com/admin/category/main/1/
Django Version: 1.3
Python Version: 2.6.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'compressor',
'django.contrib.gis',
'multilingual',
'mazban.lib.apps.core',
'mazban.lib.apps.gis',
'mazban.apps.global',
'mazban.apps.listing',
'mazban.apps.listing.post',
'mazban.apps.listing.home',
'mazban.apps.listing.engine',
'mazban.apps.listing.category']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'mazban.lib.MiddleWare.custom.RequestIsMobile')
Traceback:
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/contrib/admin/options.py" in wrapper
307. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/utils/decorators.py" in _wrapped_view
93. response = view_func(request, *args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
79. response = view_func(request, *args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/contrib/admin/sites.py" in inner
197. return view(request, *args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/multilingual/admin.py" in wrapped
31. resp = func(cls, request, *args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/multilingual/admin.py" in change_view
277. return super(MultilingualModelAdmin, self).change_view(*args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/utils/decorators.py" in _wrapper
28. return bound_func(*args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/utils/decorators.py" in _wrapped_view
93. response = view_func(request, *args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/utils/decorators.py" in bound_func
24. return func(self, *args2, **kwargs2)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/db/transaction.py" in inner
217. res = func(*args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/contrib/admin/options.py" in change_view
947. obj = self.get_object(request, unquote(object_id))
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/contrib/admin/options.py" in get_object
451. return queryset.get(pk=object_id)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/db/models/query.py" in get
341. clone = self.filter(*args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/db/models/query.py" in filter
550. return self._filter_or_exclude(False, *args, **kwargs)
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/db/models/query.py" in _filter_or_exclude
568. clone.query.add_q(Q(*args, **kwargs))
File "/users/mo/Projects/python-envs/mazban/lib/python2.6/site-packages/django/db/models/sql/query.py" in add_q
1172. can_reuse=used_aliases, force_having=force_having)
Exception Type: TypeError at /admin/category/main/1/
Exception Value: add_filter() got an unexpected keyword argument 'force_having'
Don't use django-multilingual-ng, as it is not supported anymore and will bring you many headaches. The author of the django-multilingual-ng started a new promising project, named django-nani. It should be reliable and Django 1.3 compatible.
As for me, this problem didn't show on Django 1.2.4, so you might want to move back to that version, once you go through the Django 1.2.5 release notes.
I installed from latest revision and the error disapeared:
$ pip install git+https://github.com/ojii/django-multilingual-ng.git
Although the error is gone using this release, it still says it it unsupported. I am heavily inclined to roll back to Django 1.2.4, but I am still trying to figure this out.
As mentioned, the django-nani project is promising, but it is still in alpha stages. I couldn't find a way to work with any type of model relationship as of today's revision. They will be working on it soon.
I've got the same problem, upgrading from 1.2.4 to the new security releases in 1.2.7. Ng is already in use and can't be swapped out, even though support for it has been dropped. Just the world we live in. I can't find any documentation on force_havings role in the django query system.
Glad they're working on a new system though. If anyone has any knowledge on force_having it would be greatly appreciated.