首页 \ 问答 \ drupal dev / stage / production setup(drupal dev / stage / production setup)

drupal dev / stage / production setup(drupal dev / stage / production setup)

嘿,我开始在drupal6开发新网站,我想知道什么是设置dev / stage / production环境的最好方法... svn? 在线付费服务(我看到serval灵魂网站需要付费做东西)bash脚本同步? 请帮忙


hey, i started to develop new site in drupal6 and i wonder what is the best way to set it up for dev/stage/production enviorment... svn? online paid service (i saw serval soultions sites that need to pay to do stuff) bash script for sync? please help


原文:https://stackoverflow.com/questions/4883499
更新时间:2022-02-11 11:02

最满意答案

您是否已在INSTALLED_APPS下的settings.py中注册了应用“列表”?
还可以尝试使用迁移模型
python manage.py migrate
这种方法似乎是正确的,它是您使用csv模块的标准方法。

您可以使用追溯编辑问题,以便详细了解您的问题。


First, load your django settings in a similar manner as in your manage.py file. In this scenario, "lists" is the project name, and "movies" is the app name.

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lists.settings")

import csv
from django.db import models
from movies.models import Movie
from sys import argv

script, filename = argv

with open(filename) as csvfile:
    reader = csv.reader(csvfile)
    for row in reader:
        print (row)
        # _, created = Movie.title.get_or_create(
        #     title=row[0],
        #     )

Lastly, make sure to place the script in the project's root directory.

相关问答

更多
  • 删除Theme的导入,并使用模型名称作为字符串。 theme = models.ForeignKey('themes.Theme') Remove the import of Theme and use the model name as a string instead. theme = models.ForeignKey('themes.Theme')
  • 您需要首先设置django环境: from your_project import settings from django.core.management import setup_environ setup_environ(settings) 最后导入你的模型,一切都像django一样。 You need to setup django environment first: from your_project import settings from django.core.management im ...
  • from django.contrib.auth.models import User 你错过了模型 - 用户被大写。 如果您使用自定义用户模型,您应该使用: from django.contrib.auth import get_user_model User = get_user_model() 更多的细节可以在文档中找到。 改为Django 1.11: 在导入时调用get_user_model()的能力已被添加。 from django.contrib.auth.models import Use ...
  • 你必须首先from django.conf import settings 。 之后,您可以导入模型并像平常一样使用它们。 You have to do from django.conf import settings first. After that you can import your models and work with them like usually.
  • 您是否已在INSTALLED_APPS下的settings.py中注册了应用“列表”? 还可以尝试使用迁移模型 python manage.py migrate 这种方法似乎是正确的,它是您使用csv模块的标准方法。 您可以使用追溯编辑问题,以便详细了解您的问题。 First, load your django settings in a similar manner as in your manage.py file. In this scenario, "lists" is the project na ...
  • 如果你仔细阅读了ForeignKey文档 ,你会发现第一个参数可以是一个字符串。 这允许您创建外键而无需导入,解决循环引用问题。 所以你的模型会变成: class Action_Tracker(models.Model): dateOfAction = models.DateField(verbose_name = 'Date of Action') user = models.CharField(max_length=30, verbose_name = 'Action completed ...
  • 好吧,看起来你的模块安排得很奇怪,所以你需要在sys.paths中添加更多的路径。 sys.path.append('/tools/envs/networktools/nettools/scripts/python/') 这一切都取决于你从哪个目录开始翻译。 我假设您正在从我正在添加到上面的sys.path的python目录中打开IDE中的解释器,这将把pingsweep模块直接放在您的路径上。 您的脚本是从nettools目录开始的。 如果你想从那里访问pingsweep ,你需要说: from scr ...
  • 如果它很简单,只需按照此示例读取CSV行: http://docs.python.org/2/library/csv.html 并在每个循环构建您的模型并保存它。 这是做你想做的最快最简单的方法。 大约10行,不使用任何花哨的库。 不需要过度思考它。 If it's simple, just follow this example for reading lines of CSV: http://docs.python.org/2/library/csv.html And on each loop cons ...
  • Django不会识别那些模板标签,因为大括号和百分比之间有空格。 所以,根本没有循环。 您需要以正确的格式编写它们: {% for spot in spots %} ... {% endfor %} 一旦你这样做,你将开始得到各种JS语法错误,因为你没有用引号包装任何数据。 但是,正如评论所说,这样做JSON会好得多。 Django will not recognize those template tags because you have spaces between the brace and ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)