Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ojii/django-nani
...
head fork: ojii/django-nani
Checking mergeability… Don't worry, you can still create the pull request.
  • 9 commits
  • 9 files changed
  • 0 commit comments
  • 3 contributors
View
8 .travis.yml
@@ -3,10 +3,10 @@ python:
- 2.6
- 2.7
env:
- - DJANGO_VERSION=1.2.7
- - DJANGO_VERSION=1.3.1
- - DJANGO_VERSION=1.4
+ - DJANGO_VERSION=1.2.7 ADDITIONAL_PACKAGES='sphinx django-cbv'
+ - DJANGO_VERSION=1.3.1 ADDITIONAL_PACKAGES='sphinx'
+ - DJANGO_VERSION=1.4 ADDITIONAL_PACKAGES='sphinx'
install:
- - pip install -q Django==$DJANGO_VERSION && pip install sphinx
+ - pip install -q Django==$DJANGO_VERSION && pip install $ADDITIONAL_PACKAGES
- python setup.py -q install
script: ./runtests.sh
View
8 docs/index.rst
@@ -27,6 +27,14 @@ While django-hvad tries to be as simple to use as possible, it's still
recommended that you only use it if you consider yourself to be very strong in
Python and Django.
+
+************************
+Notes on django versions
+************************
+
+django-hvad is tested on python 2.6 and 2.7 with django 1.2.7, 1.3.1 and 1.4. These should all work as expected, but for django 1.2.x you need you need to install django-cbv to use the class based views.
+
+
***************
Contents
***************
View
7 docs/public/installation.rst
@@ -10,7 +10,7 @@ Requirements
* `Django`_ 1.2 or higher
* Python 2.5 or a higher release of Python 2.x or PyPy 1.5, Python 3.x is not
supported (yet).
-
+* For Django 1.2.x you need `django-cbv`_
************
@@ -18,8 +18,9 @@ Installation
************
-Install django-nani using `pip`_ by running ``pip install django-nani``. Then
+Install django-hvad using `pip`_ by running ``pip install django-hvad``. Then
add ``'nani'`` to your ``INSTALLED_APPS`` to make the admin templates work.
.. _pip: http://pypi.python.org/pypi/pip
-.. _Django: http://www.djangoproject.com
+.. _Django: http://www.djangoproject.com
+.. _django-cbv: http://pypi.python.org/pypi/django-cbv
View
9 hvad/admin.py
@@ -196,7 +196,8 @@ def render_change_form(self, request, context, add=False, change=False,
def response_change(self, request, obj):
redirect = super(TranslatableAdmin, self).response_change(request, obj)
uri = iri_to_uri(request.path)
- if redirect['Location'] in (uri, "../add/"):
+ app_label, model_name = self.model._meta.app_label, self.model._meta.module_name
+ if redirect['Location'] in (uri, "../add/", reverse('admin:%s_%s_add' % (app_label, model_name))):
if self.query_language_key in request.GET:
redirect['Location'] = '%s?%s=%s' % (redirect['Location'],
self.query_language_key, request.GET[self.query_language_key])
@@ -328,7 +329,7 @@ def queryset(self, request):
languages.append(lang)
qs = self.model._default_manager.untranslated().use_fallbacks(*languages)
# TODO: this should be handled by some parameter to the ChangeList.
- ordering = self.ordering or () # otherwise we might try to *None, which is bad ;)
+ ordering = getattr(self, 'ordering', None) or () # otherwise we might try to *None, which is bad ;)
if ordering:
qs = qs.order_by(*ordering)
return qs
@@ -549,7 +550,7 @@ def queryset(self, request):
language = self._language(request)
qs = self.model._default_manager.all()#.language(language)
# TODO: this should be handled by some parameter to the ChangeList.
- ordering = self.ordering or () # otherwise we might try to *None, which is bad ;)
+ ordering = getattr(self, 'ordering', None) or () # otherwise we might try to *None, which is bad ;)
if ordering:
qs = qs.order_by(*ordering)
return qs
@@ -559,4 +560,4 @@ class TranslatableStackedInline(TranslatableInlineModelAdmin):
template = 'admin/hvad/edit_inline/stacked.html'
class TranslatableTabularInline(TranslatableInlineModelAdmin):
- template = 'admin/hvad/edit_inline/tabular.html'
+ template = 'admin/hvad/edit_inline/tabular.html'
View
7 hvad/tests/forms.py
@@ -129,11 +129,12 @@ def test_no_language_code_in_fields(self):
self.assertFalse(form.fields.has_key("language_code"))
def test_form_wrong_field_in_class(self):
- with LanguageOverride("en"):
- with self.assertRaises(FieldError):
+ with LanguageOverride("en"):
+ def create_wrong_form():
class WrongForm(TranslatableModelForm):
class Meta:
model = Normal
fields = ['a_field_that_doesnt_exist']
- form = WrongForm()
+ form = WrongForm()
+ self.assertRaises(FieldError, create_wrong_form)
View
5 hvad/views.py
@@ -1,5 +1,8 @@
from django.http import Http404
-from django.views.generic.edit import UpdateView
+try:
+ from django.views.generic.edit import UpdateView
+except ImportError:
+ from cbv.views.edit import UpdateView
from admin import TranslatableModelAdminMixin
from forms import translatable_modelform_factory, TranslatableModelForm
from utils import collect_context_modifiers
View
2  nani/admin.py
@@ -1,4 +1,4 @@
from hvad.admin import *
import warnings
-warnings.warn("The 'nani' namespace is deprecated, please change your imports to use 'hvad' instead", DeprecationWarning)
+warnings.warn("The 'nani' namespace is deprecated, please change your imports to use 'hvad' instead", DeprecationWarning)
View
2  nani/views.py
@@ -1,4 +1,4 @@
from hvad.views import *
import warnings
-warnings.warn("The 'nani' namespace is deprecated, please change your imports to use 'hvad' instead", DeprecationWarning)
+warnings.warn("The 'nani' namespace is deprecated, please change your imports to use 'hvad' instead", DeprecationWarning)
View
2  setup.py
@@ -1,5 +1,5 @@
from setuptools import setup, find_packages
-from nani import __version__ as version
+from hvad import __version__ as version
setup(
name = 'django-hvad',

No commit comments for this range

Something went wrong with that request. Please try again.