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'??? On Aug 9, 8:50 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Aug 9, 7:34 pm, Léon Dignòn <leon.dig...@gmail.com> wrote: > > > > > > > Hello, > > > some times I'd like not to import a class but just write it down. > > > Instead of > > from myproject.myapp.models import MyModel > > > I'd like to use > > myproject.myapp.models.MyModel > > > But I get a NameError: name 'myproject' is not defined > > > Also > > myapp.models.MyModel > > raises a NameError: name 'myapp' is not defined > > > Any ideas? > > What are you trying to do - what do you mean by 'write it down'? > > If you just want to use 'myproject.myapp.models.MyModel', instead of > just 'MyModel', when referencing a model class, that's fine - but you > still need to import myproject. > -- > DR.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---