Re: Automatically assume "models." prefix in models.py
On 11/13/2010 11:20 PM, James wrote:
> Forgive a django newbie...
>
> Maybe I'm the laziest person in the world, but sometimes I get tired
> of typing "models.WhatEver" for every single model I have to write. Is
> there anyway a shortcut could be added that would 'assume' the
> 'models.' prefix when I am defining a model?
>
> e.g. instead of:
>
> class SomeModel(models.Model):
> something = models.SomeField(someoption=something)
> # some other things
>
> Could a shortcut be added so that I can write:
>
> class SomeModel(models.Model):
> something = SomeField(someoption=something)
> # some other things
>
>
>
> I realized that not everything I will write will have the "models."
> prefix, but I think _most_ of what I write in models.py will have it.
>
> So... I'm a being too lazy, or perhaps just stupid?
>
You can import names individually from a module. In your examoke you
would do this:
from models import Model, Somefield, OtherField
class SomeModel(Model):
something = SomeField(someoption=something)
and so on.
regards
Steve
--
DjangoCon US 2010 September 7-9 http://djangocon.us/
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home