On Aug 9, 7:59 pm, Léon Dignòn <leon.dig...@gmail.com> wrote:
> In my myproject/urls.py I want to pass the class to a function.
> Because my urls.py is full of imports, I do not want another import
> line for this class I only use at one line, because it's easier to
> read.
>
> I wonder that I have to import myproject when I reference a model
> class in an app which _is_ in the project I am currently using. For
> that I have to ask this:
>
> Do I really need 'import myproject' in myproject/urls.py when I'd like
> to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???
>

Yes, if you want to write 'myproject.whatever' you need to import
myproject. Python doesn't magically know about namespaces unless you
tell it.

You're right that since you're in myproject you don't need to import
that - you can just import myapp and do 'myapp.models'. But you still
need to import myapp.

However, I do wonder why you have so many imports in your urls.py. I
presume you know that you can just use strings to reference the view
functions?
--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to