After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 533758 - django project creation fails
django project creation fails
Status: RESOLVED FIXED
Product: anjuta
Classification: Applications
Component: plugins: project-wizard
2.4.x
Other All
: Normal minor
: ---
Assigned To: Sébastien Granjoux
Anjuta maintainers
Depends on:
Blocks:
 
 
Reported: 2008-05-18 21:40 UTC by Michael Placentra II
Modified: 2008-05-21 19:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Full error details from message window (165 bytes, text/plain)
2008-05-18 21:41 UTC, Michael Placentra II
  Details
Fix (2.19 KB, patch)
2008-05-20 20:24 UTC, Sébastien Granjoux
none Details | Review
fix with conditional bash (2.47 KB, patch)
2008-05-20 22:28 UTC, Michael Placentra II
accepted-commit_now Details | Review

Description Michael Placentra II 2008-05-18 21:40:33 UTC
Please describe the problem:
Anjuta tries to run `django-admin.py startproject `, but in the version in Ubuntu 8.04's package repo (django 0.96.1, currently the latest stable is 0.96.2) the program would be `django-admin` (I guess it used to have .py but that was changed, or maybe the Ubuntu people changed it because the Django documentation currently says to use .py).

Also, if I take the command the message window says it tried to run and take off the .py, it still fails because the command must include a package name. This command:
  django-admin.py startproject
... does not work for me unless it is written like this:
  django-admin startproject mynewproject

Also, when including the project name, django puts the project files within a folder named that, so the project would end up in a subfolder within the anjuta project.

Steps to reproduce:
1. On Ubuntu 8.04, install the Django framework package (python-django)
2. In Anjuta, create a new Django project

Actual results:
Executing: sh -c 'cd /home/mike/Projects/django-deleteme && django-admin.py startproject '
sh: django-admin.py: not found

Expected results:
not that

Does this happen every time?
yes

Other information:
A temporary workaround would be:
 1- Create the project manually:
     django-admin createproject mynewproject
 2- Duplicate django-admin to django-admin.py so that Anjuta does not give up when `sh` can't find django-admin.py, even though when Anjuta runs it it won't do anything:
     ln -s `which django-admin` /usr/local/bin/django-admin.py
 3- Create the project through Anjuta in the directory that was just created by `django-admin`.

I think that the project name being absent from the `django-admin startproject ...` command may not be intended, since the command is run with a space at the end, so maybe a variable that was supposed to be appended was empty or something.
Comment 1 Michael Placentra II 2008-05-18 21:41:08 UTC
Created attachment 111118 [details]
Full error details from message window

note the space at the end of the command
Comment 2 Sébastien Granjoux 2008-05-19 19:14:15 UTC
Yes, there is a missing argument after startproject but I don't know why.

I have changed recently the project-wizard file. So could you try to use the most recent file from svn trunk. I think there is no need to change the code, so you can just get plugin/project-wizard/template/django.wiz from svn trunk and put it at /usr/share/anjuta/project (Save your current django.wiz before).

Then try again, I'm afraid it will fail in the same way but we will start from something better.

I have added a new feature in trunk, so perhaps you need to remove the attribute restriction="filename" in property named "Name" (line 10) in the django.wiz file.

Comment 3 Michael Placentra II 2008-05-19 21:49:18 UTC
Thanks for looking into this, Sébastien.

I found that in revision 3940, /trunk/plugins/project-wizard/templates/django.wiz has a new bug in the code change, which is that near the end of line 26 there is a " without the semicolon. Before fixing it, Anjuta will not reach the step that this bug involves.

After putting that semicolon in, it does still fail the same way it did with the old django.wiz, with or without restriction="filename" in line 10.

Although in the run action line (26) [+NameHLower+] does not work, I'm sure it works in the other actions because Anjuta does open the new .anjuta project from the next line.
Comment 4 Sébastien Granjoux 2008-05-20 20:22:27 UTC
Thanks for reporting this. I have never used django, so I don't really check this.

Yes, there is an error in the django .wiz file. The problem is that values of variables are available on the next page only. And here, the NameHLower use the vallue Name define in the same page. It get an empty string. For django project which has only one page, it's a bit more complex to write but here is a fix.

I'm justing adding a patch could you check that it's working.

Then, I still not sure how to handle the missing .py. I have installed django here (Mandriva) and it doesn't work if I don't put the .py extension (contrary to Ubuntu). Perhaps it's a bug in Ubuntu package ?

Currently, I have added two lines one with .py and one without. So we can expect that at least one command is working and will do the right thing but it's not very clean.

Do you have a better idea ?

If it's working for you, I will commit this in anjuta 2.4, trunk and close this bug.
 
Comment 5 Sébastien Granjoux 2008-05-20 20:24:35 UTC
Created attachment 111259 [details] [review]
Fix

A fix for django project template. It should fix the following:
- the missing ;
- the empty NameHLower
- the missing .py on Ubuntu
Comment 6 Michael Placentra II 2008-05-20 22:08:37 UTC
Your patch fixes the problem and makes the creation of Django projects work.

As for the Ubuntu .py problem, in the .deb package they actually renamed django-admin.py to django-admin in /usr/bin, perhaps as a convenience because having executables with language-specific extensions might be un-debian-like. And it's not just Ubuntu that has it set up like this, that package originated in Debian's repository. I looked on packages.debian.org to be sure, and it is the same way in the Debian repository.

So I'll go to http://bugs.debian.org/python-django and let them know about this problem. I think the best long-term solution would be for them to keep it with the .py and symlink to have it without the .py. If they do that, both commands in your patch would run successfully and I don't know whether that would cause unwanted results.

Running the command with a short bash conditional is working for me, I'll upload a patch for a working django.wiz with it. This is an example of that command:
if [ ''`which django-admin` != '' ]; then `which django-admin` startproject newprojname; else `which django-admin.py` startproject newprojname; fi;
Comment 7 Michael Placentra II 2008-05-20 22:28:24 UTC
Created attachment 111266 [details] [review]
fix with conditional bash

This includes the changes in Sébastien Granjoux's patch but it runs django-admin with or without the .py depending on which is available instead of trying both ways. It works on my system, but I don't write bash code often so who knows what it will do elsewhere. Also, it is harder to read.
Comment 8 Michael Placentra II 2008-05-20 22:32:23 UTC
Comment on attachment 111266 [details] [review]
fix with conditional bash

Oops! I edited into the diff at the top that the new version is revision 3490, but actually the old version is 3490. Sorry!
Comment 9 Sébastien Granjoux 2008-05-21 19:35:27 UTC
Thanks for your patch. I probably have written even less bash code than you so I couldn't do better. I have committed your patch in anjuta 2.4 and in svn trunk. It should available in the next release.