django& amp;的最佳项目结构angularjs

时间:2015-07-18 09:42:43

标签: python angularjs django

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

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

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

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

| - Django project
|--- angular app
|--- app1
|-------angular controller1
|-------angular controller2
|--- app2
|-------angular controller3
|-------angular controller4

或许我还是错了?

2 个答案:

答案 0 :(得分:5)

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

我将DRF用于其他服务。通过这个架构,我决定在Django本身的环境中为Angular服务。所以我的项目结构如下所示

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

使用简单的Django index.html/处为render提供服务。在index.html中使用Angular,UI路由器,UI Bootstrap等来构建应用程序。

答案 1 :(得分:0)

`| - 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