Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm still in the process of learning the basics of Django. I have a lot of questions. But the biggest one at the moment is to understand how I reuse admin models, forms and templates to display it on the frontend instead by going on the backend admin control panel.
What I've done so far is to create a url in urls.py, created a view in views.py and added template path, created the template.
Everything works well with that. But how do I just "copy" the admin model that I want so the user that is logged in can edit on the frontend instead?
What do I need to look more into to understand this so I can implement the admin on the frontend?
Though the admin can be configured through a permission system it is nothing that should be exposed to your front end users - it only should be used by users you can fully trust (administrators).
To implement similar functionality on the frontend look into Django's ModelForms and Generic Views which should help you to implement simple CRUD actions rather quickly. If you would like to implement a Javascript based frontend something like Django-REST-Framework might be a good choice to implement something similar for a REST-API.
Nonetheless you could still add a second AdminSite to your project - but as stated above this is not really recommended for security reasons, if you would expose it to the "normal" user.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to build a web application using Django. Basically a CRM for specific business type. Lets say it's for Gyms for this explanation. I will have multiple customers. The customers will each get their own 3rd level domain name. Like golds.gym.com and 24hrfitness.gym.com. Each customer will have their own customers that will use the site as well. I want to allow overlapping usernames across sites, but unique to each site. I would also like to use the built in admin pages, but I will need to be sure that the admin pages are site specific.
My question is more or less, "Is this possible". But I think what I really want to know is "Is this possible using something built in or something someone else has out there for Django?"
I have looked at the sites framework documentation and that seems to be what I need, however I have not found any documentation on how to make the admin and the users site specific.
You can definitely do it with the sites framework, but it does take a significant amount of bootstrapping. This also goes under the assumption that you will use a different hostname for each site, as this is how the sites framework works.
When you use the sites framework, there is middleware available that automatically populates the ID of the site on the request object.
If you want the end users to be able to use the admin section and see ONLY the objects on their account, you will need to have an account foreign key for every model.
You could then do something like overriding get_queryset in your views to automatically exclude any objects not belonging to the account.
Of course, you would also need a custom user model so that you can link users to sites.
If you are using postgres you could consider checking out Django Tenant Schemas, which accomplishes multi-tenancy using native postgres schemas.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Does django have the same level of code generation like Rails?
In rails you can create models, which then create database migrations.
You can generate controllers, views using the command line.
Django has a very similar way of handling database migrations. They are created by calling python manage.py makemigrations and applied with python manage.py migrate
Controllers (urls.py) must be added manually to each app, but by typing one import statement they are ready to be used.
Views are made automatically when an app is initialized. However, they are empty, so creating a app does not give you the automatic CRUD html that rails does. There is generic class based views in Django which have most of data management done for you, along with automatic form generation, but this requires some actual coding albeit very little.
TLDR: In terms of prefab code generation, Rails wins, but any experienced Django developer can include generic views and forms to get the same functionality in minutes.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Is it possible to use only some features of Django?
I'm using my own home-made ORM with redis for a webapp using the MVC model. Now I want to know what I have to do to so that I can take advantage of Django's very nice admin.py
Has anyone ever done anything similar?
You can "use only some features of Django", but some parts depend on other parts. Django Admin is very dependent on Django ORM. It is basically a tool for visualizing, creating and editing Django ORM models. Using it with your own "home-made" ORM is virtually impossible.
Take a look at django-nonrel. It forks Django to provide support for non-relational databases (currently MongoDB and Google App Engine). It might help you if your main aim is to use a non-sql db in your project. It still won't help you to easily integrate your custom ORM with Django Admin. So your other option is to write your own admin for your project.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am new to Django, I have started learning just a week ago. I am taking the reference of Django Docs, but I can't understand how to give url to an app. So can anybody please tell me how to give url to an app with description?
for example:- If I want to make a login form and when I click on login button it goes to the home page.
Django is a web framework
A web framework carry out common works for you(the web developer)
One of the common works is resolving the http request
One of the resolving is direct the request pointing to a URL to a specific piece of code which handles this request and generate the response.
We sometime call the stuff carrying out the above mechanism a URL router of the web framework. The piece of code in Django is a function(which generate a http response), we call it the view.
So we say the framework's URL router map a URL to a view.
You tell the router what URL maps to what view by listing your url-view mappings in the solo urls.py in the root directory of your project
If you dislike the solo urls.py being too large, you can split this file into multiple files, and put them in individual Apps directory. Then by using include syntax you aggregate them into the solo urls.py
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I just start a django-fairy project for django 1.3.1 here: https://github.com/goFrendiAsgard/django-fairy
It is just a simple (but I think useful) python script that can help django newbie to develop everything faster. The basic idea is:
When you make a view, usually you will make respective url and template
When you make a model, usually you will register it on admin
So that it would be more fun, if there is a way to do such a things in a simple way.
I want to make sure if what I do is right.
So these is my questions:
Do you think that such a project is useful for community?
Is it violate django (and python) philosophy?
Do you think that such a project is useful for community?
Yes, just keep developing it plus, you will know that from the users as feedback and even if the feedback wasn't good enough, let your project be, enhance it more and more and your project will get a good rating and acceptance in no time. Just consider your users' notes and comments and you will be fine.
Is it violate django (and python) philosophy?
No, it is not.
The only way to tell if it is useful is for you to complete it and publish it and people start using it.
No, there are tons of other quick bootstrapping scripts available for django. There is no such policy that prevents this.
However, you shouldn't make a lot of assumptions as to what the end user will want to do with their models/views. Django is a toolset and as such there are lots of ways to use it.
For example, there are models that are never entered in the admin, and similarly there are django sites that don't have a "front end" (ie, a view) and only use the ORM and the admin, with applications like databrowse