-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unique_error_message has moved to model in Django 1.3 #5
Comments
Is that code from easymode or something else? |
That's in easymode.i18n.admin.forms at line 126 (easymode 1.0b1). |
To fix this the following has to be done: Try to remove the code entirely and see if the test passes. If so, you fixed it. I will fix it when I can find time, but maybe you can create the unit test and try the simple remove option. The test should go in easymode.tests.testcases.testforms. The test in there can serve as an example of your test. |
Hi I'm trying to fix this but I get 0 errors. Did you override the model form on the model or not? Please add minimal example of model, admin class and forms (if you did that) which show the error. |
I've created a subclass of the SearchForm of Haystack (django-haystack==1.2.6), which is a subclass of Django's forms.Form (source: https://github.com/toastdriven/django-haystack/blob/v1.2.6/haystack/forms.py ) My custom search form looks like: from django.db import models
from haystack.forms import SearchForm
class SingleModelSearchForm(SearchForm):
"""Search form to only search for a particular type of model."""
model = None
def search(self):
sqs = super(SingleModelSearchForm, self).search()
return sqs.models(getattr(self, 'model')) And the actual forms: class ProductSearchForm(SingleModelSearchForm):
model = Product
class RecipeSearchForm(SingleModelSearchForm):
model = Recipe The models (Product and Recipe) are ordinary models with various translatable fields, including a translatable models.SlugField. The admin classes of Recipe and Product have nothing special, e.g.: @L10n(Recipe)
class RecipeAdmin(admin.ModelAdmin):
list_display = ('title',)
fieldsets = (
(None, {
'classes': ['wide'],
'fields': ('title', 'slug', 'tags',),
}),
(_('Images'), {
'classes': ['wide'],
'fields': ('image', 'homepage_image',),
}),
(_('Properties'), {
'classes': ['wide'],
'fields': ('servings', 'preparation_time', 'product',),
}),
(_('Homepage'), {
'classes': ['wide'],
'fields': ('person', 'person_text',),
}),
(_('Preparation'), {
'classes': ['wide'],
'fields': ('ingredients', 'preparation', 'tip',),
}),
) |
As of Django 1.3, the unique_error_message method has moved from the form to the model. For models with a unique slug field, this causes the following error upon saving:
AttributeError: 'RecipeForm' object has no attribute 'unique_error_message'
It happens here:
The text was updated successfully, but these errors were encountered: