Skip to content

Compatibility with Django >2 #27

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wordpress/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.0"
__version__ = "0.11.1rc"
27 changes: 13 additions & 14 deletions wordpress/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.urls import reverse


STATUS_CHOICES = (
Expand Down Expand Up @@ -153,7 +154,7 @@ class UserMeta(WordPressModel):
"""

id = models.IntegerField(db_column='umeta_id', primary_key=True)
user = models.ForeignKey(User, related_name="meta", db_column='user_id')
user = models.ForeignKey(User, related_name="meta", db_column='user_id', on_delete=models.PROTECT)
key = models.CharField(max_length=255, db_column='meta_key')
value = models.TextField(db_column='meta_value')

Expand All @@ -178,7 +179,7 @@ class Link(WordPressModel):
# category_id = models.IntegerField(default=0, db_column='link_category')
description = models.CharField(max_length=255, db_column='link_description')
visible = models.CharField(max_length=20, db_column='link_visible')
owner = models.ForeignKey(User, related_name='links', db_column='link_owner')
owner = models.ForeignKey(User, related_name='links', db_column='link_owner', on_delete=models.PROTECT)
rating = models.IntegerField(default=0, db_column='link_rating')
updated = models.DateTimeField(blank=True, null=True, db_column='link_updated')
rel = models.CharField(max_length=255, db_column='link_rel')
Expand Down Expand Up @@ -249,8 +250,8 @@ def from_path(self, path):

class TermTaxonomyRelationship(WordPressModel):

object = models.ForeignKey('Post')
term_taxonomy = models.ForeignKey('Taxonomy', related_name='relationships', db_column='term_taxonomy_id')
object = models.ForeignKey('Post', on_delete=models.PROTECT)
term_taxonomy = models.ForeignKey('Taxonomy', related_name='relationships', db_column='term_taxonomy_id', on_delete=models.PROTECT)
order = models.IntegerField(db_column='term_order')

class Meta:
Expand All @@ -275,7 +276,7 @@ class Post(WordPressModel):
status = models.CharField(max_length=20, db_column='post_status', choices=POST_STATUS_CHOICES)
title = models.TextField(db_column='post_title')
slug = models.SlugField(max_length=200, db_column="post_name")
author = models.ForeignKey(User, related_name='posts', db_column='post_author')
author = models.ForeignKey(User, related_name='posts', db_column='post_author', on_delete=models.PROTECT)
excerpt = models.TextField(db_column='post_excerpt')
content = models.TextField(db_column='post_content')
content_filtered = models.TextField(db_column='post_content_filtered')
Expand All @@ -297,7 +298,7 @@ class Post(WordPressModel):

# other various lame fields
parent_id = models.IntegerField(default=0, db_column="post_parent")
# parent = models.ForeignKey('self', related_name="children", db_column="post_parent", blank=True, null=True)
# parent = models.ForeignKey('self', related_name="children", db_column="post_parent", blank=True, null=True, on_delete=models.PROTECT)
menu_order = models.IntegerField(default=0)
mime_type = models.CharField(max_length=100, db_column='post_mime_type')

Expand All @@ -322,9 +323,8 @@ def save(self, **kwargs):
self.child_cache = None
self.term_cache = None

@models.permalink
def get_absolute_url(self):
return ('wp_object_detail', (
return reverse('wp_object_detail', args=(
self.post_date.year,
"%02i" % self.post_date.month,
"%02i" % self.post_date.day,
Expand Down Expand Up @@ -404,7 +404,7 @@ class PostMeta(WordPressModel):
"""

id = models.IntegerField(db_column='meta_id', primary_key=True)
post = models.ForeignKey(Post, related_name='meta', db_column='post_id')
post = models.ForeignKey(Post, related_name='meta', db_column='post_id', on_delete=models.PROTECT)
key = models.CharField(max_length=255, db_column='meta_key')
value = models.TextField(db_column='meta_value')

Expand All @@ -422,9 +422,9 @@ class Comment(WordPressModel):
"""

id = models.IntegerField(db_column='comment_id', primary_key=True)
post = models.ForeignKey(Post, related_name="comments", db_column="comment_post_id")
post = models.ForeignKey(Post, related_name="comments", db_column="comment_post_id", on_delete=models.PROTECT)
user_id = models.IntegerField(db_column='user_id', default=0)
#user = models.ForeignKey(User, related_name="comments", blank=True, null=True, default=0 )
#user = models.ForeignKey(User, related_name="comments", blank=True, null=True, default=0 , on_delete=models.PROTECT)
parent_id = models.IntegerField(default=0, db_column='comment_parent')

# author fields
Expand Down Expand Up @@ -484,15 +484,14 @@ class Meta:
def __unicode__(self):
return self.name

@models.permalink
def get_absolute_url(self):
return ('wp_archive_term', (self.slug, ))
return reverse('wp_archive_term', args=(self.slug, ))


class Taxonomy(WordPressModel):

id = models.IntegerField(db_column='term_taxonomy_id', primary_key=True)
term = models.ForeignKey(Term, related_name='taxonomies', blank=True, null=True)
term = models.ForeignKey(Term, related_name='taxonomies', blank=True, null=True, on_delete=models.PROTECT)
#term_id = models.IntegerField()
name = models.CharField(max_length=32, db_column='taxonomy')
description = models.TextField()
Expand Down