久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      • <bdo id='FXdlz'></bdo><ul id='FXdlz'></ul>
      <i id='FXdlz'><tr id='FXdlz'><dt id='FXdlz'><q id='FXdlz'><span id='FXdlz'><b id='FXdlz'><form id='FXdlz'><ins id='FXdlz'></ins><ul id='FXdlz'></ul><sub id='FXdlz'></sub></form><legend id='FXdlz'></legend><bdo id='FXdlz'><pre id='FXdlz'><center id='FXdlz'></center></pre></bdo></b><th id='FXdlz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FXdlz'><tfoot id='FXdlz'></tfoot><dl id='FXdlz'><fieldset id='FXdlz'></fieldset></dl></div>
    1. <small id='FXdlz'></small><noframes id='FXdlz'>

    2. <legend id='FXdlz'><style id='FXdlz'><dir id='FXdlz'><q id='FXdlz'></q></dir></style></legend><tfoot id='FXdlz'></tfoot>

      Django:“項目"與“應(yīng)用程序"相比

      Django: quot;projectsquot; vs quot;appsquot;(Django:“項目與“應(yīng)用程序相比)

      <small id='1rUg2'></small><noframes id='1rUg2'>

    3. <legend id='1rUg2'><style id='1rUg2'><dir id='1rUg2'><q id='1rUg2'></q></dir></style></legend>

        <tbody id='1rUg2'></tbody>

            • <bdo id='1rUg2'></bdo><ul id='1rUg2'></ul>

                <i id='1rUg2'><tr id='1rUg2'><dt id='1rUg2'><q id='1rUg2'><span id='1rUg2'><b id='1rUg2'><form id='1rUg2'><ins id='1rUg2'></ins><ul id='1rUg2'></ul><sub id='1rUg2'></sub></form><legend id='1rUg2'></legend><bdo id='1rUg2'><pre id='1rUg2'><center id='1rUg2'></center></pre></bdo></b><th id='1rUg2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1rUg2'><tfoot id='1rUg2'></tfoot><dl id='1rUg2'><fieldset id='1rUg2'></fieldset></dl></div>

                <tfoot id='1rUg2'></tfoot>
                本文介紹了Django:“項目"與“應(yīng)用程序"相比的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我準(zhǔn)備使用 Django 構(gòu)建一個相當(dāng)復(fù)雜的產(chǎn)品".我將避免在這種情況下使用術(shù)語項目"和應(yīng)用程序",因為我不清楚它們在 Django 中的具體含義.

                I have a fairly complex "product" I'm getting ready to build using Django. I'm going to avoid using the terms "project" and "application" in this context, because I'm not clear on their specific meaning in Django.

                項目可以有許多應(yīng)用程序.應(yīng)用程序可以在許多項目之間共享.很好.

                Projects can have many apps. Apps can be shared among many projects. Fine.

                我沒有重新發(fā)明博客或論壇 - 我看不到我的產(chǎn)品的任何部分在任何情況下都可以重復(fù)使用.直觀地說,我將其稱為應(yīng)用程序".然后我是否在一個app"文件夾中完成所有工作?

                I'm not reinventing the blog or forum - I don't see any portion of my product being reusable in any context. Intuitively, I would call this one "application." Do I then do all my work in a single "app" folder?

                如果是這樣...就 Django 的 project.app 命名空間而言,我傾向于使用 myproduct.myproduct,但當(dāng)然這是不允許的(但我正在構(gòu)建的應(yīng)用程序是我的項目,我的項目是一個應(yīng)用程序!).因此,我相信也許我應(yīng)該通過為每個重要"模型構(gòu)建一個應(yīng)用程序來接近 Django,但我不知道在我的架構(gòu)中在哪里繪制邊界以將其分成應(yīng)用程序 - 我有很多具有相對復(fù)雜關(guān)系的模型.

                If so... in terms of Django's project.app namespace, my inclination is to use myproduct.myproduct, but of course this isn't allowed (but the application I'm building is my project, and my project is an application!). I'm therefore lead to believe that perhaps I'm supposed to approach Django by building one app per "significant" model, but I don't know where to draw the boundaries in my schema to separate it into apps - I have a lot of models with relatively complex relationships.

                我希望有一個通用的解決方案...

                I'm hoping there's a common solution to this...

                推薦答案

                是什么阻止了你使用 myproduct.myproduct?你需要做的大致包括這樣做:

                What is to stop you using myproduct.myproduct? What you need to achieve that roughly consists of doing this:

                django-admin.py startproject myproduct
                cd myproduct
                mkdir myproduct
                touch myproduct/__init__.py
                touch myproduct/models.py
                touch myproduct/views.py
                

                等等.如果我說 views.py 不必被稱為 views.py 會有幫助嗎?如果您可以在 python 路徑上命名一個函數(shù)(通常是 package.package.views.function_name),它將被處理.就那么簡單.所有這些項目"/應(yīng)用程序"的東西都只是 python 包.

                and so on. Would it help if I said views.py doesn't have to be called views.py? Provided you can name, on the python path, a function (usually package.package.views.function_name) it will get handled. Simple as that. All this "project"/"app" stuff is just python packages.

                現(xiàn)在,你應(yīng)該怎么做?或者更確切地說,我該怎么做?好吧,如果你創(chuàng)建了一個重要的可重用功能,比如標(biāo)記編輯器,那就是當(dāng)你創(chuàng)建一個頂級應(yīng)用程序"時,它可能包含 widgets.py、fields.pycontext_processors.py 等 - 您可能想要導(dǎo)入的所有內(nèi)容.

                Now, how are you supposed to do it? Or rather, how might I do it? Well, if you create a significant piece of reusable functionality, like say a markup editor, that's when you create a "top level app" which might contain widgets.py, fields.py, context_processors.py etc - all things you might want to import.

                類似地,如果您可以創(chuàng)建類似博客的內(nèi)容,其格式在安裝過程中非常通用,您可以將其包裝在一個應(yīng)用程序中,使用它自己的模板、靜態(tài)內(nèi)容文件夾等,并配置一個 django 項目的實例使用該應(yīng)用的內(nèi)容.

                Similarly, if you can create something like a blog in a format that is pretty generic across installs, you can wrap it up in an app, with its own template, static content folder etc, and configure an instance of a django project to use that app's content.

                沒有硬性規(guī)定必須這樣做,但這是框架的目標(biāo)之一.事實上,包括模板在內(nèi)的所有內(nèi)容都允許您從一些共同的基礎(chǔ)中包含在內(nèi),這意味著您的博客應(yīng)該緊貼任何其他設(shè)置,只需照顧好它自己的部分.

                There are no hard and fast rules saying you must do this, but it is one of the goals of the framework. The fact that everything, templates included, allows you to include from some common base means your blog should fit snugly into any other setup, simply by looking after its own part.

                但是,為了解決您的實際問題,是的,沒有什么說您不能使用頂級項目文件夾.這就是應(yīng)用程序所做的,如果你真的愿意,你可以做到.然而,我傾向于不這樣做,原因如下:

                However, to address your actual concern, yes, nothing says you can't work with the top level project folder. That's what apps do and you can do it if you really want to. I tend not to, however, for several reasons:

                • Django 的默認(rèn)設(shè)置不這樣做.
                • 通常,我想創(chuàng)建一個主應(yīng)用程序,所以我創(chuàng)建了一個,通常稱為 website.但是,以后我可能想為這個站點開發(fā)原始功能.為了使其可移動(無論我是否曾經(jīng)這樣做),我傾向于創(chuàng)建一個單獨(dú)的目錄.這也意味著我可以通過從配置中取消鏈接該包并刪除文件夾來刪除所述功能,而不是從全局 urls.py 文件夾中復(fù)雜地刪除正確的 url.
                • 很多時候,即使我想讓某物獨(dú)立,也需要在我照顧它/讓它獨(dú)立的同時有地方住.基本上是上述情況,但對于我確實打算通用的東西.
                • 我的頂級文件夾通常包含一些其他內(nèi)容,包括但不限于 wsgi 腳本、sql 腳本等.
                • django 的 管理擴(kuò)展 依賴于子目錄.因此,適當(dāng)?shù)孛怯幸饬x的.
                • Django's default setup doesn't do it.
                • Often, I want to create a main app, so I create one, usually called website. However, at a later date I might want to develop original functionality just for this site. With a view to making it removable (whether or not I ever do) I tend to then create a separate directory. This also means I can drop said functionality just by unlinking that package from the config and removing the folder, rather than a complex delete the right urls from a global urls.py folder.
                • Very often, even when I want to make something independent, it needs somewhere to live whilst I look after it / make it independent. Basically the above case, but for stuff I do intend to make generic.
                • My top level folder often contains a few other things, including but not limited to wsgi scripts, sql scripts etc.
                • django's management extensions rely on subdirectories. So it makes sense to name packages appropriately.

                簡而言之,存在約定的原因與任何其他約定相同 - 當(dāng)涉及到其他人處理您的項目時,它會有所幫助.如果我看到 fields.py 我會立即期望其中的代碼子類化 django 的字段,而如果我看到 inputtypes.py 我可能不看就不太清楚這意味著什么在它.

                In short, the reason there is a convention is the same as any other convention - it helps when it comes to others working with your project. If I see fields.py I immediately expect code in it to subclass django's field, whereas if I see inputtypes.py I might not be so clear on what that means without looking at it.

                這篇關(guān)于Django:“項目"與“應(yīng)用程序"相比的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                How to structure python packages without repeating top level name for import(如何在不重復(fù)導(dǎo)入頂級名稱的情況下構(gòu)造python包)
                Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                How to refresh sys.path?(如何刷新 sys.path?)
                Distribute a Python package with a compiled dynamic shared library(分發(fā)帶有已編譯動態(tài)共享庫的 Python 包)

                  <tbody id='yI9Sg'></tbody>
                <tfoot id='yI9Sg'></tfoot>
                    <i id='yI9Sg'><tr id='yI9Sg'><dt id='yI9Sg'><q id='yI9Sg'><span id='yI9Sg'><b id='yI9Sg'><form id='yI9Sg'><ins id='yI9Sg'></ins><ul id='yI9Sg'></ul><sub id='yI9Sg'></sub></form><legend id='yI9Sg'></legend><bdo id='yI9Sg'><pre id='yI9Sg'><center id='yI9Sg'></center></pre></bdo></b><th id='yI9Sg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yI9Sg'><tfoot id='yI9Sg'></tfoot><dl id='yI9Sg'><fieldset id='yI9Sg'></fieldset></dl></div>
                      <bdo id='yI9Sg'></bdo><ul id='yI9Sg'></ul>

                    • <small id='yI9Sg'></small><noframes id='yI9Sg'>

                      <legend id='yI9Sg'><style id='yI9Sg'><dir id='yI9Sg'><q id='yI9Sg'></q></dir></style></legend>
                          主站蜘蛛池模板: 国产一区二区欧美 | 精品国产乱码久久久久久蜜柚 | 日本三级电影免费观看 | 免费播放一级片 | 毛片的网址 | 午夜精品一区二区三区在线视频 | 免费三级av | 久久久久国产精品午夜一区 | 午夜日韩 | 精品乱码一区二区三四区 | 人操人人 | 国产精品揄拍一区二区久久国内亚洲精 | 99久久免费精品视频 | 插插宗合网| 男人的天堂久久 | 午夜免费在线电影 | 久久性色 | 2022精品国偷自产免费观看 | 国产黄色大片在线免费观看 | 操操操日日日 | 午夜一区二区三区在线观看 | 91视频国产精品 | 中文字幕免费在线 | 麻豆一区| 黄色毛片网站在线观看 | 亚洲欧美一区二区三区视频 | 久久久久久久久一区 | 视频一区二区在线观看 | 三区四区在线观看 | 欧美国产中文字幕 | 亚洲一区二区三区福利 | 亚洲一区在线播放 | 97热在线 | 国产精品午夜电影 | 草久久 | 国产农村妇女毛片精品久久麻豆 | 国产精品视频yy9299一区 | 国产一级在线 | 久久久久国产精品午夜一区 | 成人教育av | 国产精品久久久久久久久久尿 |