Giter Site home page Giter Site logo

python-django.el's Introduction

This package contains python-django.el

Info

Introduction

A Jazzy package for managing Django projects.

Django project management package with the goodies you would expect and then some. The project buffer workings is pretty much inspired by the good ol’ `magit-status’ buffer.

See the header of python-django.el for more information.

Requirements

This package relies heavily in fgallina’s `python.el’ available in stock Emacs>=24.3 (or https://github.com/fgallina/python.el).

Installation/Usage

Add this to your .emacs:

(add-to-list 'load-path "/folder/containing/file")
(require 'python-django)

See this blog post for a detailed quick start: http://web.archive.org/web/20131010005338/http://from-the-cloud.com/en/emacs/2013/01/28_emacs-as-a-django-ide-with-python-djangoel.html

Bug Reports

If you find a bug please report it in the github tracker.

License

python-django.el is free software under the GPL v3, see LICENSE file for details.

python-django.el's People

Contributors

fgallina avatar vkurup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-django.el's Issues

python-django-open-project fails with my settings.py

I have a mature Django project that I'm trying to use with python-django.el. I'm a complete newbie at Emacs, coming from a long history with Vim, so this might be more easily debuggable than I realize. Here's the problem:

Django Version:         1.4.2
Project:                ~/src/pp/pp.hg/
Settings:               settings
Virtualenv:             /home/aron/.virtualenvs/pp


An error occurred retrieving project information.
Check your project settings and try again:

Current values:
  + python-django-project-root: ~/src/pp/pp.hg/
  + python-django-project-settings: settings
  + python-shell-interpreter: python
    - found in /home/aron/.virtualenvs/pp/bin/python


Error: Wrong type argument: listp, 17

I tested with a simpler project and that worked fine, and I also tested with this project and an empty settings.py, and that worked fine. Do you have suggestions for how I can track down the problem?

Adding app folder move - error

After creating a new app with c-o-s-a , I am asked if I want to move the folder.

App created in x/y/z/. Do you want to move it? (y or n)
y -> same directory: error in process sentinel: file is a directory.
y-> different empty directory: error in process sentinel: Renaming: No such file or directory.

"Run management command" fails

The 'm' command in the project buffer fails with the following trace (in this for my custom command "testjs":

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  expand-file-name(nil)
  (list (expand-file-name python-django-project-root) (expand-file-name "../" python-django-project-root))
  (mapconcat (quote identity) (list (expand-file-name python-django-project-root) (expand-file-name "../" python-django-project-root)) path-separator)
  (let* ((process-environment (python-shell-calculate-process-environment)) (pythonpath (getenv "PYTHONPATH")) (project-pythonpath (mapconcat (quote identity) (list (expand-file-name python-django-project-root) (expand-file-name "../" python-django-project-root)) path-separator))) (setenv "PYTHONPATH" (if (not pythonpath) project-pythonpath (format "%s%s%s" pythonpath path-separator project-pythonpath))) (setenv "DJANGO_SETTINGS_MODULE" python-django-project-settings) process-environment)
  python-django-info-calculate-process-environment()
  python-django--help-get("testjs")
  python-django-help("testjs")
  python-django-mgmt-list-command-args("testjs")
  #[nil "\305\306�\"\210\307    !\210\310\n!�\311\304!\210\312\211�\207" [setup-hook current-buffer command minibuffer-completion-table hippie-expand-try-functions-list remove-hook minibuffer-setup-hook python-util-clone-local-variables python-django-mgmt-list-command-args make-local-variable (python-django-minibuffer-try-complete-args python-django-minibuffer-try-complete-filenames)] 3]()
  read-from-minibuffer("./manage.py testjs (args): " nil (keymap (remap keymap (scroll-other-window-down . python-django-minibuffer-scroll-help-window-down) (scroll-other-window . python-django-minibuffer-scroll-help-window)) (9 . hippie-expand) keymap (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the minibuffer") (next menu-item "Next History Item" next-history-element :help "Put next minibuffer history element in the minibuffer") (isearch-backward menu-item "Isearch History Backward" isearch-backward :help "Incrementally search minibuffer history backward") (isearch-forward menu-item "Isearch History Forward" isearch-forward :help "Incrementally search minibuffer history forward") (return menu-item "Enter" exit-minibuffer :key-sequence "
" :help "Terminate input and exit minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort input and exit minibuffer") "Minibuf")) (10 . exit-minibuffer) (13 . exit-minibuffer) (7 . abort-recursive-edit) (C-tab . file-cache-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-history-element) (up . previous-history-element) (prior . previous-history-element) (XF86Forward . next-history-element) (down . next-history-element) (next . next-history-element) (27 keymap (114 . previous-matching-history-element) (115 . next-matching-history-element) (112 . previous-history-element) (110 . next-history-element))))
  python-django-minibuffer-read-command-args("testjs")
  (list (setq command (python-django-minibuffer-read-command t)) (python-django-minibuffer-read-command-args command))
  call-interactively(python-django-mgmt-run-command nil nil)

Looks like python-django-project-root is nil for some reason, even though it looks fine when I evaluate it's value in the project buffer.

It may be that this started happening after upgrading to Emacs 24.4. I am using latest python-django from Marmelade (version 20140614.2014).

Can't parse management commands from IPython

if (setq python-shell-interpreter "ipython").
Each time I try calling a management command there's just this message that no commands were found:

python-django-mgmt-list-commands: Search failed: "Available subcommands:
"

With python-shell-interpreter unset, c s s opens an ipython prompt as desired, but non-django buffers start a regular python prompt.
I'm running emacs 24.5.1 and IPython 4.0.1.

An error occurred retrieving project information

I'm having an issue getting this module working with my django setup. I work on a relatively mature project so we may have an unusual directory structure. Essentially, we have...

/apps
/apps/django <-- manage.py
/apps/django/buildbox <-- settings.py
/apps/django/apps/
/apps/django/apps/[other sub-apps]

...The error I'm getting is...

Error:

Django Version: 1.5
Project: ~/work/GITDIRS/apps/django/buildbox/
Settings: buildbox.settings
Virtualenv: None

An error occurred retrieving project information.
Check your project settings and try again:

Current values:

  • python-django-project-root: ~/work/GITDIRS/apps/django/buildbox/
  • python-django-project-settings: buildbox.settings
  • python-shell-interpreter: python
    • found in /usr/bin/python

Error: End of file during parsing


Any ideas on what's going wrong? My apologies if I've missed something obvious.

app folders not shown; not able to move

App folders in the project folder are not displayed. Am I doing something wrong?
Project folder is set properly, also virtual environment.

python-django: 20150822.404
emacs: GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21)
of 2017-09-22, modified by Debian

.emacs:
(require 'django-mode)
(require 'python-django)
(global-set-key (kbd "C-x j") 'python-django-open-project)
(setq python-shell-virtualenv-path "/wd/django_test/django_course_1/env1")
(add-to-list 'load-path "
/wd/django_test/django_course_1/one")

python-django-open-project breaks if settings.py writes to stdout or stderr

The json-read-from-string in python-django-info-get-version fails if settings.py writes to stdout or stderr. Maybe very uncommon to have settings print, but one of the ones here does. :-(

There's probably an elegant solution, but my tired mind can't see it now. Redirect sys.stdout and sys.stderr to os.devnull before importing settings, then reset them after? That's the only thing I've come up with, other than hacking the print statements out of the troublesome settings.py -- which won't help the next poor soul who can't figure out why python-django-open-project isn't working.

Error importing packages with (weird?) AppConfig names/paths

django-rules (https://github.com/dfunckt/django-rules/) recommends loading the packages with

INSTALLED_APPS = (
    'rules.apps.AutodiscoverRulesConfig',
)

which leads to an ImportError on running python-django-open-project

Details: 

Error executing: /home/fritz/.pyvenvs/intranet/bin/python -c "
from __future__ import print_function
import os
import sys
from os.path import dirname, abspath
stdout = sys.stdout; stderr = sys.stderr
sys.stdout = sys.stderr = open(os.devnull, 'w')
from django.conf import settings
# Try to import json really hard
try:
    import json
except ImportError:
    from django.utils import simplejson as json
# Force settings loading so all output is sent to devnull.
settings.DEBUG
sys.stdout = stdout; sys.stderr = stderr

app_paths = {}
for app in settings.INSTALLED_APPS:
    mod = __import__(app)
    if '.' in app:
        for sub in app.split('.')[1:]:
            mod = getattr(mod, sub)
    app_paths[app] = dirname(abspath(mod.__file__))
print(json.dumps(app_paths), end='')"

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 20, in <module>
ImportError: No module named 'rules.apps.AutodiscoverRulesConfig'; 'rules.apps' is not a package

I'm not quite sure if this is good practice on django-rules' part or not, but would appreciate your help if there's an easy solution.
For the time being, I use a dirty hack

"app_paths = {}\n"
"for app in settings.INSTALLED_APPS:\n"
"    if 'rules' in app.split('.'):\n"
"        app = 'rules'\n"
"    ..."

Regards

CMS Check Command is Not Found

When I try to run the analog of python manage.py cms check after installing Django CMS, I am not able to do so because the cms command is not found. Furthermore, I cannot include a space and check because the mode seems to prevent that.

./manage.py: cms

Django 1.7 support

Hi,

python-django.el currently does not seem to work with Django 1.7 (at least with the current beta 3) -- it shows the message "Error: End of File during parsing" instead of the directory tree. I tried this with a virtualenv -- I created a new venv, installed Django 1.6.4 in there, created a new project and app, and opened it with python-django.el -- this worked. Then I updated django to 1.7b3 and it stopped working, and when I downgraded to 1.6.4, it started working again.

I don't actually know if the issue is in python-django.el or somewhere else, but to me it looks like it's a 1.7 problem. Unfortunately my elisp skills are practically non-existent, so I can't figure out what the actual problem is.

If it is an incompatibility with python-django.el and 1.7, then what are your plans on supporting 1.7?

virtualenvwrapper support.

Would you mind having virtualenvwrapper support built in?
This way the .dir-locals.el could reference only a name instead of a path and become more portable for us using venvwrapper.

easier way to run specific commands with many args?

First thanks for the great app.

I used to M-x pdb; python manage.py runserver 0.0.0.0:8000

Now, to restart the server with python-django, C-x j; m; runserver; 0.0.0.0:8000; which is quite a more work.

Is there an easier way to run management commands (such as 'run last command') ?

Does it work on Emacs 23.3 with your python.el?

I'm having trouble with Emacs 23.3, I have your python.el for emacs 23.3

M-x python-django-mode and a buffer with a template loaded complains:

"""
Symbol's function definition is void: nil
"""

Anywork arounds?

Cheers,

Error: JSON readtable error

Hello.
I got this messages:

Django Version: 1.4.5
Project: /usr/home/jeltoesolnce/data/projects/shumbely_com
Settings: shumbely_com.settings
Virtualenv: None

An error occurred retrieving project information.
Check your project settings and try again:

Current values:

  • python-django-project-root: /usr/home/jeltoesolnce/data/projects/shumbely_com
  • python-django-project-settings: shumbely_com.settings
  • python-shell-interpreter: python
    • found in /usr/local/bin/python

Error: JSON readtable error

Allow <RET> to work on text, not just widgets

If I open a Django project with M-x python-django-open-project, I get a list of apps that I can open and close by pressing on the folder widget, which acts as widget-button-press.

It would be really nice if I could also expand the apps by pressing on the app name. Perhaps even should work too.

Thanks for python-django.el -- it's excellent, especially for easily jumping into a shell :).

tab-completion in the Ipython shell invoked with `c s s`

I think this would be a nice feature to get tab-completion, and I can't imagine this being too difficult since the default run-python command in emacs has tab-completion.

If someone knows better than I, please comment.

(How do I mark this as an enhancement?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.