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
最满意答案
您是否已在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.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
删除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脚本访问模型对象而不使用manage.py shell(Django script to access model objects without using manage.py shell)[2023-03-24]
您需要首先设置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 ...
-
Django / Python无法从脚本导入模块,但可以从IDE导入(Django/Python cannot import module from script, but can import from IDE)[2023-10-29]
好吧,看起来你的模块安排得很奇怪,所以你需要在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 ...