我正在尝试使用Django构建一个静态站点生成器(因为它的资源丰富),而现在我的问题是处理Django命令,该命令应该将我的静态站点内容构建到目录中.显然我的'NoneType'对象没有属性'split',但我不知道'NoneType'对象是什么.
(thisSite) C:\Users\Jaysp_000\thisSite\PROJECTx>python prototype.py build
Traceback (most recent call last):
File "prototype.py", line 31, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\management\__init__.py",
line 338, in execute_from_command_line
utility.execute()
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\management\__init__.py",
line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\management\base.py", lin
e 390, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\core\management\base.py", lin
e 441, in execute
output = self.handle(*args, **options)
File "C:\Users\Jaysp_000\thisSite\PROJECTx\sitebuilder\management\commands\build.py", li
ne 38, in handle
response = this_client_will.get(the_page_url)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\test\client.py", line 500, in
get
**extra)
File "C:\Users\Jaysp_000\thisSite\lib\site-packages\django\test\client.py", line 303, in
get
return self.generic('GET', path, secure=secure, **r)
File …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Pycharm 社区版来改进我的 Django 应用程序中的代码,但我无法运行我想要的所有 Django 代码。我不断收到此回溯...
Traceback (most recent call last):
File "C:/Users/Jaysp_000/firstSite/PROJECTone/blog_static/views.py", line 1, in <module>
from django.views.decorators.csrf import csrf_exempt
File "C:\Python34\lib\site-packages\django\views\decorators\csrf.py", line 3, in <module>
from django.middleware.csrf import CsrfViewMiddleware, get_token
File "C:\Python34\lib\site-packages\django\middleware\csrf.py", line 14, in <module>
from django.utils.cache import patch_vary_headers
File "C:\Python34\lib\site-packages\django\utils\cache.py", line 26, in <module>
from django.core.cache import caches
File "C:\Python34\lib\site-packages\django\core\cache\__init__.py", line 34, in <module>
if DEFAULT_CACHE_ALIAS not in settings.CACHES:
File "C:\Python34\lib\site-packages\django\conf\__init__.py", line 48, in __getattr__
self._setup(name)
File "C:\Python34\lib\site-packages\django\conf\__init__.py", line 42, in _setup
% (desc, ENVIRONMENT_VARIABLE)) …Run Code Online (Sandbox Code Playgroud) 我不知道我是否混淆了目的collectstatic.这是我的设置模块:
# BASE_DIR is the location of my django project folder
STATIC_URL = '/this.static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "ve_static_root")
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "this.static"),
os.path.join(BASE_DIR, "this.media"),
)
MEDIA_URL = '/this.media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "ve_media_root")
Run Code Online (Sandbox Code Playgroud)
在这里,我放置了我的静态文件和媒体文件,STATICFILES_DIRS以便在我回忆/将图像嵌入到我的降价文档中时,可以使用媒体文件作为简单参考,但正如您所看到的,我为MEDIA_ROOT创建了一条路径,这需要与STATIC_ROOT不同.我担心的是,我把我的媒体文件夹,this.media中,在STATICFILES_DIRS文件夹中,这让我打电话给图像或视频到Django的使用这些staticfile过滤模板,像{% static 'image/file/path/here' %}.尽管如此,我还想知道如果所有文件,图像/视频和网页设计文件都进入STATIC_ROOT,MEDIA_ROOT的重点是什么?据我所知,Django没有collectmedia命令,所以我真的没有任何东西收集到MEDIA_ROOT文件夹中.我只是把它拿出来,空虚和所有.
我错过了这个吗?任何人都了解Django对此的看法?你的观点是什么?我不确定是否collectstatic应该涉及收集媒体文件,特别是当我有MEDIA_ROOT时.我查看了静态文件的文档,它们对于媒体文件确实不是很有帮助.
我正在尝试使用 ggplot 在我用颜色编码的从 0 到 4 的因子类型向量上呈现一个地图。该向量位于我命名的数据框中spat.dataframe,向量为qt。
# plot
ggplot(spat.dataframe, aes(long,lat,group=group)) + # the data
geom_polygon(aes(fill=as.factor(qt))) + # make polygons
scale_fill_manual(values = c("0"="#F0F0F0","1"="green","2"="red","3"="blue","4"="purple"),
labels = c(paste0("white (",length(spat.dataframe[spat.dataframe$qt==0,]),")"),
paste0("green (",length(spat.dataframe[spat.dataframe$qt==1,]),")"),
paste0("red (",length(spat.dataframe[spat.dataframe$qt==2,]),")"),
paste0("blue (",length(spat.dataframe[spat.dataframe$qt==3,]),")"),
paste0("pink (",length(spat.dataframe[spat.dataframe$qt==4,]),")")),
drop=F,
name=NULL) +
theme(line = element_blank(), # remove the background, tickmarks, etc
axis.text = element_blank(),
axis.title = element_blank(),
panel.background = element_blank()) +
ggtitle(title) +
geom_path( colour = "#6b6b6b", size = .5 ) +
coord_equal()
Run Code Online (Sandbox Code Playgroud)
我的问题在于图例部分,因为我想要做的是显示所有图例选项,即使矢量中没有列出任何图例选项。所以颜色值也是蓝色和紫色的。尝试起来可能有点困难,但我希望它出现在我的图形上,以便我还可以显示可能的值的数量以及与该值关联的多边形的数量。因此,对于我的向量 中的值 3 和 4 …
django ×3
python-3.x ×2
django-views ×1
ggplot2 ×1
pycharm ×1
python ×1
r ×1
spatial ×1
static-site ×1