Django 2.1 unable to detect my new models during makemigrations












0














I've been searching on how to fix this. These are the things that i tried before posting this question. Unfortunately none of them worked.




  • Added the app name (myapp) in setting's INSTALLED_APPS list, it Didn't work.


  • Tried adding just the app name, but it didn't work as well. So now I'm using the full dotted path (myapp.settings.MyappConfig) just to be safe.


  • Deleted __pycache__/*.pyc



When I run $ python manage.py showmigrations, i can see that "myapp" is recognized but there's no migration.



I've placed all my models in a folder to organize it. See my folder structure below. What am I missing here? This is so frustrating, please help me. Thanks in advance!



mysite
|__myapp
| |__ models
| | |__ __init__.py
| | |__ project.py
| |
| |___ apps.py
| |___ admin.py #<-- register your models here
|
|__mysite
|__ settings.py


Update: FIXED!





I was able to generate the migrations scripts by registering the model in admin.py



https://docs.djangoproject.com/en/2.1/ref/contrib/admin/



With this, you can now organize the models into folders. No need to define the modules in __init__.py.



Hopefully someone find this useful. Thanks for all the responses.










share|improve this question





























    0














    I've been searching on how to fix this. These are the things that i tried before posting this question. Unfortunately none of them worked.




    • Added the app name (myapp) in setting's INSTALLED_APPS list, it Didn't work.


    • Tried adding just the app name, but it didn't work as well. So now I'm using the full dotted path (myapp.settings.MyappConfig) just to be safe.


    • Deleted __pycache__/*.pyc



    When I run $ python manage.py showmigrations, i can see that "myapp" is recognized but there's no migration.



    I've placed all my models in a folder to organize it. See my folder structure below. What am I missing here? This is so frustrating, please help me. Thanks in advance!



    mysite
    |__myapp
    | |__ models
    | | |__ __init__.py
    | | |__ project.py
    | |
    | |___ apps.py
    | |___ admin.py #<-- register your models here
    |
    |__mysite
    |__ settings.py


    Update: FIXED!





    I was able to generate the migrations scripts by registering the model in admin.py



    https://docs.djangoproject.com/en/2.1/ref/contrib/admin/



    With this, you can now organize the models into folders. No need to define the modules in __init__.py.



    Hopefully someone find this useful. Thanks for all the responses.










    share|improve this question



























      0












      0








      0







      I've been searching on how to fix this. These are the things that i tried before posting this question. Unfortunately none of them worked.




      • Added the app name (myapp) in setting's INSTALLED_APPS list, it Didn't work.


      • Tried adding just the app name, but it didn't work as well. So now I'm using the full dotted path (myapp.settings.MyappConfig) just to be safe.


      • Deleted __pycache__/*.pyc



      When I run $ python manage.py showmigrations, i can see that "myapp" is recognized but there's no migration.



      I've placed all my models in a folder to organize it. See my folder structure below. What am I missing here? This is so frustrating, please help me. Thanks in advance!



      mysite
      |__myapp
      | |__ models
      | | |__ __init__.py
      | | |__ project.py
      | |
      | |___ apps.py
      | |___ admin.py #<-- register your models here
      |
      |__mysite
      |__ settings.py


      Update: FIXED!





      I was able to generate the migrations scripts by registering the model in admin.py



      https://docs.djangoproject.com/en/2.1/ref/contrib/admin/



      With this, you can now organize the models into folders. No need to define the modules in __init__.py.



      Hopefully someone find this useful. Thanks for all the responses.










      share|improve this question















      I've been searching on how to fix this. These are the things that i tried before posting this question. Unfortunately none of them worked.




      • Added the app name (myapp) in setting's INSTALLED_APPS list, it Didn't work.


      • Tried adding just the app name, but it didn't work as well. So now I'm using the full dotted path (myapp.settings.MyappConfig) just to be safe.


      • Deleted __pycache__/*.pyc



      When I run $ python manage.py showmigrations, i can see that "myapp" is recognized but there's no migration.



      I've placed all my models in a folder to organize it. See my folder structure below. What am I missing here? This is so frustrating, please help me. Thanks in advance!



      mysite
      |__myapp
      | |__ models
      | | |__ __init__.py
      | | |__ project.py
      | |
      | |___ apps.py
      | |___ admin.py #<-- register your models here
      |
      |__mysite
      |__ settings.py


      Update: FIXED!





      I was able to generate the migrations scripts by registering the model in admin.py



      https://docs.djangoproject.com/en/2.1/ref/contrib/admin/



      With this, you can now organize the models into folders. No need to define the modules in __init__.py.



      Hopefully someone find this useful. Thanks for all the responses.







      django django-models django-migrations






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 28 '18 at 6:49







      Wreeecks

















      asked Dec 28 '18 at 5:51









      WreeecksWreeecks

      1,1071633




      1,1071633
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Make sure there is a migrations folder inside the app and there is a __init__.py inside it. Same goes to models folder, you should make sure there is __init__.py file there. Else python will not recognize it a module.
          Also inside the init file(for model), you need to import the Model classes like this:



          from .project import ProjectModel


          Or you can run python manage.py makemigrations <app_name> create the migration folder.






          share|improve this answer























          • oh yeah i forgot to include this. I also did this but still no luck.
            – Wreeecks
            Dec 28 '18 at 5:57










          • inside __init__.py (for model) can you do it like: from .project import ProjectModel? @Wreeecks
            – ruddra
            Dec 28 '18 at 5:59












          • Then run makemigrations
            – ruddra
            Dec 28 '18 at 6:00










          • Do i need to this for all the models in the folder?
            – Wreeecks
            Dec 28 '18 at 6:01










          • As far as I know, yes. As django recognizes on models.py, bascially what you are doing is that making the folder models as a module, so inside __init__.py, it should have all the model class references
            – ruddra
            Dec 28 '18 at 6:02













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53954208%2fdjango-2-1-unable-to-detect-my-new-models-during-makemigrations%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Make sure there is a migrations folder inside the app and there is a __init__.py inside it. Same goes to models folder, you should make sure there is __init__.py file there. Else python will not recognize it a module.
          Also inside the init file(for model), you need to import the Model classes like this:



          from .project import ProjectModel


          Or you can run python manage.py makemigrations <app_name> create the migration folder.






          share|improve this answer























          • oh yeah i forgot to include this. I also did this but still no luck.
            – Wreeecks
            Dec 28 '18 at 5:57










          • inside __init__.py (for model) can you do it like: from .project import ProjectModel? @Wreeecks
            – ruddra
            Dec 28 '18 at 5:59












          • Then run makemigrations
            – ruddra
            Dec 28 '18 at 6:00










          • Do i need to this for all the models in the folder?
            – Wreeecks
            Dec 28 '18 at 6:01










          • As far as I know, yes. As django recognizes on models.py, bascially what you are doing is that making the folder models as a module, so inside __init__.py, it should have all the model class references
            – ruddra
            Dec 28 '18 at 6:02


















          0














          Make sure there is a migrations folder inside the app and there is a __init__.py inside it. Same goes to models folder, you should make sure there is __init__.py file there. Else python will not recognize it a module.
          Also inside the init file(for model), you need to import the Model classes like this:



          from .project import ProjectModel


          Or you can run python manage.py makemigrations <app_name> create the migration folder.






          share|improve this answer























          • oh yeah i forgot to include this. I also did this but still no luck.
            – Wreeecks
            Dec 28 '18 at 5:57










          • inside __init__.py (for model) can you do it like: from .project import ProjectModel? @Wreeecks
            – ruddra
            Dec 28 '18 at 5:59












          • Then run makemigrations
            – ruddra
            Dec 28 '18 at 6:00










          • Do i need to this for all the models in the folder?
            – Wreeecks
            Dec 28 '18 at 6:01










          • As far as I know, yes. As django recognizes on models.py, bascially what you are doing is that making the folder models as a module, so inside __init__.py, it should have all the model class references
            – ruddra
            Dec 28 '18 at 6:02
















          0












          0








          0






          Make sure there is a migrations folder inside the app and there is a __init__.py inside it. Same goes to models folder, you should make sure there is __init__.py file there. Else python will not recognize it a module.
          Also inside the init file(for model), you need to import the Model classes like this:



          from .project import ProjectModel


          Or you can run python manage.py makemigrations <app_name> create the migration folder.






          share|improve this answer














          Make sure there is a migrations folder inside the app and there is a __init__.py inside it. Same goes to models folder, you should make sure there is __init__.py file there. Else python will not recognize it a module.
          Also inside the init file(for model), you need to import the Model classes like this:



          from .project import ProjectModel


          Or you can run python manage.py makemigrations <app_name> create the migration folder.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 28 '18 at 6:02

























          answered Dec 28 '18 at 5:54









          ruddraruddra

          12.2k32648




          12.2k32648












          • oh yeah i forgot to include this. I also did this but still no luck.
            – Wreeecks
            Dec 28 '18 at 5:57










          • inside __init__.py (for model) can you do it like: from .project import ProjectModel? @Wreeecks
            – ruddra
            Dec 28 '18 at 5:59












          • Then run makemigrations
            – ruddra
            Dec 28 '18 at 6:00










          • Do i need to this for all the models in the folder?
            – Wreeecks
            Dec 28 '18 at 6:01










          • As far as I know, yes. As django recognizes on models.py, bascially what you are doing is that making the folder models as a module, so inside __init__.py, it should have all the model class references
            – ruddra
            Dec 28 '18 at 6:02




















          • oh yeah i forgot to include this. I also did this but still no luck.
            – Wreeecks
            Dec 28 '18 at 5:57










          • inside __init__.py (for model) can you do it like: from .project import ProjectModel? @Wreeecks
            – ruddra
            Dec 28 '18 at 5:59












          • Then run makemigrations
            – ruddra
            Dec 28 '18 at 6:00










          • Do i need to this for all the models in the folder?
            – Wreeecks
            Dec 28 '18 at 6:01










          • As far as I know, yes. As django recognizes on models.py, bascially what you are doing is that making the folder models as a module, so inside __init__.py, it should have all the model class references
            – ruddra
            Dec 28 '18 at 6:02


















          oh yeah i forgot to include this. I also did this but still no luck.
          – Wreeecks
          Dec 28 '18 at 5:57




          oh yeah i forgot to include this. I also did this but still no luck.
          – Wreeecks
          Dec 28 '18 at 5:57












          inside __init__.py (for model) can you do it like: from .project import ProjectModel? @Wreeecks
          – ruddra
          Dec 28 '18 at 5:59






          inside __init__.py (for model) can you do it like: from .project import ProjectModel? @Wreeecks
          – ruddra
          Dec 28 '18 at 5:59














          Then run makemigrations
          – ruddra
          Dec 28 '18 at 6:00




          Then run makemigrations
          – ruddra
          Dec 28 '18 at 6:00












          Do i need to this for all the models in the folder?
          – Wreeecks
          Dec 28 '18 at 6:01




          Do i need to this for all the models in the folder?
          – Wreeecks
          Dec 28 '18 at 6:01












          As far as I know, yes. As django recognizes on models.py, bascially what you are doing is that making the folder models as a module, so inside __init__.py, it should have all the model class references
          – ruddra
          Dec 28 '18 at 6:02






          As far as I know, yes. As django recognizes on models.py, bascially what you are doing is that making the folder models as a module, so inside __init__.py, it should have all the model class references
          – ruddra
          Dec 28 '18 at 6:02




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53954208%2fdjango-2-1-unable-to-detect-my-new-models-during-makemigrations%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas