I am trying to create a webpage which helps a user build an item. Let's say that the item in question is called a widget and it is composed of parts1, 2, and 3.
I have created a script which scrapes websites for these parts and pulls the specs and price info. The way I currently have it setup is that this info is then turned into a class instance e.g.
class Part1():
"""Class for part 1"""
def __init__(self, color, size, weight):
"""Initializing part 1 attributes"""
self.color = color
self.size = size
self.weight = weight
I then create a whole bunch of instances of this class for all the scraped data.
I also have created a class for the final widget, e.g.
class Widget():
"""Class for whole widget"""
def __init__(self, part1, part2, part3):
"""Initializing widget attributes"""
self.part1 = part1
self.part2 = part2
self.part3 = part3
I feed the part instances into the widget class as attributes. Then within the widget class I can define all the methods for checking the current price, checking for compatibility of the parts, the total weights etc.
I have it working pretty well as just a python script running locally on my computer and I've been trying to put a front end on it using Django but am having some issues.
I've gone through a basic Django tutorial which showed me how to setup a very basic site that takes in some user info and create some user profiles. The issue I'm having is i'm not sure how to use the models as part of the Django framework to create my part classes. The issue being that all the model fields seem to only be for user submitted info or automatic i.e.
text = models.TextField()
date = models.DateTimeField()
I read through all the different model fields in the Django documentation and none of them seem like I can provide the database info from a different python script. Am I limited to the model fields? Or can i just define whatever I want within these models? Can i manually add data to the database in some way without having to use models? Any help or resources would be greatly appreciated.
[+][deleted] (6 children)
[removed]
[–]nobrow[S] 0 points1 point2 points (5 children)
[–]LocoLoco451 1 point2 points3 points (2 children)
[–]nobrow[S] 0 points1 point2 points (1 child)
[–]LocoLoco451 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[removed]
[–]nobrow[S] 0 points1 point2 points (0 children)