On Thu, May 1, 2014 at 9:46 PM, Adam "Cezar" Jenkins <[email protected]
> wrote:

> On Thu, May 1, 2014 at 11:10 AM, Venkatraman S <[email protected]> wrote:
>
>>
>>
>> On Thu, May 1, 2014 at 9:29 PM, Cezar Jenkins <[email protected]>wrote:
>>
>>> Right now I have a large project with an equally large API (done using
>>> django rest framework). The current structure is something like this:
>>>
>>> api
>>> |-----urls.py
>>> |-----models.py
>>> |
>>> ----v1
>>>     |-----views.py
>>>     |-----serializers.py
>>>     |-----permissions.py
>>>     |-----tests.py
>>>
>>> etc
>>>
>>> As you can guess, the views.py file is pretty big and I want to refactor
>>> this out. Currently I have a few options in front of me, the one I'm
>>> leaning towards is to put an 'api/v1' package into each app and use the api
>>> app to tie all the urls together and hold views that don't fall into an app.
>>>
>>
>> If the only pain point is the big views file, then why not just refactor
>> that into multiple files under 'v1'  itself - nothing is stopping you from
>> doing that.
>>
>
> That was one way I started refactoring, but ran into issues. Say I have a
> destinations.py view file in the api, but I also have a destinations app.
> In my views file I can't do 'from destinations.models import Destination'
> cause the name conflicts. So I started having to name things
> 'destinations_api.py' which seemed really dirty.
>

When I have to split views.py into multiple files, i generally suffix it
with _views; so, in your case it would be destination_views.py .

-V

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7tdFTL8DhOb5kcXG5ODzcJAjsnxNFrr5Km06RF8eLp5DYpLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to