| Name | awkwerdconcepts |
|---|---|
| Email Address | n/a |
| Posts | 4 |
-
- 2010-09-29 10:06:15
- Re: determining distance from request.user to iterated instance in template...
- Board » Django » Views
-
I will give this a try, thank you very much!
-
- 2010-09-28 15:48:31
- determining distance from request.user to iterated instance in template...
- Board » Django » Views
-
required noob disclaimer: I am one.
I am trying to figure out the best way to display distance between the requesting user and the projects they are viewing. I don't know how to pipe the Project.project_location from a list that I iterate over somewhere else back into the '#pro_loc' block below. I feel like I am missing something very simple. I assume I can't bring template tags back into the view... please help
views.py
def browse(request):
project_list = Project.objects.all().order_by('-start_date')
#pro_loc = Project.project_location
request_member = request.user.member_set.get(user=request.user)
requesting_zip = request_member.zipcode
g = geocoders.Google('KEY')
_, rz = g.geocode(requesting_zip)
_, pz = g.geocode(#pro_loc)
d = distance.distance(rz, pz).miles
return render_to_response('browse.html',
locals(),
context_instance = RequestContext(request),)
browse.html
<tbody>
{% for project in project_list %}
<tr>
<td><a href="{{ project.get_absolute_url }}">{{ project.title }}</a></td>
<td>{{ project.award }}</td>
<td>{{ project.end_date }}</td>
<td>{{ d }} Miles</td>
</tr>
{% endfor %}
--- Last Edited by awkwerdconcepts at 2010-09-28 15:50:00 ---
-
- 2010-08-30 18:55:09
- Noob question
- Board » Django » Models
-
First I must disclose that I am a beginner. Not just to Django, but to programming as well. Picked up my first programming book "Learning Python" about 7 months ago. Now I am trying to tackle Django. I am having a lot of fun, but can't figure out this problem for the life of me. Searches are not helping, I suspect I do not have the vocabulary or experience to even know what to look for.
Essentially I am am trying to create several models. I am trying to have them relate to each other through the use of ForeignKey and ManyToMany. I want when one model is updated in Admin, the other models that have ForeignKey or ManyToManyField will automatically update and reflect the changes.
Problem is I keep getting an error to the effect of "tat.submissions: Reverse query name for field 'creative' clashes with m2m field 'Creative.submissions'. Add a related_name argument to the definition for 'creative'.
so I add the related name to each ForeignKey and ManyToManyField like so:
class Foo(models.Model)
submissions = models.ManyToManyField('Submissions', related_name='project_submissions', blank=True, null=True) and everything validates... However it doesn't sync with the Submissions model as I feel it should.....
Any help would be appreciated, thanks!
-
- 2010-08-16 18:10:59
- is www.username.example.com possible?
- Board » General Category » General Discussion
-
I am trying to create an ecommerce site that allows members to direct consumers to their site which is an extension of mine.
I would like their sites to be in the format of USERNAME.example.com


