How to rename "/admin" to other URL in web2py? - python

web2py application administration is by default located on:
http://127.0.0.1:8000/admin/default/site
Is it possible to change "admin" to be something else (for example):
http://127.0.0.1:8000/appadmin/default/site
and if it is possible how that is achieved?

admin is just an app.
On windows open windows explorer and go to \web2py\applications\ right click on "admin" folder an then click in rename.
On Linux.
cd path/to/web2py/applications
mv admin newadmin

This answer is correct, but more changes needs to be done.
In your case, to change url from /admin to /appadmin do following steps
Rename admin app folder name to appadmin
Fix broken links to admin app
In your_app/controllers/appadmin.py, search all links to admin app and replace it with links to appadmin app
Change creation of links to error pages
Update routes.py, to route errors to appadmin app and not admin app
For detailed steps read How to change admin app url in web2py?

Related

Setting up Flask-Admin and Flask-Security

I have a Flask-Admin project set up with Flask-Security as well. It is pretty much https://pythonhosted.org/Flask-Security/quickstart.html#id1 but just more advanced. I can access the login page at localhost/login and logout and localhost/logout. The logging in and logging out works.
The templates for Flask-Admin works and everything is displayed as I'd expect. However, there are no templates on my machine or docker container where the Flask-Admin app is run. I installed Flask by running pip install Flask-Admin. I know I can over ride the security log in by adding something like
SECURITY_LOGIN_USER_TEMPLATE = 'security/login_user.html'
to the config file and uploading to /templates/security/login_user.html. There is also using
{%extends base.html}
to have a common theme. Should I have template files already in my project?
Flask Security have a default login template, if you want to use your own template for login or register follow these steps:
Create in template folder the a subfolder named security
Add your html documents to this folder
Go to your flask configuration and add the following settings:
If your want the register functionality
SECURITY_REGISTERABLE = True
Add the name of your templates:
SECURITY_LOGIN_USER_TEMPLATE = 'security/login.html'
SECURITY_REGISTER_USER_TEMPLATE = 'security/register.html'
Remember to use the appropriate form in login.html and in register.html, usually causes doubts but is simple:
register.html: register_user_form.field
login.html: login_user_form.field
These are the configurations for this work correctly.
this repository can you to see and understand better doubt:

How to make facebook app allow requests from django project that runs on a local server?

I am trying to use django social auth to auth via facebook.
I used this documentation to make changes in my django project and to create and setup the facebook app. I am running django project on local server. The project has url http://127.0.0.1:8000. When hit the following link on my project's web page:
Template
<p>Facebook</p>
Rendered template
<p>Facebook</p>
it redirects me to a facebook page where I can see the following message:
Given URL is not allowed by the Application configuration: One or more
of the given URLs is not allowed by the App's settings. It must match
the Website URL or Canvas URL, or the domain must be a subdomain of
one of the App's domains.
How to change facebook app's settings to allow
http://127.0.0.1:8000?
upd
Added localhost to app domains and http://localhost:8000/ to site URL in my fb app's settings.
The Facebook app doesn't allow IP addresses like that, but it does allow localhost. In the App Domains on the Settings tab you need to add localhost. What sucks is that other services (such as twitter) don't accept localhost and you can only use 127.0.0.1:8000, which means you have to switch back and forth.
It works for local development, but it's not pretty.
EDIT:
You also need to add http://localhost:8000/ to the Site URL first

Add and edit permissions disappear when debug turned off in Django

I am deploying a website that has an /admin/ page where staff and the superuser access the database tables.
In settings.py I changed these settings to put the site into production mode.
DEBUG = False
TEMPLATE_DEBUG = False
Issue is this has caused my admin site to show only black links on the applications where i cannot view, edit or add rows to the tables even if logged in as a super user.
What settings have i got wrong?
I found the solution here in this self answer:
django on apache - admin page links are VISIBLE but not CLICKABLE
Issue is i should be using a separate admin.py file, not putting things that should be in there in the model.py file.

how to set the admin user with GAE dev app server?

I want to create an Admin-only page for my GAE application. But I found there's no way to set a Admin user, so I cannot log on the page I created and test the function. I tried the local Admin console, but no luck. How can I do this?
Google App Engine provides a pretty straightforward way to create a private admin section of your web application.
1.
In your app.yaml, any URL handler can have a login setting to restrict visitors to only those users who have signed in, or just those users who are administrators for the application.
If the setting is login: admin, once the user has signed in, the handler checks whether the user is an administrator for the application. If not, the user is given an error message; if the user is an administrator, the handler proceeds.
Here a snippet of app.yaml where the /admin/.* routes are admin restricted :
- url: /admin/.*
script: admin.py
login: admin
2.
Trying to access the admin url, the dev app server automatically shows the login panel where you should check the Sign in as Administrator checkbox.
When you log in (the blue box where you enter the email) there is a checkbox to apply the administrator flag to your session.
You can define admin only pages in your app.yaml, like so:
- url: /secrets/
script: /secrets/example.py
login: admin
an admin is whoever is so defined in your appengine.google.com control panel, under permissions.

upload file not working in google app engine

it should works but hitting the submit button redirect my page to http://localhost:8082/sign (http://localhost:8082 being the path to my app). There's no such path in my application thus it return a link broken page. Is this a common problem?
Yes, but this isn't an App Engine problem. If you do a form post to a URL that doesn't exist, it will return a 404 (I'm suspecting you modified the guestbook app, which posts to /sign and didn't change where the post on that app goes to).

Categories

Resources