Re: Apache2 mod_python VirtualHost configuration
It seems that now the links to stylesheets and javacript files are not mapping properly, when i run my project site under Apache. How can I fix it? I was looking through documentation and searching a bit online, but didn't find a solid answer to this issue.
Re: Apache2 mod_python VirtualHost configuration
Thanks, Bryan! Works fine. One thing, which I did not do was to modify Postgres host configuration to allow for connections from 'GoodCompany'. A small thing, but it will raise error if it's not configured properly.
blog archive links
I'm building myself a little blog with the django blog app that is found in the djangoproject.com code. I like the archive links (seen on the right-hand side of http://www.djangoproject.com/weblog/). However, I'd like those links auto-generated according to whether there are blog entries for those dates. As it stands now, I'd have to put those links in by hand, and if I put in a link to, say, /2005/dec/, and there were no blog entries posted in December 2005, that link returns a 404 (using the date-based generic view). Any recommendations on how to automate this and avoid 404 links? Bryan
Re: Apache2 mod_python VirtualHost configuration
On 1/16/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > My VirtualHost config look now like this: > > > ServerName GoodCompany I don't think you want this: > DocumentRoot "/work/django/GoodCompany" > > allow from all > Options All > I'm pretty sure you don't want your web server serving up the python files from your django application. > > > SetHandler mod_python > PythonHandler django.core.handlers.modpython > PythonPath sys.path+['/work/django'] > SetEnv DJANGO_SETTINGS_MODULE GoodCompany.settings > PythonDebug On > The above looks ok. I have 'SetHandler python-program', I think which one you use depends on your version of mod_python. You might google further on that one. > > > SetHandler None > > That looks fine. > > I put 'GoodCompany' instead of 'goodcompany' in ServerName and > DocumentRoot directives. Also, I commented #(r'^admin/', > include('django.contrib.admin.urls.admin')), in urls.py. The site Again, don't point your DocumentRoot at your django app. I have it still pointing to my old document root where some old, dare I mention it, php files are sitting now unused. You should make sure the admin urls are *un* commented. Bryan
Re: Apache2 mod_python VirtualHost configuration
My VirtualHost config look now like this: ServerName GoodCompany DocumentRoot "/work/django/GoodCompany" allow from all Options All SetHandler mod_python PythonHandler django.core.handlers.modpython PythonPath sys.path+['/work/django'] SetEnv DJANGO_SETTINGS_MODULE GoodCompany.settings PythonDebug On SetHandler None I put 'GoodCompany' instead of 'goodcompany' in ServerName and DocumentRoot directives. Also, I commented #(r'^admin/', include('django.contrib.admin.urls.admin')), in urls.py. The site greets me with a blue welcome, but when i go to **http://goodcompany/admin**, of course i see the welcome message again. How can I access admin section? Should my urls be mapped in .htaccess now?
Re: Apache2 mod_python VirtualHost configuration
expect solutionthe same question 2006/1/17, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: Actually, I had messed up my DocumentRoot and /etc/host file which waspointiong to my PHP projects path. The Welcome screen was from symfony framework, which I had installed previously.Now, after I fixed it, I'm getting this error:Mod_python error: "PythonHandler django.core.handlers.modpython"Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line299, in HandlerDispatchresult = object(req) File"/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 165, in handlerreturn ModPythonHandler()(req) File"/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py",line 130, in __call__from django.conf import settings File "/usr/lib/python2.4/site-packages/django/conf/settings.py", line34, in ?raise EnvironmentError, "Could not import %s '%s' (is it onsys.path?): %s" % (ENVIRONMENT_VARIABLE, me.SETTINGS_MODULE, e)EnvironmentError: Could not import DJANGO_SETTINGS_MODULE'GoodCompany.settings' (is it on sys.path?): No module namedGoodCompany.settingsI guess there must be something wrong with my PythonPath setting. If my project is located in /work/django/GoodCompany and'GoodCompany.settings' is loaded when I run internal server, whatshould I put in VirtualHost configuration? My current VirtualHostconfig looks like this: ServerName goodcompany SetHandler mod_python PythonHandler django.core.handlers.modpython PythonPath sys.path+['/work/django/GoodCompany'] SetEnv DJANGO_SETTINGS_MODULE GoodCompany.settings PythonDebug On DocumentRoot "/work/django/GoodCompany" allow from allOptions All SetHandler None -- www.mawei.name PetitIM:[EMAIL PROTECTED]13585201588
Re: Apache2 mod_python VirtualHost configuration
Actually, I had messed up my DocumentRoot and /etc/host file which was pointiong to my PHP projects path. The Welcome screen was from symfony framework, which I had installed previously. Now, after I fixed it, I'm getting this error: Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 165, in handler return ModPythonHandler()(req) File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 130, in __call__ from django.conf import settings File "/usr/lib/python2.4/site-packages/django/conf/settings.py", line 34, in ? raise EnvironmentError, "Could not import %s '%s' (is it on sys.path?): %s" % (ENVIRONMENT_VARIABLE, me.SETTINGS_MODULE, e) EnvironmentError: Could not import DJANGO_SETTINGS_MODULE 'GoodCompany.settings' (is it on sys.path?): No module named GoodCompany.settings I guess there must be something wrong with my PythonPath setting. If my project is located in /work/django/GoodCompany and 'GoodCompany.settings' is loaded when I run internal server, what should I put in VirtualHost configuration? My current VirtualHost config looks like this: ServerName goodcompany SetHandler mod_python PythonHandler django.core.handlers.modpython PythonPath sys.path+['/work/django/GoodCompany'] SetEnv DJANGO_SETTINGS_MODULE GoodCompany.settings PythonDebug On DocumentRoot "/work/django/GoodCompany" allow from all Options All SetHandler None
Re: Apache2 mod_python VirtualHost configuration
On 1/16/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi, there! > > I found Django this afternoon and was impressed by what I found. After > getting the framework from SVN trunk and installing it on my Fedora > server, I followed the first 2 parts of the tutorial. Worked great and > i got the admin section up in no time. (Awesome stuff!). > > I run my little project on the internal server, but soon found that i > had to restart it every time I introduced a syntax error into the code > and refreshed the page. This led me to try to setup my Apache2.2 with > mod_python, thinking I would avoid frequent restarting of the internal > server. > > After added this configuration to the end of httpd.conf: > > > ServerName goodcompany > SetHandler mod_python > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE GoodCompany.settings > PythonDebug On > > SetHandler None > > > > ... and restarting Apache, I pointed my browser to > **http://goodcompany/** (I added '127.0.0.1 GoodCompany' to my > /etc/hosts file) and was greeted with the welcome page. However, I > could not access the admin section of my project and got 404 error. > > Is there something I'm doing wrong? What could be the problem? > Inside my VirtualHost I put a and put the mod_python/django stuff inside that and that's what works for me. Bryan
Apache2 mod_python VirtualHost configuration
Hi, there! I found Django this afternoon and was impressed by what I found. After getting the framework from SVN trunk and installing it on my Fedora server, I followed the first 2 parts of the tutorial. Worked great and i got the admin section up in no time. (Awesome stuff!). I run my little project on the internal server, but soon found that i had to restart it every time I introduced a syntax error into the code and refreshed the page. This led me to try to setup my Apache2.2 with mod_python, thinking I would avoid frequent restarting of the internal server. After added this configuration to the end of httpd.conf: ServerName goodcompany SetHandler mod_python PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE GoodCompany.settings PythonDebug On SetHandler None ... and restarting Apache, I pointed my browser to **http://goodcompany/** (I added '127.0.0.1 GoodCompany' to my /etc/hosts file) and was greeted with the welcome page. However, I could not access the admin section of my project and got 404 error. Is there something I'm doing wrong? What could be the problem? I'd love to start using Django. But first, I'd like to iron out these small initial hurdles. I'm hoping for a little help here.
Re: Apache2 - Mod_python: ValueError: Empty module name
It used to be that if user does not define the environment variable, django tell us with a more helpful line like "Environment variable DJANGO_SETTINGS_MODULE is undefined". Adrian Holovaty wrote: On 1/16/06, Krietjur <[EMAIL PROTECTED]> wrote: line 32, in ? mod = __import__(me.SETTINGS_MODULE, '', '', ['']) ValueError: Empty module name Hey Krietjur, This error is happening because mod_python isn't finding your settings module. Do you have the line "SetEnv DJANGO_SETTINGS_MODULE foo" in your httpd.conf, where "foo" is the Python path to your settings module? Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org
Re: making slug field unique
Afaik Django enforces uniqueness at the application level, but you could always add it to the database: ALTER TABLE table ADD UNIQUE (slug) I don't think it's a bad idea at all, it all depends ;) On 1/16/06, Bryan Murdock <[EMAIL PROTECTED]> wrote: > > I think I want my model's SlugField to be unique (let me know if this > is a Bad Idea for any reason). So I edit my model and change > slug=meta.SlugField() to slug=meta.SlugField(unique=True). Do I need > to do anything to update the database now? > > Thanks, > > Bryan >
Re: Comparing model objects ...
Actually, you know, I'm getting several situations where that comparision is failing, but if I explicitely do foo.id = blah.id it works. Looks like a bug. It seems to occur when I a foreign key lookup like: if foo.get_blah() == myBlah: # doesn't always work ... while if foo.get_blah().id == myBlah.id: # works (Now I have to read the website again to see what the bug submission process is)
making slug field unique
I think I want my model's SlugField to be unique (let me know if this is a Bad Idea for any reason). So I edit my model and change slug=meta.SlugField() to slug=meta.SlugField(unique=True). Do I need to do anything to update the database now? Thanks, Bryan
Re: Apache2 - Mod_python: ValueError: Empty module name
On 1/16/06, Krietjur <[EMAIL PROTECTED]> wrote: > line 32, in ? > mod = __import__(me.SETTINGS_MODULE, '', '', ['']) > > ValueError: Empty module name Hey Krietjur, This error is happening because mod_python isn't finding your settings module. Do you have the line "SetEnv DJANGO_SETTINGS_MODULE foo" in your httpd.conf, where "foo" is the Python path to your settings module? Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org
Apache2 - Mod_python: ValueError: Empty module name
I've setup a Gentoo Linux server for use with django, but I have some difficulties with the apache configuration I think. The python webserver works fine, but now I want to have it working with apache2 and mod_python. I've a config like in the tutorial (http://www.djangoproject.com/documentation/modpython/). Apache runs fine, but when I browse to my website I get this error: Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/handlers/modpython.py", line 165, in handler return ModPythonHandler()(req) File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/handlers/modpython.py", line 130, in __call__ from django.conf import settings File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/conf/settings.py", line 32, in ? mod = __import__(me.SETTINGS_MODULE, '', '', ['']) ValueError: Empty module name I'm very new to Django (just discovered it today :D), and I have no idea where to look for the problem and for more information about my config. Please help! :)
JOB POSTING: Toronto,Ontario,Canada
Hi, While the job posting below is relatively generic. What we are really looking for is someone to help us build next generation of our websites in Django. If you are interested please email your resumes to: [EMAIL PROTECTED] ST. JOSEPH MEDIA POSITION: Web Developer REPORTS TO: VP, IMS LOCATION: 111 Queen Street East STATUS: Contract HOURS OF WORK: Full-time DEADLINE FOR RESUMES: January 30th, 2006 Summary: The Web Developer will develop, organize, document and maintain dynamic Web pages, Web applications and Web interfaces as directed by the Project Manager. Responsibilities: Build and maintain dynamic Web pages and Web applications Develop architectures of Web sites including server and client side scripting and database design Participate in developing application requirements, specifications and time lines and is involved in all aspects of web development process, from architecture to development and implementation through deliverable phase Work with other team members to meet goals and deadlines Maintain accurate and up-to-date documentation on all application systems Qualifications and Requirements: The successful candidate will: Have post secondary training in Computer Science or equivalent experience. Be experienced in software development cycle (University projects are acceptable). Possess the ability to use procedural and object oriented methodologies Have strong programming skills in at least one of following languages: Python,Perl,C,C++,Ruby,Java or C#. Be familiar with SQL systems such as Microsoft SQL, MySQL, Oracle, Postgres SQL. Be familiar with Internet standards such as HTTP,HTML,XHTML,SMTP. Be familiar with Unix and Microsoft platforms. Possess knowledge of Cold Fusion is an asset.
Re: Dreamhost - problem with Django installation
PythonistL wrote: Hello James, I assume it was not a private letter. do you use their service at present? I am hosted with DreamHost: http://lazutkin.com/ I followed the instructions at http://wiki.dreamhost.com/index.php/Django but that did not work for me It worked for me. Did you followed them precisely? So I tried this script from the troubleshooting part there # #!/usr/bin/python2.3 from fcgi import WSGIServer def test_app(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield 'Hello, world!\n' WSGIServer(test_app).run() # but it did not work either. Works for me. It looks like you don't have FastCGI enabled. 1) Go there: http://wiki.dreamhost.com/index.php/Django 2) Section #1 (Prerequisites), instruction #1: "FastCGI must be enabled". 3) Go to DreamHost Control Panel (Domains / Manage Domains), click on "edit" for your domain, and enable FastCGI. Can you please let me know if that script works for you? It does. Thanks, Eugene
Re: Retrieving choices from model->field->choices
Thanks guys, Person._meta.get_field('height').get_choices() worked just fine. Needed it for my custom manipulator. Regards, Mike
Re: django 0.90 -> 0.91 : raw_id_admin representation changed: HELP!
On 1/16/06, Emanuele <[EMAIL PROTECTED]> wrote: > - in Django0.90 there will be a piece of text showing the __str()__ > representation on that Author just over that ID > - in Django0.91 that string disappears, so the user cannot know if the > author's ID he inserted was correct. The same happens in SVN version. Hi Emanuele, I just tested this using Django's SVN version, and raw_id_admin=True did indeed work properly. The string representation of the related object was displayed. I didn't test this on Django 0.91, but I assume it would work there, too. We haven't made any changes to the raw_id_admin handling in SVN since 0.91 was released. I suspect you're using custom admin templates that somehow override the raw_id_admin functionality. There were quite a few changes to admin templates between 0.90 and 0.91, so, if you're customizing admin templates, it's probably best to start from the "real" templates rather than retrofitting 0.90-style admin templates to fit the template scheme 0.91 expects. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org
Re: Dreamhost - problem with Django installation
I can recomment rimuhosting (http://rimuhosting.com) for a VPS setup- that means you can install/run what you like. They will setup most stuff if you put what you want into your order. Support, the few times I've needed it, has been great. I don't have Django on that setup, yet- just got lighttpd running so I can switch off apache before cranking up mysql. Derek
Re: django 0.90 -> 0.91 : raw_id_admin representation changed: HELP!
> I've just upgraded from Django0.90 to Django0.91 my production server (running a django app on a LAN). [kicks tires a bit] Yep, thar's yer problem right there. Ya put tha tires on backwards. Seriously, you should plan a little better than that! First of all it is known the 0.x is not backward compatible. Second of all - it doesn't matter! You should always test before the upgrade. Given how portable Django is this should be quite easy. As for the admin changes, I would check the HEAD of the html to make sure you are using RelatedObjectLookups.js. Given the new-admin changes, you might need to add the script in your {% block extrahead %} of the template. -rob
django 0.90 -> 0.91 : raw_id_admin representation changed: HELP!
Hi djangonauts, I've just upgraded from Django0.90 to Django0.91 my production server (running a django app on a LAN). Everything works well except the representation of fields with raw_id_admin=True when using admin interface. My application strongly relies on automatically generated admin interface so even small changes from admin to new-admin are relevant. And this one is not so small to me. Let me describe the problem with an example taken from the usual Poll and Choice. Assume my model is made of a class Choice that refers to Poll and Author. Assume the Choice.poll's ForeignKey is editable inline and Choice.author's ForeignKey has raw_id_admin=True: class Poll(meta.Model): question = ... pub_date = ... class Author(meta.Model): name = ... def __str(self)__: return name class Choice(meta.Model): poll = meta.ForeignKey(Poll, edit_inline=meta) choice = ... author = meta.ForeignKey(Author, raw_id_admin=True) The 'detail' admin interface of a Poll object will show one entry of Choice that has the author field represented by a text entry where users can insert authors'IDs. After inserting an ID and saving the form, if you go back to the detail page you'll see the ID value previously inserted, BUT: - in Django0.90 there will be a piece of text showing the __str()__ representation on that Author just over that ID - in Django0.91 that string disappears, so the user cannot know if the author's ID he inserted was correct. The same happens in SVN version. Now my users ask me to go back to the situation of Django0.90, where they could see that piece of text explains the meaning of the ID. I don't want to go back to 0.90, but instead I prefer to hack Django a bit and use 0.91 (or svnversion). I'm currently studying Django code, but if you can help me and give suggestions for a solution I will appreciate it very much. Thanks in advance, Emanuele P.S.: changing author field and removing raw_id_admin=True is not a good solution in my case.
Re: Bulk delete?
> >things.delete(type__exact='foo') ... > > Have I overlooked something? > > Nope - *we've* overlooked something; this totally should be > possible. I've opened a ticket so we can keep track of this (http:// > code.djangoproject.com/ticket/1219). I've just submitted a patch on magic-removal to this ticket that implements bulk delete; the syntax is similar to that originally proposed, except that the delete method is on the Manager, rather than the class itself: Things.objects.delete(type__exact='foo') Any query that is legal for get_list() et al should be legal in delete(), with the exception of anything requiring a join. DELETE FROM foo INNER JOIN bar... isn't legal, so any query that requires a join will cause the delete() to throw an exception. Any objections to this commit? Or are the impending descriptor changes going to render this patch immediately obsolete? Russ Magee %-)
Re: Dreamhost - problem with Django installation
Hello James, do you use their service at present? I followed the instructions at http://wiki.dreamhost.com/index.php/Django but that did not work for me So I tried this script from the troubleshooting part there # #!/usr/bin/python2.3 from fcgi import WSGIServer def test_app(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield 'Hello, world!\n' WSGIServer(test_app).run() # but it did not work either. Can you please let me know if that script works for you? Thank you Regards, L.
Re: Dreamhost - problem with Django installation
Their (DreamHost) prices are ridiculous (ie low), and to keep them low, they can only spend time on things that have an identified market (they say this in their FAQs or KnowledgeBase or whatever its called). It's the main reason they don't provide PostGres. I guess FCGI for Django hasn't hit the big time for them... I've looked at Dreamhost (cheap, ridiculous storage and bandwidth, very much mass-market driven), TextDrive (not as cheap as DreamHost, but still good, ok storage and bandwidth, PostGres and other nice bits of software - but weird usage 'no webdevelopment'), A2 (from www.43folders.com) (cheap, low storage and bandwidth, PostGres or MySQL), Zettai (more expensive, unlimited domains, PostGreSQL and/or MySQL, Zope and Plone) and Gypsy hosting (same price as Zettai - $24.95/month, full Django, Postgres, Apache2, ok storage and bandwidth - currently not taking any more signups) I've not plonked down money for any of them yet. So you pays your money and you takes your choice... ;) Cheers, Tone
Re: Dreamhost - problem with Django installation
On 1/16/06, PythonistL <[EMAIL PROTECTED]> wrote: > Does it mean Dreamhost stopped Django support?? Perusing the Django-powered sites that are known to be hosted at Dreamhost, none of them seem to be down, so Django apparently still works just fine on Dreamhost. Most likely their response was meant to indicate that Dreamhost will only provide official technical support and assistance with FCGI for Rails use, so if you want to use another framework you'll be on your own for figuring out how to make it work. -- "May the forces of evil become confused on the way to your house." -- George Carlin
Re: Retrieving choices from model->field->choices
On 1/16/06, Mike <[EMAIL PROTECTED]> wrote: > > How do I do that? To retrieve a field's choices from the model? > > class Person(meta.Model): > height = meta.CharField(maxlength=100, > choices=(('tall','Tall'),('short','Short'))) > > >>> Person.height.choices # In the magic removal branch, you are correct: Person.height.choices will give you the original list of tuples used at instantiation. If you want the list that is used for display purposes, try: >>> Person.height.get_choices() This will include "---" (Undefined) in the list of choices returned. There are some optional parameterrs on this method if you need to customize the output; see core/db/models/fields/__init__.py for details. In v0.90, v0.91 or trunk, you need to go through the meta object associated with the model class to get to the Field object that stores the choices: >>> Person._meta.get_field('height').choices >>> Person._meta.get_field('height').get_choices() Yours, Russ Magee
Re: create object method
The Boss wrote: that was needed. one problem with django i guess is figuring out what exactly are the correct names and hierarchy, Precisely, which is why the magic-removal branch has changed this particular annoyance (model classes now don't jump to a different namespace) and a few others. I had enough problems dealing with the magic that I went ahead and moved my development to magic-removal... See http://code.djangoproject.com/wiki/RemovingTheMagic -- --Max Battcher-- http://www.worldmaker.net/ "History bleeds for tomorrow / for us to realize and never more follow blind" --Machinae Supremacy, Deus Ex Machinae, Title Track
Re: create object method
thanks Joseph! that got me on the right track. it wasn't quite... from django.models.mypp.group import Group but... from django.models.mypp import groups that was needed. one problem with django i guess is figuring out what exactly are the correct names and hierarchy, but i just took the clue from the import line in tutorial 1 for the interactive shell and imported the module 'groups', since I guess Group is actually just the name of the class def, and the latter version seems more consistent with what I see elsewhere in django. But most important i didn't realize i could import this directly into a method of this class that will become a module. thanks again.