模块结构Python + Django,没有名为“实体”的模块

时间:2018-12-15 14:29:40

标签: python django

有关我的项目结构,请参见下图。

在riskgame / view.py中,我尝试到达实体Risk.py:

public class DisplayArticle extends AppCompatActivity {
    private TextView tv_title,tv_desc;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_article);
        tv_title = findViewById(R.id.pt);
        tv_desc = findViewById(R.id.pd);
        Intent intent= getIntent();

        String art_title = intent.getExtras().getString("Atitle");
        String art_desc = intent.getExtras().getString("Atext");

        tv_title.setText(art_title);
        tv_desc.setText(art_desc); }

        @Override
        protected void onDestroy() {
        tv_desc.setText(null);

        tv_title.setText(null);
        super.onDestroy(); }}

尝试此操作时出现错误:from entities.Risk import Risk def index(request): game = Risk() return HttpResponse("test")

也从ModuleNotFoundError: No module named 'entities'收到错误api.risk.riskgame.entities.Risk import Risk

什么是我的项目的良好结构?

enter image description here

1 个答案:

答案 0 :(得分:0)

from riskgame.entities.Risk import Risk

from .entities.Risk import Risk