Monday, September 2, 2024

Re: IMPORT PROBLEM

Good... it's just a path issue.

Instead of doing 'from . import views', try this: 'from {app_name} import views'.

In your case, you have an app named 'land', so it would look something like this:

'from land import views'.

You need to specify the app name because of the directory structure. When you use 'from . import', you're telling Django to import something from the current directory, which in your case is 'homeland'. However, 'homeland' typically doesn't contain an app directory.

And please make sure you actually created app with manage.py startapp {app_name} and included the app in your settings.py:

INSTALLED_APPS = [
    'django.contrib.admin',
    'land.apps.LandConfig' # your app
 
]
Em segunda-feira, 2 de setembro de 2024 às 09:44:46 UTC+2, Heman Okumbo escreveu:
Homeland is my project directory,there is another folder in the same directory with the same name,my apps directory is named land and its where i am trying to import views from.
I get the below traceback error when i try the import.

On Mon, Sep 2, 2024, 09:46 Augusto Domingos <augustodom...@gmail.com> wrote:

can you send some screenshots showings how you are importing the view?
Em segunda-feira, 2 de setembro de 2024 às 07:50:38 UTC+2, Heman Okumbo escreveu:
My project url cannot import views from the app folder, what ks the problem?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/64c28c86-41d4-4242-a8bf-05862a4b18fbn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/da36e2df-a452-43e6-b02d-0f7621aaed65n%40googlegroups.com.

No comments:

Post a Comment