Skip to content

Commit

Permalink
1.fix import htmlparser error for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
WUJISHANXIA committed Oct 14, 2017
1 parent dd4bdba commit f45dcfe
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bootcamp/articles/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import unicode_literals

from HTMLParser import HTMLParser
import sys
from django.contrib.auth.models import User
from django.db import models
from autoslug import AutoSlugField
Expand All @@ -11,6 +11,14 @@
import markdown
from taggit.managers import TaggableManager

PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3

if PY3:
from html.parser import HTMLParser
else:
from HTMLParser import HTMLParser


@python_2_unicode_compatible
class Article(models.Model):
Expand Down Expand Up @@ -125,9 +133,6 @@ def __init__(self):
HTMLParser.__init__(self)
self.summary = ''

def feed(self, data):
HTMLParser.feed(self, data)

def handle_data(self, data):
if self.summary:
self.summary = ' '.join([self.summary, data])
Expand Down

0 comments on commit f45dcfe

Please sign in to comment.