I'm creating a basic CMS. The CMS will contain information about different Entities.
A normal users can only see the information about the Entities but an editor will have access to an Dashboard were it can add new Entities or updated them.
I have an app Entity that use class-based view (CBV) for create,update,details,list-display (CRUD).
The urls for listing and details are: /entities and /entity-name
Because update and create are behind login and use different urls I create a second app Dashboard that use the create/update models of the Entity app
The urls are account/add and account/edit.
There is another solution to have different urls for views of the same model ?
I want the fist page of the dashboard to show different information based on the following logic(exist and/or is activated):
- if doesn't exist I want the CreateView (CBV) and corresponding form to appear
- if exist but it is not active a Pending message
- if exists and active the data of the entity
I can do the logic at the template level, but to separate things is better to be done at the CBV level. So in this case I need some help, how to implement it.
- Have a single view that initially examines the situation, and then calls the respective functions or CBV's that handle the specific situation. Keeps the request logic within the view infrastructure, but not a typical strategy as far as I know. The same URL can then serve all of the situations.
- Have a single view that builds a basic page structure, and use a JS framework and AJAX calls to build an SPA that displays the right information.
- Have a separate view for each situation, along with a separate URL, and another view/URL for the main dashboard. Have the main dashboard view check for your logic, and redirect the browser to the URL for each action. Once the situation is corrected (form submitted, etc.) then redirect back to the main dashboard. This would be my preferred method.
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVf2DJ4NnVjcr9y%2B3SwS-T3eqS7vzEFVCnkfypJTE2D6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment