2

I have a blog app and a video app in the same directory in my django project. I am trying to a add a model from my video app called video, to my blog/views.py so I can access it by using

Video.object.all()

I tried doing this

from video.models import Video

and

from Models.video import Video

and

import video

but none of these are working. How do I change my code to access that class

losee
  • 2,190
  • 3
  • 29
  • 55
  • 1
    You need to list your models here. – Ahmed Jan 04 '16 at 16:06
  • Also, you need to tell us what kind of error do you get. – Ahmed Jan 04 '16 at 16:06
  • 1
    Are both apps listed in your `INSTALLED_APPS` setting? – nthall Jan 04 '16 at 16:11
  • Possible duplicate of http://stackoverflow.com/questions/31406662/django-unable-to-import-model-from-another-app – Deva Jan 04 '16 at 16:13
  • @Deva that didn't work. It just cleared up my ide but I am getting an error saying there is no module named src – losee Jan 04 '16 at 16:19
  • @Ahmed this seems to work now – losee Jan 04 '16 at 16:25
  • @Ahmed this seems to work now from video.models import Video. But my Pycharm ide has warning lines under video and Video. The error message says "this inspection detects names that should resolve but don't. due to dynamic dispatch and duck typing this is possible in limited but useful amount of cases. Top level and class level items are supported better than instance items – losee Jan 04 '16 at 16:31
  • what is project directory structure? – Muhammad Hassan Jan 04 '16 at 18:52
  • Your example cites Video.``object``.all(). This should be plural; ``objects`` – Ben Keating Jan 05 '16 at 02:54

0 Answers0