Skip to content
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

Django 1.8 #1060

Closed
wants to merge 9 commits into from
Closed

Django 1.8 #1060

wants to merge 9 commits into from

Conversation

kaedroho
Copy link
Contributor

This PR adds Django 1.8 support into Wagtail

@kaedroho kaedroho force-pushed the dj18 branch 2 times, most recently from 74bb087 to 45489d6 Compare March 16, 2015 00:08
@kaedroho kaedroho mentioned this pull request Mar 16, 2015
6 tasks
@kaedroho kaedroho modified the milestones: 1.0, 0.9 Mar 17, 2015
@kaedroho
Copy link
Contributor Author

I think it's worth trying to get this into 0.9. Django 1.8 is scheduled for the end of this month and 1.0 might be a long wait.

@tomdyson
Copy link
Contributor

I agree. How much work do you think it is? Could someone else help?

On Tuesday, 17 March 2015, Karl Hobley notifications@github.com wrote:

I think it's worth trying to get this into 0.9. Django 1.8 is scheduled
for the end of this month and 1.0 might be a long wait.

Reply to this email directly or view it on GitHub
#1060 (comment).

sent from my phone

@kaedroho
Copy link
Contributor Author

The work on getting Wagtail working on Django 1.8 is mostly done. Mainly waiting on the following PRs to be merged:

Reviews much appreciated!

We also need to think about how we're going to get RoutablePageMixin working with the changes made to Djangos url configuration. Possibly an API breakage may be required here...

@@ -6,7 +6,7 @@
from six import text_type

from modelcluster.forms import ClusterForm, ClusterFormMetaclass

from modelcluster.models import get_related_model
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would probably be best to redefine this in wagtail so an older version of modelcluster can still be used under Django 1.7

@mx-moth
Copy link
Contributor

mx-moth commented Mar 26, 2015

I tried to combine Django 1.8 (rc1), Wagtail, and Jinja templates, and came across a problem: Jinja templates fail when the context contains a self key! I made a Django bug for it: https://code.djangoproject.com/ticket/24538#ticket

@kaedroho kaedroho force-pushed the dj18 branch 2 times, most recently from 58e4b0e to 4416529 Compare March 26, 2015 11:02
@kaedroho
Copy link
Contributor Author

@timheap thanks for testing!

@kaedroho kaedroho force-pushed the dj18 branch 6 times, most recently from 6671217 to faa1d03 Compare March 30, 2015 15:29
@huxley
Copy link

huxley commented Mar 30, 2015

Just noticed that the Django ticket @timheap references is now marked wontfix because Tim has found that self is a special variable in Jinja2. Wondering how difficult it would be to switch Wagtail to use a different variable than self?

@kaedroho kaedroho force-pushed the dj18 branch 2 times, most recently from 447c5bf to 4b5895c Compare March 30, 2015 16:13
@chrxr
Copy link
Contributor

chrxr commented Mar 31, 2015

Hi @timheap, please could you review this. Django 1.8 is due to be released tomorrow, and we're keen to get support into Wagtail 1.0. Thanks!

@mx-moth
Copy link
Contributor

mx-moth commented Apr 1, 2015

This looks good! I am keen to see Wagtail in Django 1.8. Wagtail 1.0 will be huge at this rate! Some thoughts on this pull request:


tox.ini tests py27-dj18-postgres, but not -mysql or -sqlite, as these are commented out. Is this deliberate?

tox.ini contains some git URLs for dependencies still. I understand that these changes are not yet merged so this is required, just dont forget them before release!


Feature detection seems to be used in many places, as opposed to version detection. In my opinion, this makes the code much harder to read and reason about, as well as hiding the true intention of the code behind comments. For example get_related_model:

def get_related_model(rel):
    # In Django 1.7 and under, the related model is accessed by doing: rel.model
    # This was renamed in Django 1.8 to rel.related_model. rel.model now returns
    # the base model.
    return getattr(rel, 'related_model', rel.model)

and TestRouting.test_request_serving:

# Django 1.8+
if hasattr(used_template, 'template'):
    used_template = used_template.template

In my opinion, checking the version is much clearer, straight forward, less error prone, and more explicit:

def get_related_model(rel):
    # In Django 1.7 and under, the related model is accessed by doing: rel.model
    # This was renamed in Django 1.8 to rel.related_model.
    if DJANGO_VERSION < (1, 8):
        return rel.model
    else:
        return rel.related_model
if DJANGO_VERSION >= (1, 8):
    used_template = used_template.template

This has the added benefit of being self documenting, as it is clear that the functionality differs from version to version. It also works in all cases, and is already in use where feature detection does not work (e.g. migrations involving content types: defaults={'name': 'document'} if DJANGO_VERSION < (1, 8) else {}). Finally, when Django 1.7 support is dropped in the future, searching the codebase for the tuple (1, 8) should return all instances of hacks done to support the 1.7/1.8 differences.


I did not review the pull requests for django-taggit and django-modelcluster.

@kaedroho
Copy link
Contributor Author

kaedroho commented Apr 1, 2015

tox.ini tests py27-dj18-postgres, but not -mysql or -sqlite, as these are commented out. Is this deliberate?

Yeah.. Unfortunately, the more we make Travis do the slower it gets. We're testing all the database backends on Python 3.4, but just Postgres on Python 2.7.

tox.ini contains some git URLs for dependencies still. I understand that these changes are not yet merged so this is required, just dont forget them before release!

Maybe I'll just include them for the Django 1.8 tests for now and test Django 1.7 with released versions.

Feature detection seems to be used in many places, as opposed to version detection. In my opinion, this makes the code much harder to read and reason about, as well as hiding the true intention of the code behind comments.

That looks better, will change

@kaedroho kaedroho changed the title [WIP] Django 1.8 Django 1.8 Apr 1, 2015
@kaedroho
Copy link
Contributor Author

kaedroho commented Apr 1, 2015

This may require some tweaks now that the API is merged

@kaedroho
Copy link
Contributor Author

kaedroho commented Apr 2, 2015

Ready for merge. There's still a load of deprecation warnings, I'll solve those in another PR.

@kaedroho kaedroho modified the milestone: 1.0 Apr 4, 2015
@kaedroho
Copy link
Contributor Author

kaedroho commented Apr 4, 2015

Django taggit 0.13.0 released with my PR merged. Still waiting on django-modelcluster. This PR can be merged at any time though.

@kaedroho kaedroho force-pushed the dj18 branch 3 times, most recently from e9415c5 to ca993ee Compare April 9, 2015 15:09
@gasman
Copy link
Collaborator

gasman commented Apr 10, 2015

Have cherry-picked af5cbaa, 229a666, 775da10, c2456b6, fc374bc - please rebase.

Otherwise, Django sees it as unsaved and doesn't allow any foreign keys to point to it
@gasman
Copy link
Collaborator

gasman commented Apr 13, 2015

5f198fc, b43aff6, 55cd422, 4d8e31b all cherry-picked. 819b8cc rejected, because we're not yet ready to add 1.8 to the 'include' list (the RoutablePage failures are still outstanding as of this PR). Remaining commits to be addressed in a separate PR which I'll open shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants