Python Forum
[Help] Keep getting a 'TypeError' from Django and BeautifulSoup
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Help] Keep getting a 'TypeError' from Django and BeautifulSoup
#7
Okay, so I've written a script that grabs the BBC navigation headers and saves them into a CSV. I was thinking from that I can write them into a database but maybe I have to do that from an outside process. ie, write a new file outside of models.py and reference it...

That is to say write write my model elements so

models.py
class BBCHEaders(models.Model):
   nBBC = models.CharField(max_length=200)
And then have a new module something like:

storedNav.py
from .models import BBCHeaders.nBBC

def writeBBC
    with open('C:\\...app\\Headings\\BBCHeadings.csv') as f:
        freader = csv.DictReader(f, delimiter=',')
            for r in freader:
                nBBC.create(r['Heading'])
I am wondering if this would write to the nBBC model database and then I can refer to it with the views.py.

views.py
from .storedNav import writeBBC
from .models import BBCHeaders

class BBCView(generic.ListView):
    writeBBC()
    model = BBCHeaders
    template_name = 'news/BBCNews.html'
Reply


Messages In This Thread
RE: [Help] Keep getting a 'TypeError' from Django and BeautifulSoup - by Plant_Boy - Jun-13-2018, 10:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: missing 1 required positional argument (word counter Django app) Drone4four 2 14,656 Jul-11-2019, 09:34 PM
Last Post: Drone4four
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,362 Jun-30-2019, 12:21 AM
Last Post: scidam
  [split] [Help] Keep getting a 'TypeError' from Django and BeautifulSoup moxasya 0 2,195 Nov-15-2018, 07:38 AM
Last Post: moxasya
  How to create dynamic webscraper in Django using BeautifulSoup Prince_Bhatia 1 6,189 Jan-26-2018, 02:07 PM
Last Post: frostbite

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020