Django&angularjs的最佳项目结构

2024-04-24 15:53:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我为自己创建了一个相当大的Django项目,并希望在前端实现AngularJS,在后端实现一些rest框架。我知道这个项目将实现至少7-8个我自己的应用程序(我认为django应用程序应该很小,只负责一个功能)。在

我以前从未使用过AngularJS,但我想创建一个好的架构。 所以一个django应用程序应该有一个角度应用程序?在

| - Django project
|--- app1
|------ angular_app1
|---------angular controller1
|---------angular controller2
|--- app2
|------ angular_app2
|---------angular controller1
|---------angular controller2

或者我应该有一个全局角度应用程序为整个项目和单个django应用程序应该注册他们的控制器在视图中?我认为当我们想使用其他应用程序的模块时,它是有用的。在

^{pr2}$

或者我还是错了?在


Tags: 项目django功能框架rest应用程序架构角度
2条回答

实际上,我最近使用Django和AngularJS构建了一个巨大的应用程序。在

剩下的服务我用DRF。通过架构,我决定在Django本身的上下文中为ango服务。所以我的项目结构如下所示

| - Django project
     DjangoApp1
     DjangoApp2
     DjangoSettingsDir
     static
         assets/
             JS/
                  controllers/
             partials/
     templates //base Django templates
          index.html

/使用简单的Djangorender服务于index.html。在index.html中使用Angular、UI Router、UI引导等来构建应用程序。在

`| - Django project
 DjangoApp1
 DjangoApp2
 DjangoSettingsDir
 static
     bower_component/
         all Javascript Library/
     node_build
         all node files or npm files(if required)
     templates
         all custom HTML files
     JavaScript
         all custom JavaScript files
     Style
         all custom CSS files goes here
 templates //base Django templates
      index.html`
      index.js
      index.css

相关问题 更多 >