django 新应用_新的Django网站

django 新应用

After a series of Django gigs in 2014, I had the urge to redevelop our company website in Django; I am very happy with the results.

在2014年进行了一系列Django演出后,我渴望用Django重新开发我们的公司网站; 我对结果感到非常满意。

This overview is roughly in order of development from start to finish. And since I am a “packaging guy”, I will take this opportunity to comment on miscellaneous packaging issues too*.

此概述大致是从头到尾的开发顺序。 由于我是一名“包装专家”,因此我也将借此机会就其他包装问题发表评论*。

Website front page

相同主题,不同后端 (Same theme, different backend)

The Pyramid version of aclark.net was almost two years old and needed an overhaul. Django appeared attractive because:

aclark.net的金字塔版本已有近两年的历史,需要大修。 Django之所以吸引人是因为:

  • I know Django, but I don’t know enough Django. Like with Pyramid and Plone before, I learned a lot of Django while developing this site over the last few weeks.
  • There was no “content” with the previous (Pyramid) site. The idea of putting my “content” in Django models was appealing to me.
  • The new Django project website is awesome! An awesome website makes me want to build another awesome website with an awesome web framework. Awesome.
  • 我了解Django,但我对Django的了解不够。 像以前使用Pyramid和Plone一样,在过去几周的开发过程中,我学到了很多Django。
  • 以前的(金字塔)网站没有“内容”。 将我的“内容”放入Django模型的想法吸引了我。
  • 新的Django项目网站很棒! 一个很棒的网站使我想用一个很棒的Web框架来构建另一个很棒的网站。 太棒了

我讨厌代码生成器 (I hate code generators)

I typically hate using code generators, full stop. But somehow Django’s startproject and startapp don’t make me want to vomit. So I used them in an organic [1] way, to make some obnoxiously long package names, and I miraculously don’t hate the results! This can only mean:

我通常讨厌使用代码生成器,句号停止。 但是以某种方式,Django的startprojectstartapp并不需要我呕吐。 因此,我以自然的[1]方式使用了它们,使它们成为了一些令人讨厌的长包名 ,而我奇迹般地不讨厌结果! 这只能表示:

  • I am more tolerant of boilerplate code when learning a new framework, and/or:
  • The process of creating the boilerplate code and the resulting boilerplate are so elegant/minimalistic that my insatiable desire for elegance/minimalism is at least partially satisified.
  • 在学习新框架时,我更容忍样板代码,并且/或者:
  • 创建样板代码和生成的样板的过程是如此优雅/简约,以至于我对优雅/简约的无限满足至少部分得到了满足。

没有Postgres? 没问题 (No Postgres? No problem)

The idea of having to develop locally with Postgresql (or some other “real” database) feels “heavy” to me. With sqlite, I don’t have to worry about database setup until I’m ready to worry about database setup [2].

对我来说,不得不使用Postgresql(或其他“真正的”数据库)进行本地开发的想法让我感到“沉重”。 使用sqlite时,我不必担心数据库设置,直到我准备担心数据库设置[2]为止。

I even pushed to Heroku with the sqlite database checked in, until I was ready to deploy Postgres. And I still use sqlite locally.

我什至在签入sqlite数据库的情况下推送到Heroku,直到准备部署Postgres。 而且我仍然在本地使用sqlite。

引导所有东西 (Bootstrap all the things)

Sure Bootstrap is ubiquitious now, but it remains attractive nonetheless. One of the first tasks I performed was add django-admin-bootstrapped to my INSTALLED_APPS [3].

Sure Bootstrap现在无处不在,但仍然具有吸引力。 我执行的第一个任务之一是将django-admin-bootstrapped添加到我的INSTALLED_APPS [3]中

And because it’s 2015, I Bower-installed Bootstrap and Fontawesome for my theme development.

因为是2015年,所以我为自己的主题开发安装了Bower安装的Bootstrap和Fontawesome。

像一棵树和文件 (Make like a tree and file)

Lately I’ve gotten into the habit of using good-ol’ Make to automate various tasks [4]. This project was no exception:

最近,我养成了使用good-ol'Make自动执行各种任务的习惯[4] 。 这个项目也不例外:

dump:
    curl -o latest.dump `heroku pgbackups:url`
push:
    git push
    git push heroku master
sync:
    heroku run python aclarknet/manage.py syncdb
publish:
    git commit -a -m "Update"
dump:
    curl -o latest.dump `heroku pgbackups:url`
push:
    git push
    git push heroku master
sync:
    heroku run python aclarknet/manage.py syncdb
publish:
    git commit -a -m "Update"

附加组件,应用程序,鸡蛋,发行版,包装,产品,车轮 (Add-ons, Apps, Eggs, Distributions, Packages, Products, Wheels)

I am literally annoyed by the figurative abomination that is Python packaging terminology. The proliferation of terms is understandable though because of the many layers of technology, each with its own terminology, that may or may not overlap:

Python包装术语比喻性的可憎性确实使我感到恼火。 术语的泛滥是可以理解的,但是由于技术的各个层次,每个层次都有自己的术语,可能会重叠也可能不会重叠:

  • The Python language
  • Various packaging frameworks
  • Software written in Python
  • Python语言
  • 各种包装框架
  • 用Python编写的软件

And all of that was just so I could tell you I pip-installed the following:

而且,所有这些只是为了告诉您我点安装了以下内容:

Buildout,Conda,easy_install,pip (Buildout, Conda, easy_install, pip)

On a related subject, why do I have a setup.py? I get the feeling that Django projects in the wild sometimes have one and sometimes don’t. And the Django documentation has only a few mentions of setup.py. So why do I have one?

关于一个相关主题,为什么要有setup.py ? 我感觉到Django项目在野外有时会有一个,有时却没有。 而且Django文档仅提及setup.py 。 那我为什么要一个?

In short, because I want my code in sys.path. I have another feeling that when Django projects/apps/etc don’t have setup.py files, they are somehow manipulating sys.path manually to include themselves. There is slightly more mentioning of sys.path in Django’s documentation, at least.

简而言之,因为我希望我的代码在sys.path 。 我有另一种感觉,当Django项目/应用程序/ etc没有setup.py文件时,它们会以某种方式手动操作sys.path使其包含自身。 至少在Django文档中更多地提到了sys.path

Anyway, I use setup.py because I’m familiar with setuptools.

无论如何,我使用setup.py是因为我熟悉setuptools。

联系表 (Contact Form)

Enough packaging rants, back to the rest of the Django story.

足够的包装咆哮,回到Django故事的其余部分。

Every business website needs a contact form, right? And contact forms are tedious and boring to create, right? Yes and yes. That’s why I thought using django-contact-form would be a good idea. Unfortunately I ran into an issue I couldn’t easily work around, so I gave up and made my own [5].

每个企业网站都需要联系表格,对吗? 和联系表单创建起来很乏味和无聊,对吗? 是的,是的。 这就是为什么我认为使用django-contact-form是一个好主意。 不幸的是,我遇到了一个我无法轻易解决的问题,所以我放弃了, 做了自己的事情 [5]

ORM我真的是一个人吗? (ORM I really on my own?)

Tweet

That’s right. After adding an ImageField I expected the image to be stored in the database and not the file system, and I’m not ashamed. Since that was not the case, I ended up using django-cumulus [6].

那就对了。 添加ImageField我希望图像将存储在数据库中,而不是文件系统中,并且我不会感到羞耻。 由于不是这种情况,我最终使用了django-cumulus [6]

总体 (Overall)

Overall, this was a great experience. As such, I’m now considering another pythonpackages.com reboot with Django; to further exercise my Django chops and fullfill the packaging-automation-vision I’ve had since late 2011.

总的来说,这是一次很棒的经历。 因此,我现在考虑使用Django重新启动pythonpackages.com ; 进一步练习Django排行榜,并实现我自2011年底以来的包装自动化愿景。

Please let me know your reaction to my experiences in the comments.

请在评论中让我知道您对我的经历的React。

[1][1] django-admin django-admin startproject startproject aclarknet; aclarknet; cd cd aclarknet/aclarknet; aclarknet/aclarknet; django-admin django-admin startapp startapp aclarknetaclarknet
[2][2] actual burden of “real” database setup which is admittedly fairly trivial: 实际负担要差得多,后者被认为是相当琐碎的: brew install postgres.brew install postgres
[3][3] I also don’t like.我也不喜欢它
[4][4] s/    /t/ because my tabstop is set to 4 spaces. Maybe I should be change my tabstop setting each time?s/ /t/创建了选项卡,因为我的tabstop设置为4个空格。 也许我应该每次更改Tabstop设置?
[5][5] Something to do with Sendgrid integration, certainly not django-contact-form’s fault! 与Sendgrid集成有关,当然不是django-contact-form的错!
[6][6] Which is another story. First I tried django-storages only to discover Rackspace Cloud Files support moved to cumulus (or started in cumulus and moved back?) Then django-cumulus almost worked but not quite. Rackspace Cloud Files returned a URL but upload failed. So I manually uploaded all the files to Rackspace Cloud Files as a workaround. 这是另一个故事。 首先,我尝试使用django-storages只是发现对Rackspace Cloud Files的支持转移到了cumulus(或开始于cumulus,然后又移回了?),然后django-cumulus 几乎起作用了,但效果不佳。 Rackspace Cloud Files返回了URL,但上传失败。 因此,我作为解决方法将所有文件手动上传到Rackspace Cloud Files。

翻译自: https://www.pybloggers.com/2015/01/new-django-website/

django 新应用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值