Problems creating custom multi-widget....

2009-11-21 Thread mediumgrade
I am trying to create my own Dojo-aware Django widgets. I have defined
the following


class DojoDateWidget(forms.widgets.DateTimeInput):
format = '%Y-%m-%d'

def __init__(self, *args, **kwargs):
kwargs.setdefault('attrs', {}).update({'dojoType':
"dijit.form.DateTextBox",
  'required': kwargs.pop
('required', False),
  'constraints': mark_safe
("{datePattern:'MM/dd/'}"),
  })
attrs = kwargs['attrs']

if kwargs.get('promptMessage', None) is not None:
attrs['promptMessage'] =  kwargs.pop('promptMessage')

super(DojoDateWidget, self).__init__(*args, **kwargs)



class DojoTimeWidget(forms.TimeInput):

input_type = 'text'

def __init__(self, *args, **kwargs):
kwargs.setdefault('attrs', {}).update({'dojoType':
"dijit.form.TimeTextBox",
  'required': kwargs.pop
('required', False),
  #'constraints': mark_safe
("{timePattern:'HH:mm'}"),
  })
attrs = kwargs['attrs']

if kwargs.get('promptMessage', None) is not None:
attrs['promptMessage'] =  kwargs.pop('promptMessage')

self.input_formats =  ['T%H:%M:%S']

super(DojoTimeWidget, self).__init__(*args, **kwargs)


def render(self, name, value, attrs=None):
if value is None:
value = ''
elif isinstance(value, time):
value = value.replace(microsecond=0)

#For Dojo TimeTextBox formatting.
#Requires T14:30:59 (there's a 'T' in front)
value = 'T%s' % value

return super(DojoTimeWidget, self).render(name, value, attrs)



class DojoDateTimeWidget(forms.widgets.MultiWidget):

def __init__(self, attrs=None):
widgets = (DojoDateWidget, DojoTimeWidget)
super(DojoDateTimeWidget, self).__init__(widgets, attrs)

def decompress(self, value):
if value:
return [value.date(), value.time().replace(microsecond=0)]
return [None, None]



The DojoDateWidget and DojoTimeWidget validate correctly when
submitting in a form. However, when I leave the DojoDateTimeWidget
blank in a form, Django sees the empty values as ['', ''] as opposed
to simply None which causes the form validation to say that the date
time format is invalid. I see that the decompressed null value for the
widget is "return [None, None]" but this is the same as the Django
built-in SplitDateTimeWidget and when I simply return "None" I get the
error message "'NoneType' object is unsubscriptable". How do I get my
datetime widget to correctly send an empty value?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Can I tell IE not to cache data?

2009-09-17 Thread mediumgrade

I have several views which generate some JSON data. They all end
something like this:

response = HttpResponse(pie_data, mimetype='application/json')
response['Content-Disposition'] = 'attachment;
filename=my_pie_chart.json'

Where "pie_data" is holding some generated JSON data that I wish to
send back to my application. However, Internet Explorer keeps caching
this data which is messing up the JavaScript components that are
actually using it. Is there something I can inject in the HTTP header
to prevent IE from caching the data? Neither Firefox nor Chrome seems
to exhibit this behavior.

Any help would be appreciated. Thank you so much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom function to serve a static file with Django...

2009-05-06 Thread mediumgrade

I know of the "standard" way of serving static files in Django for
development purposes, but I want to create my own function which reads
the contents of a file then serves it to the user (I want to put some
security around the downloading of the file).

What is the best way to accomplish this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Some help creating custom widgets...

2009-03-03 Thread mediumgrade

I am planning to create a series of widgets for Dojo. I just need a
little help getting started:

First, I need to know how to set custom attributes in a widget. The
most important thing to set is "dojoType." For most widgets, I plan to
use the TextInput widget as my base.

Secondly, I would like to know how I can set the "Select" widget to
NOT display the "" placeholder for the empty option. Dojo has
it's own way of handling this. Can I access the "required"  attribute
from a widget? Can I simply "pop" this option off the "choices" list?

I think that should be enough to get me going. Can anyone help me out
a bit?

Thanks,

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Validation problems with formset_factory

2009-02-23 Thread mediumgrade

Worked like a charm. It was the ModelChoice field. It was trigging the
errors because of the initial value I was setting.

On Feb 20, 7:48 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Fri, 2009-02-20 at 19:32 -0800, mediumgrade wrote:
> > So, I have a form like this:
> > 
> > class AddUserForm(forms.Form):
> >     username = forms.CharField(label='Username', required=False)
> >     password1 = forms.CharField(label='Password',
> > widget=forms.PasswordInput)
> >     password2 = forms.CharField(label='Password (Again)',
> > widget=forms.PasswordInput)
> >     first_name = forms.CharField(label='First Name')
> >     last_name = forms.CharField(label='Last Name')
> >     email = forms.EmailField(label='Email')
> >     group = forms.ModelChoiceField(label='Group',
> > queryset=Group.objects.all())
> >     team = forms.ModelChoiceField(label='Team',
> > queryset=Team.objects.all())
>
> >     def save(self):
> >         //Some custom procedures here
> >         return u
>
> So in the interests of effective debugging, what happens when you reduce
> this to the simplest possible example? In this case, that would be a
> form with exactly one field. Say, the "username" field and nothing else.
> If that works, add in another field. Rinse, wash, repeat, until the
> problem appears. Then try to remove the fields that you already know
> work, etc.
>
> I would expect that you will be able to get it down to a form containing
> only one or two fields that demonstrates the problem.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Validation problems with formset_factory

2009-02-20 Thread mediumgrade

So, I have a form like this:

class AddUserForm(forms.Form):
username = forms.CharField(label='Username', required=False)
password1 = forms.CharField(label='Password',
widget=forms.PasswordInput)
password2 = forms.CharField(label='Password (Again)',
widget=forms.PasswordInput)
first_name = forms.CharField(label='First Name')
last_name = forms.CharField(label='Last Name')
email = forms.EmailField(label='Email')
group = forms.ModelChoiceField(label='Group',
queryset=Group.objects.all())
team = forms.ModelChoiceField(label='Team',
queryset=Team.objects.all())

def save(self):
//Some custom procedures here
return u

And I use it in a view like so:

AddUserFormset = formset_factory(AddUserForm, extra=10, max_num=0)

if request.method == 'POST':
formset = AddUserFormset(request.POST, request.FILES)

#If formset is valid
if formset.is_valid():
#Do some stuff with the forms

return render_to_response('profiles/
profile_add_users.html', { 'formset':formset,  },
context_instance=RequestContext(request))

#Something was wrong with the formset
else:
return render_to_response('profiles/
profile_add_users.html', { 'formset':formset },
context_instance=RequestContext(request))

For some reason, all of the fields in the forms I leave blank give me
"This field is required" errors and formset.is_valid() keeps failing.
Is there something I am missing? Isn't the formset supposed to be
smart enough to see that forms will all empty fields should be
ignored?

Any ideas
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Filtering one form field with value from another...

2009-01-15 Thread mediumgrade

Currently, I have a series of models which look something like this:


class make(model.Models):
name = models.CharField()

class model(model.Models):
name = models.CharField()
make = models.ForeignKey(Make)

class claim(models.Model):
make = models.ForeignKey(Make)
model = models.ForeignKey(Model)

In my model form, I would like to dynamically filter the list of
models by the selected make. What is the best way to accomplish this?
Is there a way to do this in ajax so that the field is updated as the
user selects the make?

Thank you
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using field choices in a template...

2007-04-08 Thread mediumgrade

Thanks a lot, James.

On Apr 1, 12:22 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 3/31/07, mediumgrade <[EMAIL PROTECTED]> wrote:
>
> > I have a model with charfield's with choices attached to them. In my
> > templates, however, I would like to be able to display the values from
> > the dictionary list in my models, not just the value stored in the
> > database.
>
> This is covered in the database API documentation:
>
> http://www.djangoproject.com/documentation/db-api/#get-foo-display
>
> (and a link to that is provided in the model documentation for the
> "choices" argument)
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Date field widget for generic views...

2007-03-31 Thread mediumgrade

I am writing an app that makes heavy use of generic views. I have
several forms which include date fields and I want to know how to
attach a widget to the field for entering the date (like the one used
in the admin site).

Am I making sense?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using field choices in a template...

2007-03-31 Thread mediumgrade

I have a model with charfield's with choices attached to them. In my
templates, however, I would like to be able to display the values from
the dictionary list in my models, not just the value stored in the
database.

Am I making sense?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Authentication Issues...

2007-03-24 Thread mediumgrade

Totally fixed me up. Thanks!

On Mar 19, 9:33 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 3/19/07, mediumgrade <[EMAIL PROTECTED]> wrote:
>
> > I am not sure what the difference is between RequestContext and
> > Context (I am still fairly new to Django and Python).
>
> RequestContext automatically adds some extra variables to the context
> of every template that uses it; exactly which variables depends on the
> TEMPLATE_CONTEXT_PROCESSORS setting, but the default set includes a
> variable called 'user', which lets you do things like '{% if
> user.is_authenticated %}' in a template.
>
> To use it you'd want to do something like this:
>
> from django.template import RequestContext
>
> def home(request):
> if not request.user.is_authenticated():
> return render_to_response('login_error.html', {},
> context_instance=RequestContext(request))
> else:
> return render_to_response('index.html', {},
> context_instance=RequestContext(request))
>
> And also note that Django will happily help you out with forcing
> login; you could write the view like this:
>
> from django.template import RequestContext
> from django.contrib.auth.decorators import login_required
>
> def home(request):
> return render_to_response('index.html', {},
> context_instance=RequestContext(request))
>
> home = login_required(home)
>
> The 'login_required' decorator will accomplish the same thing as your
> manual authentication check -- if the user isn't logged in, it will
> force them to log in and then go on to your view.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Date field widget for generic views...

2007-03-23 Thread mediumgrade

I am writing an app that makes heavy use of generic views. I have
several forms which include date fields and I want to know how to
attach a widget to the field for entering the date (like the one used
in the admin site).

Am I making sense?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Date field wiget for generic views...

2007-03-21 Thread mediumgrade

I am writing an app that makes heavy use of generic views. I have
several forms which include date fields and I want to know how to
attach a widget to the field for entering the date (like the one used
in the admin site).

Am I making sense?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Authentication Issues...

2007-03-19 Thread mediumgrade

So, I am writing my first Django app that requires some form of
authentication, and I have run into a bit of a snag:

I authenticate the user via the 'django.contrib.auth.views.login' view
using a login template like this:


{% block main_section %}


{% if form.has_errors %}
Your username and password didn't match. Please try again.
{% endif %}
LoanCRM


Username:{{ form.username }}
Password:{{ form.password }}







{% endblock %}


As you can see, this redirects the user to the URL "/home".

"Home" is rendered using a template like this:




{% block contentbody %}
{% if is_logged_in %}Thanks for logging in!{% else %}Please log in.{%
endif %}
{% endblock %}




The login process seems to work just fine. If the password is
incorrect, the login page will warn them. If the password is correct,
the user proceeds to the "/home" URL.

The problem is that once they are at the "/home" URL, the template
does not show that the user is logged in. The "if is_logged_in" test
fails.

What could I be doing wrong?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A calendar-like view in Django/Python...

2007-01-16 Thread mediumgrade


I found this:

http://python.about.com/od/advancedpython/ss/howtocal.htm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



A calendar-like view in Django/Python...

2007-01-13 Thread mediumgrade


I have written an application that keeps track of appointments for my
technicians. My partners would like to be able to view the appointments
in a "calendar-like" format which can be viewed and/or printed. Am I
making sense? Is there already some kind of library in Django and/or
Python that does this or that can help?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Changing Field names...

2006-12-28 Thread mediumgrade


Alright, I have a simple Work Order entry system. I want to add a
boolean field to the system. How is this done if there is already data
in the system? Can I just add it to the model, then run syncdb? Should
I add it to the model, then manually add it to the database? Is there a
documented approach for this?

Any help?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User Environment Variables

2006-09-12 Thread mediumgrade

In, n my views, I could do something like app.user = request.user? Can
I get all information for the currently logged in user?



nymbyl wrote:
> To say "Hello, Person's name!" you can do "Hello, {{ user.username
> }}!":
> http://www.djangoproject.com/documentation/authentication/#authentication-data-in-templates
>
> Also, the request object has a 'user' attribute that you can access
> within views:
>
> http://www.djangoproject.com/documentation/request_response/#httprequest-objects
> 
> --Rob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



User Environment Variables

2006-09-12 Thread mediumgrade

In my application, I have an object which has a foreign key to the
django users table. Is there an environment variable that I can use to
get information on the currently logged-in user? For example, if I want
the main page to display "Hello, Person's Name!" or if I want my
objects to have the users foreign key to be automatically populated by
the currently logged-in user. How would I do this?

Any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: verbose_name option not working...

2006-08-29 Thread mediumgrade

Great! Thanks!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: mod_python apache problems...

2006-08-29 Thread mediumgrade

Thanks, Ricardo. That was it :-)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



mod_python apache problems...

2006-08-27 Thread mediumgrade

I am trying to setup my django site using mod_python and apache.

My Django project is called "autosales" and it works just fine when
accessing it from the development web server. However, when I try to
access it from apache, I get the following error

EnvironmentError: Could not import settings 'autosales.settings' (Is it
on sys.path? Does it have syntax errors?): No module named
autosales.settings

Here is my apache virtual host entry:


ServerAdmin [EMAIL PROTECTED]
ServerName autoapp.somedomain.com
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE autosales.settings
PythonDebug On



I am not sure what to do. I also tried adding PythonPath
"['/path/to/project'] + sys.path" in my virtual host entry like so:


ServerAdmin [EMAIL PROTECTED]
ServerName autoapp.somedomain.com
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['/path/to/project'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE autosales.settings
PythonDebug On


But I still get the same message. Keep in mind that I am restarting
apache every time I make a change.

Any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



verbose_name option not working...

2006-08-26 Thread mediumgrade

In my models, I have added the options "verbose_name" and
"verbose_name_plural" to make my models easier to understand in the
admin interface. However, even though I have added these options in my
models, the admin interface still displays the model's name in the
default camel case style. Is there something else I am supposed to add
in order for these names to be used?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Dynamic Menus...

2006-08-24 Thread mediumgrade

Don't know if this is a Django question or not, but here is the
situation:

I am developing an application for a client who is a automobile broker.
He wants agents to submit requests for vehicles from the web. The agent
will be able to select the make/model of the vehicle. What I want is
for the model menus to adjust dynamically depending on the make
selected. For example, if the agent selects "Honda" I only the the
models menu to show Civic, Accord, Element, ect.

How can this be achieved?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Manipulators Question

2006-08-19 Thread mediumgrade

I like this solution:

http://code.djangoproject.com/wiki/CookBookManipulatorWithPostpopulatedFields


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Manipulators Question

2006-08-15 Thread mediumgrade

So, I have a model which looks like this:

STATUS_TYPES = (
(1, 'Attending'),
(2, 'Not Attending'),
(3, 'Tentatively Attending'),
(4, 'Tentatively Not Attending'),
(5, 'No response'),
)

class Recipient(models.Model):
name = models.CharField(maxlength=50)
persons = models.IntegerField()
email = models.EmailField()
status = models.IntegerField(choices=STATUS_TYPES, default=5)
categories = models.ForeignKey(Category)


It's for a simple RSVP app I'm writing. My problem is that I want to
present someone with a for which only updates the RSVP status. I was
trying to use an update manipulator, but it appears as though the
manipulator is requiring that I update ALL fields not just the ones I
am POST'ing back to my view. What gives? How do I tell the manipulator
to only update certain fields? Should I just re-write this to not use
manipulators?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Getting properties of parent objects into a template

2006-08-14 Thread mediumgrade

And I am a 'tard.

I had pluralized the name of my author foreign key so that the actualy
name of the foreign key was "authors" and not "author". Once I used {{
entry.authors.name }}, everything was fine.

Still learning here,
Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Getting properties of parent objects into a template

2006-08-14 Thread mediumgrade

Yes, that would be the relationship and that was actually the first
thing I tried. The template gets passed an "array" of "entry" objects.
Within the template, I loop through them printing the headline, portion
of the body, and the created date. With Author's as a foreign key, I
assumed you could do something like {{ entry.author.name }} but I get
nothing in my output when I do this. I assume that objects passed in a
template can't follow their foreign key relationships.

Sorry, I am still very new to both Django as well as Python. Forgive me
if I am not stating my problem clearly.


Ivan Sagalaev wrote:
> mediumgrade ÐÉÛÅÔ:
> > I have a simple blog app that I am working on. In this app, I have
> > ojects for  each entry as well as the author who wrote it. I wrote a
> > simple view which displays a list of all entrys made, but I want that
> > list to include the name of the author. Since the author's name is not
> > part of the entry, how do I access attributes from related objects
> > within a template?
>
> If I'm guessing correctly that relation is like this:
>
>  class Article(models.Model):
>author = models.ForeignKey(Author)
> 
> ... then {{ article.author.name }} should work.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Getting properties of parent objects into a template

2006-08-13 Thread mediumgrade

I have a simple blog app that I am working on. In this app, I have
ojects for  each entry as well as the author who wrote it. I wrote a
simple view which displays a list of all entrys made, but I want that
list to include the name of the author. Since the author's name is not
part of the entry, how do I access attributes from related objects
within a template?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---