This commit is contained in:
2019-03-11 06:30:58 -04:00
parent 68bdcf61d9
commit ee215ce59e
8 changed files with 233 additions and 4 deletions
+4
View File
@@ -1,3 +1,7 @@
from django.contrib import admin
# Register your models here.
from .models import Post
admin.site.register(Post)
+32
View File
@@ -0,0 +1,32 @@
from django.core.management.base import BaseCommand, CommandError
from core.models import Post
from requests_html import HTMLSession
requests_html = HTMLSession()
def get_hn(filter="py"):
r = requests_html.get('https://news.ycombinator.com/')
pass
def get_reddit():
pass
class Command(BaseCommand):
help = 'Import content from known sites.'
def add_arguments(self, parser):
parser.add_argument('--hn', action='store_true')
parser.add_argument('--reddit', action='store_true')
# parser.add_argument('--pycoders', action='store_true')
def handle(self, *args, **options):
if options['hn']:
get_hn()
if options['reddit']:
get_reddit()
+1 -2
View File
@@ -7,8 +7,7 @@ from taggit.managers import TaggableManager
class Post(models.Model):
title = models.TextField()
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)
timestamp = models.DateTimeField(default=timezone.now)
tags = TaggableManager()
def __unicode__(self):