#1240 closed enhancement (fixed)
Tab-completion actions for django-admin
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | minor | Keywords: | |
Cc: | paolo@…, treborhudson@…, wonlay@…, Gonzalo Saavedra | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Tab-completion actions for django-admin
This ticket exists because after reading LittleEasyImprovements wiki page I have been attracted by "Tab-completion actions for django-admin" project. So I decided to write a bash script for that purpose.
The script is attached below, and adds tab completion capability to django-admin.py and manage.py (./manage.py, python manage.py, python project/manage.py, etc.), even if it is only partially supported: actually only actions (adminindex, createcachetable, createsuperuser, etc.) and options (--help, --settings, etc.) are handled, while models completion is not, mainly because I was not able to write Python code that returns names of models installed within a project (auth, core, and the ones created by the user). Any help on this would be greatly appreciated!
I hope you can find the script useful in some way, even if not finished. Feel free to use it as you want, if you want. It has been a pleasure to do something for you, in each case.
Installation
Create a directory named .bash_completion in your home directory and move
this file there. Now, if in your home exists a file called .profile use this
one, otherwise use .bash_profile and add this line:
source ~/.bash_completion/django
Do the same in ~/.bashrc. Usually this shouldn't be necessary as
.profile or .bash_profile take care to invoke .bashrc, if it exists, but
different distributions handle this aspect differently.
Settings will become effective since next login, or after typing source ~/.bash_completion/django
Attachments (10)
Change History (47)
by , 19 years ago
comment:1 by , 19 years ago
Severity: | normal → minor |
---|
comment:2 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
by , 19 years ago
Django bash completion script updated for 0.95 (post-magic-removal)
comment:3 by , 19 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
The script has been updated to reflect new django-admin.py and manage.py actions and options (dbshell, diffsettings, syncdb, --version).
It is available as attachment named django.2
comment:4 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fixed. This new patch appears to offer no new functionality over what's currently in Django's trunk.
by , 19 years ago
Django bash completion script updated to reflect changes happened in #1736
comment:5 by , 19 years ago
Cc: | added |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
comment:6 by , 19 years ago
Next time (and I'm sure there will be a next time), could you post a diff please, rather than the whole file. It makes it slightly faster to review. Thanks. :-)
comment:7 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:9 by , 18 years ago
Cc: | added; removed |
---|---|
Keywords: | rthml tab space editor js added |
Summary: | Tab-completion actions for django-admin → hi-world cup |
comment:10 by , 18 years ago
Summary: | hi-world cup → Tab-completion actions for django-admin |
---|
comment:11 by , 18 years ago
Cc: | added; removed |
---|---|
Keywords: | rthml tab space editor js removed |
comment:12 by , 18 years ago
Component: | django-admin.py → Generic views |
---|---|
milestone: | → Version 0.92 |
priority: | normal → high |
Severity: | minor → normal |
Type: | enhancement → task |
Version: | → magic-removal |
comment:13 by , 18 years ago
Component: | Generic views → django-admin.py |
---|---|
milestone: | Version 0.92 |
priority: | high → normal |
Severity: | normal → minor |
Type: | task → enhancement |
Version: | magic-removal → SVN |
comment:14 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
I couldn't get this latest patch (the one that autocompletes app names) to work.
comment:15 by , 18 years ago
Keywords: | http status response added |
---|
The latest patch doesn't apply for me. Did you use svn diff to generate it?
comment:16 by , 18 years ago
Cc: | added |
---|---|
Has patch: | set |
Keywords: | http status response removed |
Resolution: | invalid |
Status: | closed → reopened |
Re-opening ticket to add my app completion support.
Tested on:
- Mac OS 10.4
- Ubuntu Linux
See this thread for more:
http://groups.google.com/group/django-developers/browse_thread/thread/284c81cf24ff8e2b/#
by , 18 years ago
Attachment: | app_completion.diff added |
---|
Adding app completion to existing bash script using standard unix tools (sed, grep, tr).
comment:17 by , 18 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
comment:18 by , 18 years ago
The patch does now apply (thanks!) but it assumes I'm in the working directory for the project, settings.py is just grabbed from the PWD. I don't tend to be in my project dir when I invoke django-admin.py
so I get sed errors on hitting tab.
One other related thing, test is not included in the list of verbs. That's a separate bug though.
comment:19 by , 18 years ago
I've updated the patch.
- Support for DJANGO_SETTINGS_MODULE in the environment variable for django-admin.py so you don't have to be in the project directory for this to work.
- If you are in the project directory, it overrides the environment variable.
- Changed grep -v django to grep -v django.contrib so app names can contain django. Thanks Paolo.
- Changed the regular expression to support just 'appname' instead of 'project.appname'. Thanks Paolo.
Thanks for the comments.
comment:20 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:21 by , 18 years ago
Patch needs improvement: | set |
---|
This completion does not work when django-admin.py or manage.py is not invoked directly. i.e. if you type python django-admin.py and <tab> it does not work. It will be good to have that added as well. I will check and see if I can check the bash manual and add it myself...
comment:22 by , 18 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Amit would please check if my patch work for you?
by , 18 years ago
Attachment: | a_better_app_completion.diff added |
---|
A patch to improve application name completion
comment:23 by , 18 years ago
paolo, your patch seems to work fine for me in my setup. Would it be easy to also include minor python changes like python2.3 python2.4 as well (in addition to python) ?
--Amit
comment:24 by , 18 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
since being reopened, this is not ready for checkin yet.
comment:25 by , 18 years ago
The new patch support_for_multiple_interpreters.diff should satisfy your request Amit, would you please confirm this? Thanks.
by , 18 years ago
Attachment: | support_for_multiple_interpreters.diff added |
---|
Updated patch against the trunk
comment:26 by , 18 years ago
On Mac I get this an error with "whereis". It apparently doesn't take a "-b" flag...
whereis: illegal option -- b
usage: whereis program [...]
comment:27 by , 18 years ago
Ouch... To be honest I must say I had a weird experience using the -b flag; the man page says that its purpose is to force a search for binaries, and it would be perfect in this case, even if on my system it spits out things like /usr/local/lib/python2.3 and /usr/local/lib/python2.4. That wasn't a problem, as the script is able to handle this situation in some way (the result of basename /usr/local/lib/python2.3 and basename /usr/local/bin/python2.3 is the same), so I decided to leave it.
It becomes a problem if this flag origins an error :-)
Could you please test the patch removing the offending flag? Thanks.
comment:28 by , 18 years ago
Removing the "-b" doesn't give me an error now, but it doesn't appear to work.
If I'm in a Django project directory, and type: python manage.py [tab][tab], I get a list of all files in the directory rather than a list of options or args. Similarly, typing: python /path/to/django-admin.py [tab][tab], gives me the directory listing. Am I testing this wrong?
-Rob
comment:29 by , 18 years ago
Rob, for me it is working (with and without "-b"). I can use with success "python manage.py [tab][tab]", "python2.3 manage.py [tab][tab]", "/usr/local/bin/python2.3 /usr/local/bin/django-admin.py" and other combinations inside a project.
The only thing I have done is to apply support_for_multiple_interpreters.diff to the bash completion script in the trunk.
I'm using the script both with an old bash version (2.05) and with the recent bash version shipped with Ubuntu Edgy, and it works, so I can't even try to do some investigation, sorry.
comment:30 by , 18 years ago
My apologies... Something was mixed up in my shell, or I didn't source the profile but it's working this morning. App completion is working as well. Nice!
comment:31 by , 18 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Good, thanks for testing!
comment:32 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:33 by , 18 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Actually, this should be re-opened to remove the "-b" option to whereis which breaks on Mac. Paolo, can you update the patch?
by , 18 years ago
Attachment: | support_for_multiple_interpreters_mac.diff added |
---|
comment:35 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:36 by , 16 years ago
Cc: | added |
---|
Does anyone here use tab indent instead of spaces?
Tab completion fails if the settings.py is using tab for indent.
I will upload a working patch for this.
by , 16 years ago
Attachment: | django_bash_completion.diff added |
---|
Fix problems when tabs are used for indent of settings.py
comment:37 by , 16 years ago
Cc: | added |
---|
Rather than use source to run the script, . should be used as it doesn't create a new process to run the script.
instead of source ~/.bash_completion/django
. ~/.bash_completion/django