Django sites framework and authentication [closed] - python

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.

Related

How can I restrict API token access for users while giving them API access using Python? [closed]

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 8 days ago.
Improve this question
I currently have a Flask application that allows users to submit a set of form data which is then used to query an API. This API requires an API token for authentication. I want users of my Flask application to be able to make queries to this API but I don't want them to have access to the API token required to make those queries.
At a higher level, what design can I implement to allow for this. My current thinking was to host the Flask application on a dedicated server and allow only specific users (defined using a subnet CIDR block) to interact with it. The API token itself would be contained on the server and not on the local machines of the users. I would love to hear suggestions for different ways to approach this task. I am new to this area and haven't found anything online that is simple enough or relevant for my use case.
My first attempt at this involved a hacky workaround whereby the user form data submitted by users through the Flask app would be stored in a YAML file then subsequently pushed to a remote git repository. This git repository is polled periodically for changes by a Jenkins pipeline on a separate machine which takes any new changes detected and creates an API request using the configuration defined in the YAML file. I'm aware this can't possibly be the optimal solution.

Get and transfer data using an API [closed]

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 3 years ago.
Improve this question
I have to develop an API to manage data between my Database in PostGreSQL and my website in Django.
I'm actually looking for the best way to manage and transfer this data, what I actually found on different topics / sites is the Django Rest Framework to develop a Rest API in Django, here I would use a JavaScript framework for the front like React, Angular or VueJS (any tips about which one to choose ? ).
I was wondering if there was other solutions that would be interesting ? I've been searching about FTP or things like this.
Thanks,
Lucas
Like you said you need to send and retrieve information like name, contact, login detail etc related to user and their subscriptions.
In this case you don't have to think about FTP. It isn't related here. FTP is something that you'll use to transfer files without django.
With django you will have to use DRF (django rest framework) or use GraphQL along.
There is a package well known to use GraphQl called graphene
For front end part you can use anything according to your requirement and skillset.
Hope this helps.
Cheers

Viewing queries history in django [closed]

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 4 years ago.
Improve this question
I need something to view the queries happened ( creating or updating or deleting ) in DB tables in Django, I want it to be able to be used by the user, not at the admin panel
If I understand your question correctly, you are looking for a model history (sometimes also called "audit trail").
In this link there is a comparisson of different packages that can be used for audit/history of models.
As I already pointed out in this answer,
I use django-simple-history which comes with a nice integration to view the list of changes of every model instance in the admin.
For my use case at least, django-simple-history provided me with what I needed, and so far I did not face any issues with it, even though this package does NOT track history of ManyToManyField (for that see related questions like this or this or the Github issue).
Now, if you want the end user to be able to see the history (but not through the admin panel), then you would need to add a few pages for that.
For example, you could add a list view for each model using djangos generic ListView.

Django admin on the frontend [closed]

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.

Plone CMS - multiple domains? user permissions? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Good Afternoon,
We are currently investigating using Plone for our CMS solution.
Ideally we would move our current websites accross to Plone, and then move across other applications later in the project.
I have a couple of Questions that Should be easy, but I have not found direct answers here;
Does Plone have the ability to run multiply domains, So say 5 domains
could run off one instance of Plone, and dependant on the domain,
different content and pages would display? Would this be a simple exercise?
The ability to have multiply user hierarchy, some with Editing ability, but can not post changes, and other who can approve the content before it is published and edit when needed?
We are not scared of the programming or developing additional applications, and we are also looking at employing a company who knows Plone as well to guide our process.
Yes you can have multiple Plone sites for each domain on the same Plone instance(s)/zeo setup. I would recommend you use collective.recipe.filestorage and give each site it's own data.fs (instructions on how to use this here) in case you want to split them up later. If you just want to have each domain point to a separate section of the same website you can do that as well.
Yes you can customize the workflow and user groups however you would like. There is some basic information here.
What exactly is your use case for serving one instance of Zope over several domain names, with different content? In any case, this could probably be achieved with a combination of Apache VirtualHosts (serve the site via multiple domain names) and mod_rewrite (to serve different content for each domain.) Really, though, you may be better off running separate instances of Plone.
Zope does support permissions. I haven't read the documentation on permissions closely to determine if the Zope permissions model meets your exact needs, but you should start here.

Categories