Hi,
On Fri, 20 Jun 2008 20:42:57 +0200, diggs <[EMAIL PROTECTED]> wrote:
> Thanks. It's actually the importing part that I don't know how to do.
>
assuming you have:
models.py:
ROLES = (
whatever
)
views.py:
import models
models.ROLES
and since you are probably interacting with
You should be able to access it in a template from an instance of a model
that uses it via:
model_instance_object.ROLES
but if you just want to access from the template generically, then yes, you
need to pass it to the template.
hth,
-richard
On 6/20/08, diggs <[EMAIL PROTECTED]> wrote:
>
>
>
Thank you. Now I'm realizing that I didn't ask my question correctly.
I want to access ROLES from within a template. Do I have to pass it to
the template each time I need it or can I access it directly somehow?
On Jun 20, 2:47 pm, Juanjo Conti <[EMAIL PROTECTED]> wrote:
> In views.py:
>
> from
In views.py:
from models import ROLES
Greets,
Juanjo
--
mi blog: http://www.juanjoconti.com.ar
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
Thanks. It's actually the importing part that I don't know how to do.
On Jun 20, 2:29 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote:
> sure, its just python:
> for r in ROLES:
> r[0] #retrieves 'Associate' the first iteration
> r[1] # also retrieves 'Associate'
>
> You just need to ensure
sure, its just python:
for r in ROLES:
r[0] #retrieves 'Associate' the first iteration
r[1] # also retrieves 'Associate'
You just need to ensure that ROLES is imported into your views.
hth,
-richard
On 6/20/08, diggs <[EMAIL PROTECTED]> wrote:
>
>
> Hello,
>
> I've defined a set of
Hello,
I've defined a set of choices in my model.py file that are used in a
particular model via the CHOICE arg. Is it possible to access these
values from a view to populate a random select list? In models:
ROLES = (
('Associate', 'Associate'),
('Role 2', 'Role2'),
)
I don't want to
7 matches
Mail list logo