django - 从 Django 1.4 升级到 Django 1.7 - 可以吗?

标签 django django-1.7

我有一个在过去几年中构建的项目,它是在 Django 1.4 中启动的。运行该项目的服务器即将更换,因此我正在迁移到新服务器。

我正在考虑借此机会将项目升级到 Django 1.7。我一直在查看注释,并且我知道我需要做一些关于 url 标记和其他一些事情的工作。但是,看起来项目的主要结构已经改变了。在我的项目中,settings.pystatic 文件夹和项目范围内的 urls.py 文件/文件夹都在项目的根目录中.然而,在 1.7(可能还有几个更早的版本)中,这些文件/文件夹似乎被移动到主项目中的应用程序文件夹中。

比如我的1.4项目的项目结构为:

project folder:
    - urls.py # all other app urls.py files are included in this main urls file
    - static # all static files for the whole project reside here
    - settings.py # project settings
    ./app:
        - urls.py #app specific urls

但是现在,默认的项目结构似乎已经变成了这样:

project folder:
    - # there's nothing here other than the "manage" script
    ./project:
        - # an 'app' with the same name as the project now holds project wide files
        - urls.py # project wide urls file?
        - settings.py # project wide settings? within this app folder?
        - static # project wide static files to be held here? 

那么,鉴于新的项目结构,我什至能够在 1.7 中运行我的项目吗?

最佳答案

您可以在 Django 中拥有您想要的任何项目结构。因此,您将能够运行您的项目,除非出现任何其他升级问题。当前最好的项目结构示例之一是 Django Cookiecutter。由 PyDanny 提供。

除了抽象用户类、身份验证和迁移(以及诸如 syncdb/schemamigration 之类的命令)之外,没有什么能真正阻碍您的升级。有些东西已经折旧,但它们有据可查且易于修复。在每个版本中,他们都确保升级路径和向后兼容性清晰且尽可能好。

我建议遵循 1.5、1.6 和 1.7 的最佳实践,它们改变了社区编写 Django 应用程序的方式。我最喜欢的了解它们的资源是 Two Scoops of Django . PyDanny 是作者之一。有两个版本,分别是 1.5 和 1.6,每个版本都介绍了以前版本之间的主要区别以及新功能如何改变了您编写 Django 应用程序的方式。通过阅读这两篇文章,您可以清楚地了解如何将您的应用程序从 1.4 升级到 1.5 再到 1.6。除此之外,每个版本的发行说明和 django-cookiecutter 都是查看更改内容和新最佳实践的好地方。

关于django - 从 Django 1.4 升级到 Django 1.7 - 可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27648751/

相关文章:

python - django rest 框架嵌套模型序列化器

pillow - 解码器 jpeg 不可用 mac osx

python - Django 1.7 : Passing around unsaved instances throws "unhashable" exception

django - 在 grappelli admin 上添加指向主页的链接

python - "DRF Throttling"和 "Django Axes"有什么不同

django - 处理 Django 用户订阅到期日期

python - django 形式 __init__ 不包括字段

django - 如何从 Apache 读取环境变量从 Django 1.6.5 更新到 1.7

python - Django:异常值(2013, '2013: Lost connection to MySQL server during query',无)

python - Django:基于 'as_view()' 方法的通用 View