简体   繁体   English

无需在数据库中存储数据的Django项目

[英]Django project without storing data in database

I wrote a script to collect some informations about products offerred by few eShops. 我写了一个脚本来收集一些eShop提供的产品信息。 This script runs once an hour and collects data to csv file. 该脚本每小时运行一次,并将数据收集到csv文件中。 File is overwritten everytime so it contains currently offered products only. 文件每次都会被覆盖,因此仅包含当前提供的产品。 Csv file contains fields - shop name, price, vendor, description, size, picture URL, product page URL and looks like this (just two lines of about 1500 lines) CSV文件包含字段-商店名称,价格,供应商,描述,大小,图片URL,产品页面URL,看起来像这样(仅两行,约1500行)

sklep-presto.pl, 149.90, real, Deck Davis Northern Light 8,38 Real, 8.38, https://www.sklep-presto.pl/pol_il_Deck-Davis-Northern-Light-8-38-Real-59111.jpg, https://www.sklep-presto.pl/product-pol-59111-Deck-Davis-Northern-Light-8-38-Real.html
sklep-presto.pl, 169.90, real, Deck Embossed Elite Ferguson 8,5 Real, 8.5, https://www.sklep-presto.pl/pol_il_Deck-Embossed-Elite-Ferguson-8-5-Real-56151.jpg, https://www.sklep-presto.pl/product-pol-56151-Deck-Embossed-Elite-Ferguson-8-5-Real.html

This script is also generating dictionary csv files - price, vendor, size. 该脚本还生成字典csv文件-价格,供应商,大小。 These files contain unique values from particular field form main csv file. 这些文件包含来自特定字段形式的主csv文件的唯一值。 For example vendor dictionary loks like this 例如像这样的供应商字典

almost,blind,chocolate,deathwish,foundation,goodwood,machine,real,zero
3,3,4,2,3,2,2,9,7

It contains vendor names and occurence count (in main csv). 它包含供应商名称和发生次数(在主csv中)。

I would like to make a web page using django but I have never been using django. 我想使用django制作网页,但是我从未使用过django。

I would like to make a web page that will present 5 choice lists and search button on top. 我想制作一个网页,上面会显示5个选择列表和搜索按钮。 Choice lists will be vendor, from price, to price, from size, to size. 选择列表将是供应商,从价格到价格,从大小到大小。 I would like possible choices to be imported (from csv files) to these choise lists on web page every time the page is loaded. 我希望每次加载页面时(从csv文件)将可能的选择导入到网页上的这些选择列表中。

I don't need to store anything in database because I want to use only current values that are stored in my csv files. 我不需要在数据库中存储任何内容,因为我只想使用存储在csv文件中的当前值。 Do I have to make djagno model and store data in database? 是否需要制作djagno模型并将数据存储在数据库中?

After search button is pressed I would like chosen values to be passed to my another script that will search the main csv against sarch criteria. 按下搜索按钮后,我希望将选定的值传递给另一个脚本,该脚本将根据sarch标准搜索主csv。 Of course this script has to be started after search button is pressed. 当然,必须在按下搜索按钮后启动此脚本。 This script returns may return saerch results line by line or as a list of lists. 此脚本返回的内容可能会逐行或以列表列表的形式返回saerch结果。

I would like the search results to be displayed as tiles on web page. 我希望搜索结果在网页上显示为图块。 Every tile shoud present as picture and same text values below (name, price, etc.). 每个图块均应以图片形式显示,并在下面显示相同的文本值(名称,价格等)。 Tiles should be aligned in columns and rows (20 products per web page). 磁贴应按列和行对齐(每个网页20个产品)。

I don't need to store search results in database because I want to use only current values that are passed from my search engine. 我不需要将搜索结果存储在数据库中,因为我只想使用从搜索引擎传递来的当前值。 Do I have to make djagno model and store data in database? 是否需要制作djagno模型并将数据存储在数据库中?

Can you point me similar porject that I can review to realize how I should do this? 您能否指出我可以回顾的类似内容,以实现该如何做?

Do I have to make djagno model and store data in database? 是否需要制作djagno模型并将数据存储在数据库中?

No. 没有。

Can you point me similar porject that I can review to realize how I should do this? 您能否指出我可以回顾的类似内容,以实现该如何做?

You want a basic Django setup with one view, template and form. 您需要具有一个视图,模板和表单的基本Django设置。 Django tutorial project should be a good place to start. Django教程项目应该是一个很好的起点。

From the documentation: 从文档中:

https://docs.djangoproject.com/en/1.10/topics/db/models/#abstract-base-classes https://docs.djangoproject.com/en/1.10/topics/db/models/#abstract-base-classes

If you don't want your model to create database tables you put abstract=True in the Meta class 如果您不希望模型创建数据库表,则可以在Meta类中放置abstract=True

from django.db import models

class CommonInfo(models.Model):
    name = models.CharField(max_length=100)
    age = models.PositiveIntegerField()

    class Meta:
        abstract = True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM