I am using Django for developing a website and I want to allow my staff to be able to add/edit/delete pages with multiple text fields. I am planning to use Django's admin framework for this as the staff is a non-technical one.But I have no clue on how to go about doing this so that people can login and edit the contents on these pages whenever they want.
Also, my site will be receiving around 1500 hits per day. I don't want to embed these pages in static templates (so that I can allow my staff to edit it). Will loading this data at runtime slow down my site. I am using a Servint VPS server.
Thanks
niting
Follow the Django tutorial, replacing the concept of Polls with Pages, and Choices with Content blocks and you'll be most of the way there (Django's built in Admin will allow you to edit these models).
For a more advanced CMS based on Django take a look at either Django CMS or FeinCMS.
Related
I am currently developing a mobile app using Ionic and I am using Django Admin Interface as sort of Backend for adding and editing the content of my mobile app through a MySQL Database.
I currently wish to create a custom analytical dashboard for tracking the usage of the users of my mobile app in the startpage of the Django Admin. While there are some analytical packages for tracking the usage in Django, they only function for web applications.
In my case I need to gather and display aggregate data from my database (Django models & not Django models) as well for other APIs. Is there a way how can I fetch data in form of SQL queries and display them in my dashboard using Python (Django)?
And how can I extend the starting page of Django Admin to a full analytical dashboard with the named functionalities?
I am currently struggling with this as I am new to Django. Any help is much appreciated!
There are some prebuilt admin themes which you can look into, and I personally recommend Django Jet. You can also change directly the way that the admin templates are made and rendered looking around the contrib/admin folder on your Django installation, or you can extend the admin views and templates, take a look at the documentation. Hope I could help!
I am a total noob with Django, I come from the PHP world and I am used to doing things differently.
I'm building an app and I want to change the way the backend looks, I want to use Bootstrap 4 and add a lot of custom stuff e.g. permission based admin views, and I was wondering what is the best practice, or how do more experienced django devs go about it?
Do they override all the django.contrib.admin templates, or do they build custom templates and login/register next to it, and use the django.contrib.admin only for the superuser?
What is the django way?
Django admin is intended for administration purposes. For all intents and purposes it is a direct interface to your database. While I have seen some people building customer facing interfaces using admin, this is most definitely not the way to make a general Django web application.
You should define views for your models. You can use built-in APIs to login and authenticate users. You should most likely restrict access to admin to internal users only.
As for templates, the modern way of doing things is to dynamically fetch data using an API and do all the UI logic in Javascript. Django can be used very well to provide an API to a frontend. Look into Django REST Framework. The basic idea is to write serializers for your models and have view functions serve the serialized data to the front end.
You could go the old school way and render your pages using templates of course. In that case your views would render templates using data provided by your models.
Yes. The admin pages is actually for administering the webpage. For user login and registration you create the templates. However, if you want your backend to look different then you can tweak the template for the admin page, admin login page as well. And you can also have permission based admin views. It's okay to over ride the defaults as long as you know what you're doing. Hope that helped.
Can I use Django Rest Framework to create an "ordinary" site - like a blog, with templated HTML pages ala "normal" django?
The reason I ask this is that I am building a website (sort of a blog), but for sections of the site, the functionality will be provided by making CALLS to a REST API.
So, my question essentially is this:
Is DRF equivalent to (all the features/functionality of django) + ability to create/use RESTful APIs?
Django Rest Framework is an add-on to Django. It doesn't replace Django; it's just another app. You still create your models via Django, and can use views and templates as normal.
Is it possible to organize your urls.py with a Django model? I would like to create a admin interface to manage pages, and output the pages as links in the navigation, but I will run into problems with parameters. The pages should take different parameters. Am I on the wrong track? Is it possible to find a project which has already done it on Github or other open source code repository sites?
Django comes with a flatpages app that does what you need.
I guess Django CMS does that. It holds the whole site structure in DB.
I've installed Django CMS (http://www.django-cms.org/) and it's almost perfect. I've been chatting on the IRC #django-cms group and it's been confirmed to me that I can't have access restricted to the pages I make in Django CMS to only a select few on the site side.
I know of the CMS_PERMISSIONS setting, but this seems to only restrict users on the admin site. What I am trying to achieve is have pages that are made in the admin side of CMS are restricted on the site side to a select few. So on my site side, I'd have my normal pages of Home, About, Services, Contact and then they'll be a login area. Once logged in, they'll be pages that can only be available to particular people. Some of the pages to some users, other pages to other users.
If this can't be achieve in the normal Django CMS installation, how on earth would I achieve this in another way? I'm not a Django expert, but this is something I'd like to do, and I'm not sure where to start. Can anyone help with this? Has anyone else achieved this?
Use the 'View restrictions' panel in the admin page. This is documented here.
I don't know Django CMS, but you could do such filtering in middleware - i.e. you could check incoming URL and redirect to login page if current user doesn't have permissions to view it.
http://docs.djangoproject.com/en/1.1/topics/http/middleware/