Hello everyone, finally after 3 weeks without Internet and django
installed to play with i can ask questions.

Firstly about the model, i am doing a recipes website to learn django
and / utility.

Here is a small part of the recette.py model of recettes app


DIFFICULTY_CHOICES = (
        (1, 'Simple'),
        (2, 'Intermedaire'),
        (3, 'Difficile'),
)       
        

class Recette(meta.Model):
...
        difficulte = meta.SmallIntegerField(choices = DIFFICULTY_CHOICES)
...

That works fine,nowin my template when i do {{recette.difficulte }} i
got the number 1,2 or 3 not the name of the difficulty.
SInce DIFFICULTY_CHOICES is not defined as a global variable and it is
not allowed to put DIFFICULTY_CHOICES in class;
the following trick doesnt work.

def category_name(self, number):
     return CATEGORY_CHOICES[number][1]

What is a good solution to get the corresponding name associated to the
number ? 

----------------
An other question is related to mod apache
i have the following httpd.conf 

<VirtualHost *>
        <Location "/cefinban/">
            SetHandler python-program
            PythonHandler django.core.handlers.modpython
            PythonPath sys.path+['/home/greg/Projects']
            SetEnv DJANGO_SETTINGS_MODULE cefinban.settings
            PythonDebug On
        </Location>
        Alias /media "/var/www/cefinban/media"
        <Location "/media/">
                SetHandler None
        </Location>
</VirtualHost>

alink to http://127.0.0.1/cefinban/ works well, however
i have to modifie my url.py file previously

urlpatterns = patterns('',
        (r'^recettes/$', 'cefinban.recettes.views.index'),
        (r'^recettes/(?P<recettes_id>\d+)/$',
'cefinban.recettes.views.detail'),
        .....
)

to (r'^cefinban/recettes/(?P<recettes_id>\d+)/$',
'cefinban.recettes.views.detail'), ...

I guess this is not the food way, i would like not to need to put
cefinban before recette only because of the location "/cefinban/".

Thank you for your help, django roxxs.



Reply via email to