Re: Last object of a set?
Thank you Brandon! That worked great. kind regards, -raymond On Sep 3, 10:07 pm, Brandonwrote: > You should be able to use the properties of a for loop to get the > first and last items. > > {% for course_part in course.coursepart_set.all %} > {% if forloop.first %} > {{ course_part.begin_date }} > {% endif %} > > {% if forloop.last %} > {{ course_part.end_date }} > {% endif %} > {% endfor %} > > HTH, > Brandon > > On Sep 3, 11:01 pm, watusee wrote: > > > I'm attempting to get the first and last items in a set inside a > > django template. The first is no problem: > > > {{ course.coursepart_set.all.0.begin_date }} > > > but I can't figure out how to get the last item without knowing the > > length of the set. Is there a way to do this? > > > Something like (theoretically): > > > {{ course.coursepart_set.all.LAST.end_date }} > > > kind regards, > > > -raymond --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Cloning/using Django admin without auth_ and django_ database tables?
Hi all, I’m using Django to build an Intranet web interface to a big legacy database running in a MS SQL Server. With the help of the code from the guys over at the django_pyodbc project (http://code.google.com/p/django-pyodbc/) I have managed to get things working quite well against this “alien” database manager. In a local copy of the legacy database on my Windows laptop I can browse and update records, using both my own forms and the admin interface. Now I want to move the web interface to an Ubuntu Linux server that is supposed to act as an Intranet web interface against the MS SQL database. I have my own forms working for updating from the Linux web to the MS server, but I would also like to make use of the excellent Django admin interface for managing data on the server. The problem I’m facing here is that I’m not in charge of the legacy database, and I can’t get the rights to install the tables for authorisation, sessions and content management that the Django admin interface seems to be dependent on. I have been fiddling with multi database management with a bit of luck, (thanks to http://www.mechanicalgirl.com/view/multiple-database-connection-a-simple-use-case/ and http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/), the idea being to have a local PostgreSQL on the Linux box as the default database for the tables needed by Django admin and switching over to the MS database for the actual data handling. Browsing and reading works fine, but I can’t get the multi-db management to work properly for updating of records on the MS SQL Server. This may be due to the non-supported code for MS SQL doing non-standard requests or to my lack of knowledge. So, my bottom line question is: Is there by chance any way to turn off authorisation in the Django admin or is there a way I could clone the functionality of the admin interface and use it without authorisation, sessions and content management, so that it won’t need to access any of the auth_ or django_ tables in the database? Thanks for any of your friendly support, Ulf --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Getting values set across relation spanning multiple tables
Hi I needed a query to get the values set of a model which has multiple child models like below class Vehicle(models.Model): vehicle_pkey = models.OneToOneField(User, primary_key=True, parent_link=True) vehiclename=models.CharField(max_length=20) class no_of_tyres(models.Model): no_of_tyres_pkey=models.ForeignKey (Vehicle,related_name='no_of_tyres_relatedname') numberoftyres=models.IntegerField() class brand_name(models.Model): brand_name_pkey=models.ForeignKey (Vehicle,related_name='brand_name_relatedname') brandname=models.CharField(max_length=20) My first question is Can I get all the details of the models into a single values set like below query_which_I_dont_know.values ('username','vehiclename','numberoftyres','brandname') To complicate further imagine I have one more field in brand_name which is cost class brand_name(models.Model): brand_name_pkey=models.ForeignKey (Vehicle,related_name='brand_name_relatedname') brandname=models.CharField(max_length=20) costofvehicle=models.IntegerField() My second question is say I want to obtain the values set (as in the above query ) of all the vehicle whose cost is >1000 and which has 4 numberoftyres how can I get it Thanks in advance Regards Subramanyam --~--~-~--~~~---~--~~ 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: What happened to djangoplugables.com?
Awesome, thanks! It looks very nice as well. On Sep 3, 8:53 pm, Andy McKaywrote: > On 2009-09-03, at 3:47 PM, Anthony wrote: > > > It's been down for a while. > > It's been dead for a while. Fortunately I did spider it many months > ago and put it intohttp://djangozen.com/app. > -- > Andy McKay > Clearwind Consulting:www.clearwind.ca > Twitter: @clearwind --~--~-~--~~~---~--~~ 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: Serializing with not just the query data but also some additional columns
On Fri, Sep 4, 2009 at 11:58 AM, Andy McKaywrote: > > > On 2009-09-03, at 1:21 PM, Neeraj wrote: >> I am trying to serialize a queryset but for each row I want >> supplementary data that is appropriate to the context I am doing the >> serialization in. I might want to add a column to each row in one >> situation which is some calculate value, etc, etc, etc. >> >> It seems that serialization only really lets you serialize a queryset. > > It does indeed, you would have to extend the built-in ones with your > own serializer. Changing this situation is a quite old feature request, and one that has the full blessing of the core. See #4656, #5711 for some related tickets. What is missing is a strong design that hits the underlying problem. 'Just add these extra columns to the serialized data' is the small version of a much larger feature request to customize the output format of the serialized data. Rather than try to tape lots of little features to the outside of the current serializers, we are looking for a strong framework for specifying serialization output formats. Yours Russ Magee %-) --~--~-~--~~~---~--~~ 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: how do you use session variables in template tags?
Is the request object present in your context? I believe you'd have to pass in the request, or make it available to the template via request_context and or the django.core.context_processors.request middleware. HTH, Brandon On Sep 3, 8:21 am, Bobby Robertswrote: > I cannot for the life of me get a session variable to work in a > template tag. Here's what I have > > ... > from django.contrib.sessions.models import Session > > register = template.Library() > > @register.filter(name='isinsavedlist') > # this gets the latest new item from the new item flex mod > def isinsavedlist(request): > try: > myval=int(request) > except: > myval=0 > > assert False, request.session["mylist[]"] > > When it tries to assert the value for mylist, i get the following: > > 'long' object has no attribute 'session' > > what am I 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Last object of a set?
You should be able to use the properties of a for loop to get the first and last items. {% for course_part in course.coursepart_set.all %} {% if forloop.first %} {{ course_part.begin_date }} {% endif %} {% if forloop.last %} {{ course_part.end_date }} {% endif %} {% endfor %} HTH, Brandon On Sep 3, 11:01 pm, watuseewrote: > I'm attempting to get the first and last items in a set inside a > django template. The first is no problem: > > {{ course.coursepart_set.all.0.begin_date }} > > but I can't figure out how to get the last item without knowing the > length of the set. Is there a way to do this? > > Something like (theoretically): > > {{ course.coursepart_set.all.LAST.end_date }} > > kind regards, > > -raymond --~--~-~--~~~---~--~~ 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: 'function' object has no attribute 'fields' errror on first access to development server
Make sure you've added in autodiscover: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf If you want help on a specific error, you are going to have give us a traceback, otherwise its unlikely we have enough information to go on. On 2009-09-03, at 4:34 PM, hamdiakoguz wrote: > > After starting django dev server I get this error on the first access. > After refreshing the page it goes away but somehow it seems that > admin.py (in my application dir) seems not to be executed and none of > the models i registered does not appear in admin. > > > -- Andy McKay Clearwind Consulting: www.clearwind.ca Twitter: @clearwind --~--~-~--~~~---~--~~ 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: Last object of a set?
If you are in a for loop you can test whether you are at the end. Otherwise I think you'd have to do it in the view. http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for On 2009-09-03, at 9:01 PM, watusee wrote: > > I'm attempting to get the first and last items in a set inside a > django template. The first is no problem: > > {{ course.coursepart_set.all.0.begin_date }} > > but I can't figure out how to get the last item without knowing the > length of the set. Is there a way to do this? > > Something like (theoretically): > > {{ course.coursepart_set.all.LAST.end_date }} > > kind regards, > > -raymond > > -- Andy McKay Clearwind Consulting: www.clearwind.ca Twitter: @clearwind --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Last object of a set?
I'm attempting to get the first and last items in a set inside a django template. The first is no problem: {{ course.coursepart_set.all.0.begin_date }} but I can't figure out how to get the last item without knowing the length of the set. Is there a way to do this? Something like (theoretically): {{ course.coursepart_set.all.LAST.end_date }} kind regards, -raymond --~--~-~--~~~---~--~~ 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: Serializing with not just the query data but also some additional columns
On 2009-09-03, at 1:21 PM, Neeraj wrote: > I am trying to serialize a queryset but for each row I want > supplementary data that is appropriate to the context I am doing the > serialization in. I might want to add a column to each row in one > situation which is some calculate value, etc, etc, etc. > > It seems that serialization only really lets you serialize a queryset. It does indeed, you would have to extend the built-in ones with your own serializer. -- Andy McKay Clearwind Consulting: www.clearwind.ca Twitter: @clearwind --~--~-~--~~~---~--~~ 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: What happened to djangoplugables.com?
On 2009-09-03, at 3:47 PM, Anthony wrote: > It's been down for a while. It's been dead for a while. Fortunately I did spider it many months ago and put it into http://djangozen.com/app. -- Andy McKay Clearwind Consulting: www.clearwind.ca Twitter: @clearwind --~--~-~--~~~---~--~~ 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: extending objects.get()
On 2009-09-03, at 4:40 PM, dwh wrote: j = Junk.objects.get(cheese='12345') > > The field cheese isn't part of Junk obviously. You can do anything you want in a custom manager. What cheese is and how possible that is, is up to you. -- Andy McKay Clearwind Consulting: www.clearwind.ca Twitter: @clearwind --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
zxJDBC.DatabaseError: driver [org.postgresql.Driver] not found Jython
Hi Everyone, I'm running Jython 2.5.0 and Django 1.0.3 on OS X Snow Leopard. Having an issue connecting to Postgres. I can create and run a project fine, but attempting to connect to a database using the django-jython database backend - doj.backends.zxjdbc.postgresql, throws the error: zxJDBC.DatabaseError: driver [org.postgresql.Driver] not found Jython I found a post: http://stackoverflow.com/questions/468763/how-to-connect-to-database-from-jython I'm not a Java developer, but correct me if I'm wrong...isn't Java SE 6 the same as JDK 1.6? The post indicates that switching from JDK 1.5 32 bit to JDK 1.6 64 bit solves the issue. I would certainly appreciate some pointers! Cheers, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
extending objects.get()
Is it possible to add a custom search key within get() that are: 1) Not part of the containing model 2) Use custom SQL Example: class Junk(models.Model): name = models.CharField(maxlength=10) size = models.IntegerField() >>> j = Junk.objects.get(cheese='12345') The field cheese isn't part of Junk obviously. It maybe easier to use a custom Manager. I've done that but I'd like to know if the above is possible as the code is more symmetrical. TIA --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
'function' object has no attribute 'fields' errror on first access to development server
After starting django dev server I get this error on the first access. After refreshing the page it goes away but somehow it seems that admin.py (in my application dir) seems not to be executed and none of the models i registered does not appear in admin. --~--~-~--~~~---~--~~ 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: Outputing an integer value in a template, but with some calculation done on it
> I am trying to output a variable page_no to a template, but I want to output > page_no + 1 and page_no - 1. How do I do that? I tried to do something like > {{ page_no + 1 }} and that failed. Tried {% and %} as well, but no success. > > Surely there is a way to do this other than having to calculate these values > in the view ahead of time? You bet -- you want the "add" filter: {{ page_no|add:"1" }} detailed at http://docs.djangoproject.com/en/dev/ref/templates/builtins/#add -tim --~--~-~--~~~---~--~~ 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: how to deploy an app that gets used by people in multiple time zones
Thanks for the input. I have a couple questions. Both of you talk about saving the date/time in UTC format. What is the default when using a django DateTimeField? Does it not save it in UTC? If it is not saving it in UTC, what is it saving it in? I thought that one of the things the DateTimeField did for you was convert your input (whether form a user typed input or from a server call to datetime.datetime.now ()) into some sort of internal representation (UTC?). I thought that when I was using the date filter, that it was simply converting that internal representation into my specificied text format. Am I confused here? I thought about putting the timezone in the profile but that does have the disadvantage that if the user travels, they would have to update their profile to get dates displayed in whatever location they are at. I really don't like that since the people that will be using my app are management, and they often travel (and probably won't want to modify their profile all the time). One thing I thought about is trying to save the timezone info in the session. It seems like there should be a way to set a session variable at login time that reflects the current time zone and then have template tags that access that variable and generate the correct format based on the session variable.Is this a viable option? Since this is an internal site within a company, it is ok for me to require my users to have javascript on. Tim - i assume that with respect to your comment about javascript you are suggesting that identify the timezone via client javascript code and send it with every request? I thought I had read there was something going on in this area, possibly for django 1.2 but I can't remember what I saw about that ... Would be curious if there is anything planned for develpment in this area as I could possibly wait a few months to implement this if there was going to be some additional support coming on the django side. Margie On Sep 3, 3:02 pm, Tim Chasewrote: > > I've created a django app and I soon am going to have users that are > > in multiple timezones. My app is a task management system and it is > > important for users to see dates and times with respect to their own > > time zone. IE, if here in California I create a task at 3PM on Sept > > 3, I want someone in India to see it as being created at 1AM on Sept > > 4. Optimally, if that India employee travels to the US and looks at > > the task creation date, they should see 3PM on Sept 3. Is there a > > "best" way to handle this? Things that come to mind are: > > > 1. Create a deployment for each of my time zones where TIME_ZONE and > > DATE_FORMAT are set appropriately for the time zone associated with > > the deployment. This seems painful ... > > agreed...yuck! > > > 2. Have a single deployment and whenever I display dates, use some > > sort of tag that can figure out how to display the date correctly > > based on the user's time zone > > Best that I've found. It's best to store everything in the > database as UTC and then adjust the display for whatever the > relative timezone is. > > > 3. I see there is a reusable app called django-timezones. There is > > not much doc with it, but I'm guessing this is targeted at what I am > > trying to do. > > Not familiar with this one. > > The catch is that HTTP doesn't require the requester to send > their timezone information in the request. So you either have to > store the user's TZ in their user profile information, or you > have to use some client-side JavaScript to get the local TZ. > Both have problems -- If the client has JavaScript turned off (I > tend to fly with NoScript, only white-listing those sites I care > about to be able to run JS) you don't get this information back > from them. On the other side, if your customers travel from TZ > to TZ, they will have to update their profile each time they > move. Neither is a horrible solution, just with their own set of > hiccups. The two solutions can be combined to keep an "expected > TZ" in the user profile, but then take advantage of JS when > available to sniff the local PC's time-zone to override. > > Python's stock TZ handling is a little weak last I experimented > with it, expecting a single TZ for the entire running instance. > There's a library at pytz.sf.net that simplifies a lot of the TZ > pain I've experienced with Python's native datetime libraries. > It also gives good examples and cautions on things that can screw > you up (such as notifications set during a DST rollback time-slot). > > Hope this helps, > > -tim --~--~-~--~~~---~--~~ 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
What happened to djangoplugables.com?
It's been down for a while. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Serializing with not just the query data but also some additional columns
Hello. I am trying to serialize a queryset but for each row I want supplementary data that is appropriate to the context I am doing the serialization in. I might want to add a column to each row in one situation which is some calculate value, etc, etc, etc. It seems that serialization only really lets you serialize a queryset. 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 -~--~~~~--~~--~--~---
"Stupid newbie" question - why does this IntegrityError happen?
I've got the following models defined: class FeatureType(models.Model): type = models.CharField(max_length=20) def __unicode__(self): return self.type class Feature(models.Model): value = models.CharField(max_length=200) type = models.ForeignKey(FeatureType) def __unicode__(self): return u'type=' + repr(self.type.type) + u', value=' + repr (self.value) class Meta: unique_together = ( ("value", "type"), ) This is what I tried for creating a new Feature: ft = Feature(type=FeatureType(type='Color'), value='Red') ft.type.save() ft.save() I get an IntegrityError at ft.save() saying that the type_id must not be NULL. However, this works: ft = Feature(type=FeatureType(type='Color'), value='Red') ft.type.save() ft.type = ft.type ft.save() Now, if I add in 'null=True' to the definition of 'type' in the Feature model, then the first 3-line code set works, and correctly gets the type_id defined. Am I running into a bug, or am I misunderstanding something? - Johnson --~--~-~--~~~---~--~~ 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: Imagefield, PIL and save()
On Sep 3, 5:31 pm, Rob Broadheadwrote: > If you are on a Mac there are some issues with the imagelib you will > need to fix. Very interesting. I am on a Mac. So I'll investigate and update. Thanks, 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
wrong links when using deployment server
Hello. I just started using Django and everything works fine when using the built-in development server. But when I use the deployment server (provided via lighthttpd) all links of my page get corrupted. For example a "www.mysite.org/user" is now becoming a "www.mysite.org/ django.fcgi/user" when using the deployment server. So everytime a not needed "django.fcgi" ends up in the url. I guess it is cause of the django.conf I use for my lighthttpd (see below), but I am not really sure (I am new to Django and lighthttpd). Can someone give me a hint how I can solve that problem? Regards, Kai $HTTP["host"] =~ "(^|\.)mysite\.sites\.myprovider\.com$" { fastcgi.server = ( "/django.fcgi" => ( "main" => ( "socket" => env.HOME + "/mysite/mysite.sock", "check-local" => "disable", ) ), ) alias.url = ( "/media" => env.HOME + "/mysite/media", ) url.rewrite-once = ( "^(/media.*)$" => "$1", "^/favicon\.ico$" => "/media/favicon.ico", "^(/.*)$" => "/django.fcgi$1", ) } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Outputing an integer value in a template, but with some calculation done on it
Hello people. This may seem like a very simple question, and for that I apologize. I am trying to output a variable page_no to a template, but I want to output page_no + 1 and page_no - 1. How do I do that? I tried to do something like {{ page_no + 1 }} and that failed. Tried {% and %} as well, but no success. Surely there is a way to do this other than having to calculate these values in the view ahead of time? 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: Re-usable/pluggable app form question.
You want your project "foo" to be able to (1) render content from a template and also (2) handle a request to a specific url. If you want to do (1), you can add 'django.template.loaders.app_directories.load_template_source' to your TEMPLATE_LOADERS in your settings file. In fact, it may be there already. That will automatically look in /templates/ for any installed apps when resolving template strings: http://docs.djangoproject.com/en/dev/ref/templates/api/#ref-templates-api If you want to do (2), you'll have to put something into your main urls.py file. Why not add it to your urls with an include under a url prefix like 'foo/' that points to whatever urls.py file you have in the app 'foo'. The django admin app is a great example of what you're trying to do, why not look into how it gets configured and how it organizes its templates? Maybe also look at django.contrib.comments. Peter On Sep 3, 10:07 am, Shawn Milochikwrote: > I'm working on an existing project that I'm splitting up into multiple > apps. My question is about how to use those apps together. > > Say I have an app called "main." Then two supporting apps which sit > outside of that Django project folder. They are "foo" and "bar." They > are not "installed" as Python modules -- they're just in another > directory on the Python path, and they are added to the INSTALLED_APPS > of the main project. > > Let's say foo has a template which is just a div containing a > form.as_p tag, and the form it uses is also in the project foo. The > function to act on that form's submission is in the views.py of foo. > > If I want to offer that form on my site from the main app, how do I do > it? Is it possible to not import the forms, views, and templates from > foo into main, and just use template tags to load the foo content into > main and have it processed by foo? > > The point is to keep all foo logic outside of the main app, so main > doesn't have to "know about" foo or any of its internals. This may not > strictly be a "pluggable" app, but it works for our application. Is > the way to do this documented anywhere? > > Thanks, > Shawn --~--~-~--~~~---~--~~ 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: Imagefield, PIL and save()
If you are on a Mac there are some issues with the imagelib you will need to fix. Google Mac PIL django and I think you will get three or four walk-throughs to fix the problem. I think you can see the error when you run the PIL tests, but I went through a lot of iterations just fixing that myself so my recollection may be a bit off. On Sep 3, 2009, at 5:23 PM, aa56280 wrote: > > I have an ImageField in a model. I also have a ModelForm for this > model. I'm overriding save() so that I can take the image that was > uploaded and make a thumbnail out of it using PIL. > > I'm using the simplest of examples just to get started: > > ... > def save(self): > from PIL import Image > > im = Image.open(self.logo) # 'logo' is the image field name > im.thumbnail((100,100), Image.ANTIALIAS) > im.save('test.png') > > No exception, no errors, but neither was a thumbnail created. I keep > thinking something's going on with the Image.open() method, but I have > no clue what. Any ideas greatly appreciated. > > > > Rob Broadhead robert.broadh...@gmail.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Imagefield, PIL and save()
I have an ImageField in a model. I also have a ModelForm for this model. I'm overriding save() so that I can take the image that was uploaded and make a thumbnail out of it using PIL. I'm using the simplest of examples just to get started: ... def save(self): from PIL import Image im = Image.open(self.logo) # 'logo' is the image field name im.thumbnail((100,100), Image.ANTIALIAS) im.save('test.png') No exception, no errors, but neither was a thumbnail created. I keep thinking something's going on with the Image.open() method, but I have no clue what. Any ideas greatly appreciated. --~--~-~--~~~---~--~~ 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: how to deploy an app that gets used by people in multiple time zones
> I've created a django app and I soon am going to have users that are > in multiple timezones. My app is a task management system and it is > important for users to see dates and times with respect to their own > time zone. IE, if here in California I create a task at 3PM on Sept > 3, I want someone in India to see it as being created at 1AM on Sept > 4. Optimally, if that India employee travels to the US and looks at > the task creation date, they should see 3PM on Sept 3. Is there a > "best" way to handle this? Things that come to mind are: > > 1. Create a deployment for each of my time zones where TIME_ZONE and > DATE_FORMAT are set appropriately for the time zone associated with > the deployment. This seems painful ... agreed...yuck! > 2. Have a single deployment and whenever I display dates, use some > sort of tag that can figure out how to display the date correctly > based on the user's time zone Best that I've found. It's best to store everything in the database as UTC and then adjust the display for whatever the relative timezone is. > 3. I see there is a reusable app called django-timezones. There is > not much doc with it, but I'm guessing this is targeted at what I am > trying to do. Not familiar with this one. The catch is that HTTP doesn't require the requester to send their timezone information in the request. So you either have to store the user's TZ in their user profile information, or you have to use some client-side JavaScript to get the local TZ. Both have problems -- If the client has JavaScript turned off (I tend to fly with NoScript, only white-listing those sites I care about to be able to run JS) you don't get this information back from them. On the other side, if your customers travel from TZ to TZ, they will have to update their profile each time they move. Neither is a horrible solution, just with their own set of hiccups. The two solutions can be combined to keep an "expected TZ" in the user profile, but then take advantage of JS when available to sniff the local PC's time-zone to override. Python's stock TZ handling is a little weak last I experimented with it, expecting a single TZ for the entire running instance. There's a library at pytz.sf.net that simplifies a lot of the TZ pain I've experienced with Python's native datetime libraries. It also gives good examples and cautions on things that can screw you up (such as notifications set during a DST rollback time-slot). Hope this helps, -tim --~--~-~--~~~---~--~~ 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: how to deploy an app that gets used by people in multiple time zones
On Thu, Sep 03, 2009 at 02:36:21PM -0700, Margie Roginski spake thusly: > the task creation date, they should see 3PM on Sept 3. Is there a > "best" way to handle this? Things that come to mind are: I am going to have to be dealing with this soon also. My plan is to store datetime objects in the db in UTC. I then plan to have a user profile with a timezone attribute for that user. Whenever I display a date/time to the user I intend to convert it to their timezone. I am wondering if I have to just make an explicit conversion everywhere I end up displaying them a time or if there is some slick way I can override a method on datetime objects to automatically have them return the correct timezone when being rendered in a template and always be in UTC when going into the database. -- Tracy Reed pgpNsO1wxrEbn.pgp Description: PGP signature
how to deploy an app that gets used by people in multiple time zones
I've created a django app and I soon am going to have users that are in multiple timezones. My app is a task management system and it is important for users to see dates and times with respect to their own time zone. IE, if here in California I create a task at 3PM on Sept 3, I want someone in India to see it as being created at 1AM on Sept 4. Optimally, if that India employee travels to the US and looks at the task creation date, they should see 3PM on Sept 3. Is there a "best" way to handle this? Things that come to mind are: 1. Create a deployment for each of my time zones where TIME_ZONE and DATE_FORMAT are set appropriately for the time zone associated with the deployment. This seems painful ... 2. Have a single deployment and whenever I display dates, use some sort of tag that can figure out how to display the date correctly based on the user's time zone 3. I see there is a reusable app called django-timezones. There is not much doc with it, but I'm guessing this is targeted at what I am trying to do. Can anyone give any recommendations? I'm happy to dive in and read source (ie, for django-timezones app), but I just want to make sure I'm heading in the right direction. Thanks, Margie --~--~-~--~~~---~--~~ 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: Parsing / Deserializing a JSON String
I suspect your error is hiding in . What do you expect obj to be? Your JSON should return a big dictionary with one key ("ganttgroups"). When you iterate over a dictionary in python, you get the keys of that dictionary. In this case, the string "ganttgroups". You may be doing the following: for obj in serializers.deserialize("json", gantt_data): do_something_to(obj['gantts']) which returns an error, because it evaluates to "ganttgroups"['gantts'] (which would give you the error you see. What you want is more like: for obj in serializers.deserialize('json', gantt_data)['ganttgroups']: start = obj['start'] for gantt in obj['gantts']: for row in gantt['rows']: print row['own'] In short, you're getting your dicts and lists mixed up, or your keys and values. Cheers, Cliff On Wed, 2009-09-02 at 10:40 -0700, Eric wrote: > I forgot to mention that I am trying to deserialize the data as > follows: > > " > ... > gantt_data = request.POST.get('ganttdata') > > for obj in serializers.deserialize("json", gantt_data): > > ... > " > > On Sep 2, 10:37 am, Ericwrote: > > Hi, > > I am attempting to parse a json string passed to my view via a form > > post. A simple example of my json structure is as follows (indented > > for readability): > > > > { > > "ganttgroups":[ > > { > > "gantts":[ > > { > > "rows":[ > > {"stt":1, "end":2, "ttl":"test row - gr1 ga1 > > ta1", "own":"Tim Johnson"}, > > {"stt":2, "end":3, "ttl":"my row (g1 t2)", > > "own":"John Doe"}, > > {"stt":1, "end":2, "ttl":"test row - gr1 ga1 > > ta3", "own":"Mary Smith"} > > ] > > }, > > { > > "rows":[ > > {"stt":1, "end":2, "ttl":"My 4th task", > > "own":"Eric Johnson"}, > > {"stt":1, "end":2, "ttl":"my row (g2 t2)", > > "own":"Jeff Smith"}, > > {"stt":1, "end":2, "ttl":"test row - gr1 ga2 > > t3", "own":"Bill Baker"} > > ] > > } > > ], > > "start":"2009-1-01" > > } > > ,{ > > "gantts":[ > > { > > "rows":[ > > {"stt":1, "end":2, "ttl":"row - gr2 ga1 t1", > > "own":"Ted Tillman"}, > > {"stt":1, "end":2, "ttl":"row - gr2 ga1 t2", > > "own":"Kim Crane"}, > > {"stt":1, "end":2, "ttl":"row - gr2 ga1 t3", > > "own":"Bob Barker"} > > ] > > } > > ], > > "start":"2009-1-01" > > } > > ] > > > > } > > > > I would like to parse it so that I can loop over the pairs/arrays to > > access the data. When I try to deserialize the data, I get the django > > error "string indices must be integers". Can anybody please help me > > determine what exactly this means and how I may fix this? Is there > > another method I should be using? I am obviously a bit of a newbie at > > this so any help would be greatly appreciated. > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Assign a User/Group to a Site
Ok, so I can have an article associated with multiple sites. That's pretty sweet! But how about ensuring that a user I create can only work on a certain site? --~--~-~--~~~---~--~~ 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: JSON serialization of related records.
Thanks Mike. The issue is the inflexible handling of fk entries of a model by the django serializer or more accurately PythonSerializer. The behavior is inherited by json and xml serializers the same. I've eventually resorted to rewriting the whole serialization to make it a better fit for my ajax style front-ends but I guess it may take a while before I can come up with a fully configurable and robust framework as the serialization code should serialize into the output stream directly rather than building the whole object tree and creating a giant string before even touching the output stream. BTW, I like your idea of JSONResponse, it makes the code neat and readable. On Sep 1, 7:25 pm, Mike Ramirezwrote: > On Tuesday 01 September 2009 12:29:56 pm Amir Habibi wrote: > > > How can I serialize a Queryset along with the related records. For > > example, in Poll and Choice case, I need each poll to have the choices > > encoded in json format. > > > Thanks > > you'll want to look at the docs on serialization [1], it is pretty straight > forward, though the examples use 'xml', it does output to json data (among > other formats) also. > > http://docs.djangoproject.com/en/dev/topics/serialization/ > > It's quite simple to use, in my examples I'm using FAQ Categories and Question > and Answers within a category. > > In [1]: from django.core import serializers > > In [2]: from base.models import FAQC > FAQCategory FAQCategoryManager > > In [2]: from base.models import FAQCategory, FAQ > FAQ FAQCategory FAQCategoryManager > > In [2]: from base.models import FAQCategory, FAQ > > In [3]: cat = FAQ > FAQ FAQCategory > > In [3]: cat = FAQCategory.objects.all().get(pk=1) > > In [4]: cat > Out[4]: > > In [5]: faqs = FAQ.objects.all().filter(category=cat) > > In [6]: faqs > Out[6]: [] > > In [7]: json = serializers.serialize('json', faqs) > > In [8]: json > Out[8]: '[{"pk": 1, "model": "base.faq", "fields": {"answer": "Because I want > to.", "category": 1, "question": "Why?", "number": 1, "slug": "why"}}]' > > you can also extend HttpResponse to return a JsonResponse: > > # as seen on:http://toys.jacobian.org/presentations/2007/oscon/tutorial/#s67 > class JSONResponse(HttpResponse): > def __init__(self, data): > HttpResponse.__init__(self, data, mimetype="application/json") > > In your view code just return this, using the serialized data from above: > > def ajaxview(request): > cat = FAQCategory.objects.all().get(pk=1) > faqs = FAQ.objects.all().filter(category=cat) > json = serializers.serialize('json', faqs) > return JSONResponse(json) > > hope this helps, > > Mike > -- > War is peace. Freedom is slavery. Ketchup is a vegetable. > > signature.asc > < 1KViewDownload --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Add buttons to change_form
Hi friends, I have a problem. I want add buttons to change_form, and I did the same thing of Django, I wrote a templatetags, but I have a doubt in the views. I want do something as: def newdescriptor(request): if request.method == 'POST': form = CustomNewForm(request.POST) if form.is_valid(): if 'checked' in request.POST: new = Descriptor(term = form.cleaned_data['term'], note = form.cleaned_data['note']) new.save() return HttpResponseRedirect('/admin/new/%s' % new.id) I did this function, and it works, but I used it in my custom form (CustomNewForm), and I have modify it for use it in change_form In this case, "checked" is a button, Descriptor is a model, and term and note are attributes. I create an instance of Descriptor when I press "checked" button. My doubt is how modify it for use it in chage_form? Because in this case, my "form" is..? Please, help, really I need do that. 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: Which query to use?
Ok, I have a working SQL query, but I don't know how to translate it to Django DB API: select * from main_intermail where id in (select max(id) from main_intermail group by conversation_id); Any help will be appreciated! --~--~-~--~~~---~--~~ 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: Parsing / Deserializing a JSON String
Here is a raw example of the json.. Note that it is a different example than above: {"ganttgroups":[{"gantts":[{"rows":[{"stt":1,"end":2,"ttl":"wash dog","own":"Joe"},{"stt":2,"end":3,"ttl":"clean house"},{"stt":3,"end": 5,"ttl":"sell couch","own":"Mary"}]},{"rows":[{"stt":1,"end": 5,"ttl":"eat diner"},{"stt":5,"end":7,"ttl":"frame","own":"Ed"},{"stt": 6,"end":10,"ttl":"the rest","own":"Chris"}]}],"start":"2009-1-01"}, {"gantts":[{"rows":[{"stt":3,"end":5,"ttl":"1st try","own":"Bill"}, {"stt":5,"end":9,"ttl":"2nd try","own":"Jeff"},{"stt":9,"end": 12,"ttl":"3rd try"}]}],"start":"2009-1-01"}]} On Sep 2, 11:30 am, Andrew McGregorwrote: > On Wed, Sep 2, 2009 at 6:47 PM, Eric wrote: > > > Im using the Django deserialization method shown here: > > >http://docs.djangoproject.com/en/dev/topics/serialization/ > > ok, try pasting your json (the original, not your re-typed version) here: > > http://www.jsonlint.com/ > > -- > Andrew McGregor > 07940 22 33 11 --~--~-~--~~~---~--~~ 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: are you using mptt, treebeard or something else?
>From what I understand, Treebeard has better performance, but mptt has (I think) been around longer. I've messed around w/ mptt, but looking through treebeards benchmarks, it looks like treebeard might be more well thought out. As far as admin support goes, I don't think either has "official" admin support, but both seem to have patches from other users that attempt to implement it. On Thu, Sep 3, 2009 at 10:51 AM, Sandra Djangowrote: > Hi Aljosa Mohorovic, I need work with django-mptt or django-treebeard, but > neither I'm sure. I think that django-mptt is better, this says all ( > http://magicrebirth.wordpress.com/2009/08/06/representing-hierarchical-data-with-django-and-mptt/ > ) > Sorry, a cuestion because I don't understand. mptt requires v1.1, but not > SVN version? > > > > On Thu, Sep 3, 2009 at 11:11 AM, Aljosa Mohorovic < > aljosa.mohoro...@gmail.com> wrote: > >> >> i'm looking at django-mptt and django-treebeard but i'm not sure which >> one to use although both will solve my problem. >> currently i'm thinking to use treebeard because mptt requires me to >> use trunk for django v1.1. >> any comments/tips/recommendations are appreciated. >> >> Aljosa Mohorovic >> >> > > > > --~--~-~--~~~---~--~~ 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: Return FK model
@Javier, not sure.. I've used user profiles on my past sites because that's what I was told to do a while ago, if inheritance works with authentication and the admin, I would definitely go that route. Also, @Yanik, I realized my UserProfile model example above was wrong, the user relation should be OneToOneField, not ForeignKey. On Thu, Sep 3, 2009 at 10:49 AM, Javier Guerrawrote: > > On Thu, Sep 3, 2009 at 10:41 AM, Ben Davis wrote: > > The django docs suggest using a UserProfile model when you need to add > more > > information about a user: > > > http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users > > slightly OT: is there any advantage to use profiles instead of table > inheritance? > > I know the userprofiles were the only choice before there was table > inheritance; but is it still the best way? > > -- > Javier > > > > --~--~-~--~~~---~--~~ 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: context processors in 404 errors
On Thu, Sep 3, 2009 at 4:27 AM, Alessandrowrote: > 2009/9/1 Karen Tracey > >> On Tue, Sep 1, 2009 at 12:02 PM, Alessandro Ronchi < >> alessandro.ron...@soasi.com> wrote: >> >>> When I return a 500 error I need to have my context_processor, in which I >>> store some important vars used in my template. Is it possible? >>> >> >> Your subject line says 404 errors but your text says 500. Which are you >> asking about? >> >> > sorry, the problem is on 500 errors. on 404 the context is correct (i've > tried). > > The default handler for 500s intentionally uses an empty Context for rendering, so as to minimize chances of another critical error being encountered. There was a period of 2 days 3 years ago where it used a RequestContext, but that was reconsidered to be a Bad Idea. Since then requests to change this have been rejected, see: http://code.djangoproject.com/ticket/5617 Here's a mailing list thread discussing it: http://groups.google.com/group/django-users/browse_thread/thread/aee94039eccf2d90/01fa9a19cd3350bc So, if you want to have your context processor run for 500s, you will have to provide your own custom 500 handler that uses a RequestContext. Karen --~--~-~--~~~---~--~~ 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: are you using mptt, treebeard or something else?
Hi Aljosa Mohorovic, I need work with django-mptt or django-treebeard, but neither I'm sure. I think that django-mptt is better, this says all ( http://magicrebirth.wordpress.com/2009/08/06/representing-hierarchical-data-with-django-and-mptt/ ) Sorry, a cuestion because I don't understand. mptt requires v1.1, but not SVN version? On Thu, Sep 3, 2009 at 11:11 AM, Aljosa Mohorovic < aljosa.mohoro...@gmail.com> wrote: > > i'm looking at django-mptt and django-treebeard but i'm not sure which > one to use although both will solve my problem. > currently i'm thinking to use treebeard because mptt requires me to > use trunk for django v1.1. > any comments/tips/recommendations are appreciated. > > Aljosa Mohorovic > > > --~--~-~--~~~---~--~~ 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: Return FK model
On Thu, Sep 3, 2009 at 10:41 AM, Ben Daviswrote: > The django docs suggest using a UserProfile model when you need to add more > information about a user: > http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users slightly OT: is there any advantage to use profiles instead of table inheritance? I know the userprofiles were the only choice before there was table inheritance; but is it still the best way? -- Javier --~--~-~--~~~---~--~~ 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: Return FK model
True, you wouldn't be able to modify the auth.User model. Though you're wrong about what would happen if you were able to. What I'm saying is with a ManyToMany field, the relationship is with itself (User), so it would return User objects. The django docs suggest using a UserProfile model when you need to add more information about a user: http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users What you could do is this. Create a UserProfile model with the friends reflexive relationship: class UserProfile(models.Model): user = ForeignKey(User) friends = ManyToManyField(UserProfile) then you could do: some_user = UserProfile.objects.get(user=X) his_friends = some_user.friends This would return UserProfile objects, though. So if you wanted User objects, you could do his_friends = some_user.friends.select_related('user') This would pull all this user's friends, plus their information from the auth_user table in one query, so while looping through their friends, you access their user information like so: for friend in his_friends: this_friends_user_acct = friend.user Make sense? On Thu, Sep 3, 2009 at 10:17 AM, Yanikwrote: > > Well, I can't add very well add fields to the Auth.User. But even if I > could, user.friends would get me instances of "Friend" model, not > "User" model. > > On Sep 3, 11:13 am, Ben Davis wrote: > > It looks you're setting a many-to-many reflexive (circular) relationship > > between users. It seems it would be better to add a ManyToManyField on > the > > User model, eg: > > > > class User(models.Model): > > ... > > friends = ManyToManyField(User) > > > > Then you could just use "user.friends" > > > > On Thu, Sep 3, 2009 at 9:50 AM, Yanik wrote: > > > > > Let's say I have a model "Friends" that looks something like: > > > > > class Friend(models.Model): > > >user = models.ForeignKey(User) > > >friend = models.ForeignKey(User, related_name="friend") > > > > > I want a list of "User" instances of a user's friends. Is my only > > > option to: > > > > > 1) Get list of "Friends" > > > 2) Then get list of "Users" where id in friends.value_llist('id') > > > > > Or is there a way to do a query on the "Friend" model and as to return > > > "User" instances of friends? > > > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
are you using mptt, treebeard or something else?
i'm looking at django-mptt and django-treebeard but i'm not sure which one to use although both will solve my problem. currently i'm thinking to use treebeard because mptt requires me to use trunk for django v1.1. any comments/tips/recommendations are appreciated. Aljosa Mohorovic --~--~-~--~~~---~--~~ 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: Return FK model
Well, I can't add very well add fields to the Auth.User. But even if I could, user.friends would get me instances of "Friend" model, not "User" model. On Sep 3, 11:13 am, Ben Daviswrote: > It looks you're setting a many-to-many reflexive (circular) relationship > between users. It seems it would be better to add a ManyToManyField on the > User model, eg: > > class User(models.Model): > ... > friends = ManyToManyField(User) > > Then you could just use "user.friends" > > On Thu, Sep 3, 2009 at 9:50 AM, Yanik wrote: > > > Let's say I have a model "Friends" that looks something like: > > > class Friend(models.Model): > > user = models.ForeignKey(User) > > friend = models.ForeignKey(User, related_name="friend") > > > I want a list of "User" instances of a user's friends. Is my only > > option to: > > > 1) Get list of "Friends" > > 2) Then get list of "Users" where id in friends.value_llist('id') > > > Or is there a way to do a query on the "Friend" model and as to return > > "User" instances of friends? > > --~--~-~--~~~---~--~~ 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: Return FK model
It looks you're setting a many-to-many reflexive (circular) relationship between users. It seems it would be better to add a ManyToManyField on the User model, eg: class User(models.Model): ... friends = ManyToManyField(User) Then you could just use "user.friends" On Thu, Sep 3, 2009 at 9:50 AM, Yanikwrote: > > Let's say I have a model "Friends" that looks something like: > > class Friend(models.Model): >user = models.ForeignKey(User) >friend = models.ForeignKey(User, related_name="friend") > > I want a list of "User" instances of a user's friends. Is my only > option to: > > 1) Get list of "Friends" > 2) Then get list of "Users" where id in friends.value_llist('id') > > Or is there a way to do a query on the "Friend" model and as to return > "User" instances of friends? > > > > --~--~-~--~~~---~--~~ 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: django profiles question and http404
as usual i solved by myself! with something like this: user = User.objects.get(username=username) try: profile_obj = user.get_profile() except ObjectDoesNotExist: return HttpResponseRedirect('/some/path/') thank you anyway... On Sep 3, 4:16 pm, andreas schmidwrote: > hi, > > im trying django-profiles and i like it but im not understanding why if > a profile does not exist it has to output a http404. i think it doesnt > has really much sense because if a profile is not yet created or not > public it shouldnt give a 404 but a "im sorry but the profile is not > available because has not been created or its not public". > > i looked at the profile_detail view and im trying to redirect to a > "profile_does_not_exist" template but im experiencing problems because > the profile request is made with a get_profile_or_404 method and i cant > do a HttpResponseRedirect like: > > user = get_object_or_404(User, username=username) > try: > profile_obj = user.get_profile() > except ObjectDoesNotExist: > return HttpResponseRedirect('http://some/url/') > > right?! > > how could i redirect to another template, view if the profile doesnt > exist instead of the actual 404?? > > i appreciate 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Need help with a small Django project
Hi, We need help to do a small Django project, it might take 5-10 hours. If anyone interested in it, please email me: happyra...@yahoo.com. Please provide your charge rate, by hour or by project. When will you have time and your experience in Django. 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 -~--~~~~--~~--~--~---
Return FK model
Let's say I have a model "Friends" that looks something like: class Friend(models.Model): user = models.ForeignKey(User) friend = models.ForeignKey(User, related_name="friend") I want a list of "User" instances of a user's friends. Is my only option to: 1) Get list of "Friends" 2) Then get list of "Users" where id in friends.value_llist('id') Or is there a way to do a query on the "Friend" model and as to return "User" instances of friends? --~--~-~--~~~---~--~~ 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: Model field vs Form field vs Widget
On Thu, Sep 3, 2009 at 1:11 PM, alexandre...@gmail.com < alexandre...@gmail.com> wrote: > > Hi, I'm a newbie on Django and would like a reference reading on model > fields, form fields and widgets. > > For example I want to have a model field called CountryField that > automatically in forms displays as a bombobox with country options. > > Furthermore, I want to develop a Zip Code field like the country field > with one difference the table of Zip Codes has over a million records > so I want do develop a widget that popus another form that let me > search over that huge amount of records and fills back do the field. > > > I just want to create model classes with special fields, and they know > how to display themselves in forms. The online docs are the best place to start Models and model fields: http://docs.djangoproject.com/en/dev/topics/db/models/ http://docs.djangoproject.com/en/dev/ref/models/fields/ http://docs.djangoproject.com/en/dev/howto/custom-model-fields/ Forms and form fields: http://docs.djangoproject.com/en/dev/topics/forms/ http://docs.djangoproject.com/en/dev/ref/forms/fields/ http://docs.djangoproject.com/en/dev/ref/forms/validation/ Widgets: http://docs.djangoproject.com/en/dev/ref/forms/widgets/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django profiles question and http404
hi, im trying django-profiles and i like it but im not understanding why if a profile does not exist it has to output a http404. i think it doesnt has really much sense because if a profile is not yet created or not public it shouldnt give a 404 but a "im sorry but the profile is not available because has not been created or its not public". i looked at the profile_detail view and im trying to redirect to a "profile_does_not_exist" template but im experiencing problems because the profile request is made with a get_profile_or_404 method and i cant do a HttpResponseRedirect like: user = get_object_or_404(User, username=username) try: profile_obj = user.get_profile() except ObjectDoesNotExist: return HttpResponseRedirect('http://some/url/') right?! how could i redirect to another template, view if the profile doesnt exist instead of the actual 404?? i appreciate 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Add buttons to change_form
Hi friends, I have a problem. I want add buttons to change_form, and I did the same thing of Django, I wrote a templatetags, but I have a doubt in the views. I want do something as: def newdescriptor(request): if request.method == 'POST': form = CustomNewForm(request.POST) if form.is_valid(): if 'checked' in request.POST: new = Descriptor(term = form.cleaned_data['term'], note = form.cleaned_data['note']) new.save() return HttpResponseRedirect('/admin/new/%s' % new.id) I did this function, and it works, but I used it in my custom form (CustomNewForm), and I have modify it for use it in change_form In this case, "checked" is a button, Descriptor is a model, and term and note are attributes. I create an instance of Descriptor when I press "checked" button. My doubt is how modify it for use it in chage_form? Because in this case, my "form" is..? Please, help, really I need do that. 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 -~--~~~~--~~--~--~---
Model field vs Form field vs Widget
Hi, I'm a newbie on Django and would like a reference reading on model fields, form fields and widgets. For example I want to have a model field called CountryField that automatically in forms displays as a bombobox with country options. Furthermore, I want to develop a Zip Code field like the country field with one difference the table of Zip Codes has over a million records so I want do develop a widget that popus another form that let me search over that huge amount of records and fills back do the field. I just want to create model classes with special fields, and they know how to display themselves in forms. --~--~-~--~~~---~--~~ 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-usable/pluggable app form question.
I'm working on an existing project that I'm splitting up into multiple apps. My question is about how to use those apps together. Say I have an app called "main." Then two supporting apps which sit outside of that Django project folder. They are "foo" and "bar." They are not "installed" as Python modules -- they're just in another directory on the Python path, and they are added to the INSTALLED_APPS of the main project. Let's say foo has a template which is just a div containing a form.as_p tag, and the form it uses is also in the project foo. The function to act on that form's submission is in the views.py of foo. If I want to offer that form on my site from the main app, how do I do it? Is it possible to not import the forms, views, and templates from foo into main, and just use template tags to load the foo content into main and have it processed by foo? The point is to keep all foo logic outside of the main app, so main doesn't have to "know about" foo or any of its internals. This may not strictly be a "pluggable" app, but it works for our application. Is the way to do this documented anywhere? Thanks, Shawn --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
how do you use session variables in template tags?
I cannot for the life of me get a session variable to work in a template tag. Here's what I have ... from django.contrib.sessions.models import Session register = template.Library() @register.filter(name='isinsavedlist') # this gets the latest new item from the new item flex mod def isinsavedlist(request): try: myval=int(request) except: myval=0 assert False, request.session["mylist[]"] When it tries to assert the value for mylist, i get the following: 'long' object has no attribute 'session' what am I 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
UserProfile StackedInLine without #1 showing.
Hello everyone and thanks for reading. I have a simply problem that I want to get rid of and I have not seen examples where this is achieved yet although searching around the net for quite a while. I recently extended with UserProfile so my admin.py looks like this: http://dpaste.com/hold/89067/ and models.py like this: http://dpaste.com/hold/89070/ In an app called users that is referred to by settings.py with AUTH_PROFILE_MODULE = users.UserProfile #1 Basically what I want to achieve is to get rid of the #1 StackedInLine that shows in the admin. The reason I use StackedInLine instead of TabularInLine is because otherwise I get a "Delete?" column to the right and I find it optional so I would like to either exclude that or get rid of the #1 numbering in StackedInLine. This is what it looks like in "the real world" .. (Marked with red) Stacked: http://i28.tinypic.com/2lsadkg.jpg Tabular: http://i27.tinypic.com/4lybs.jpg #2 Also. I wonder why I cannot use fieldsets when I have loaded the UserProfile models.py file in admin.py. It simply says the field doesn't exist. Do I have to call the fields differently than in django/ contrib/auth/admin.py where I've seen it 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Which query to use?
Hi there, I'm new to Django and still having some problems about simple queries. Let's assume that I'm writting an email application. This is the Mail model: class Mail(models.Model): to = models.ForeignKey(User, related_name = "to") sender = models.ForeignKey(User, related_name = "sender") subject = models.CharField() conversation_id = models.IntegerField() read = models.BooleanField() message = models.TextField() sent_time = models.DateTimeField(auto_now_add = True) Each mail has conversation_id which identifies a set of email messages which are written and replyed. Now, for listing emails in inbox, I would like as gmail to show only last email per conversation. I tried this: mails = InterMail.objects.filter(to = request.user).order_by("- sent_time") mails.query.group_by = ["conversation_id"] ... but only the first message per conversation is selected. How to select LAST email in each conversation? Thank you in advance! --~--~-~--~~~---~--~~ 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: No Module named ... problem
On Thu, Sep 3, 2009 at 12:13 PM, phoebebrightwrote: > > Russ, > > Phew - you set me on the right track there. I actually had an app > called events at the same level as the main app > > /django > /appwithproblem > /web > /events > /events > /web > > > There are various errors reported - like the above .__init__ one where > python behaves correctly but not in the way some newbies might > expect. Be great to write an app that looked for all these possible > errors - called "dont_do_that" maybe. If I had a spare 5 mins > > > Thanks so much. > Did you checked module's directory permissions? I had similar problem and simply solved by proper chmod --~--~-~--~~~---~--~~ 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: No Module named ... problem
Russ, Phew - you set me on the right track there. I actually had an app called events at the same level as the main app /django /appwithproblem /web /events /events /web There are various errors reported - like the above .__init__ one where python behaves correctly but not in the way some newbies might expect. Be great to write an app that looked for all these possible errors - called "dont_do_that" maybe. If I had a spare 5 mins Thanks so much. On Sep 3, 12:39 am, Russell Keith-Mageewrote: > On Wed, Sep 2, 2009 at 11:38 PM, phoebebright wrote: > > > And it's not a missing __init__.py program that I can see. > > > Am trying to move a site to a new server - CentOS to Ubuntu and > > version of python are changing from 2.4.3 to 2.5.2 and using wsgi now > > instead of mod_python. > > > I already have one django site running on the new server so the basic > > setup is ok. > > The old site runs fine on the old server > > But when I copy the code across, and the data, and change the settings > > and try to run I get > > > ViewDoesNotExist > > Exception Value: > > Could not import towns.town.views. Error was: No module named models > > > The offending line seems to be: > > from events.models import Event > > > There is an events app off the main directory > > It has a __init__.py > > There is a models.py and it does contain a class Event > > The paths look fine. > > > I've deleted and recopied the whole lot, restarted apache countless > > times, deleted the offending line and it just falls over on the next > > reference to the events.model file. > > > Googled till I'm cross eyed - I bet it's something simple but I'm > > baffled! > > > An ideas gratefully received. > > One possible cause is a naming confusion. Take the following directory > structure: > > events/ > __init__.py > models.py > stuff/ > __init__.py > events.py > utils.py > > In this situation, if utils.py includes "from events.models import > Event", you will get the error you describe because the 'events' > module that is found is actually stuff.events, not the top level > events. > > This error can even persist after you delete the events.py - if > events.pyc still exists in the stuff directory, it will get used in > preference to the actual code module. > > I don't know if this is your problem specifically, but this has bitten > me in the past. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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: djangol_tables
On Thu, Sep 3, 2009 at 11:05 AM, luca72wrote: > > I have fount an exple that show how to create a teble : > the first line is > import django_tables as tables > > but i get the error that django_tables don't exist > can you tell me how to render the table Is that a 3rd party module? If so, have you installed it? If you have, have you added it to sys.path so Django knows where to find it? -- Andrew McGregor 07940 22 33 11 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
djangol_tables
I have fount an exple that show how to create a teble : the first line is import django_tables as tables but i get the error that django_tables don't exist can you tell me how to render the table regards Luca --~--~-~--~~~---~--~~ 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: context processors in 404 errors
2009/9/1 Karen Tracey> On Tue, Sep 1, 2009 at 12:02 PM, Alessandro Ronchi < > alessandro.ron...@soasi.com> wrote: > >> When I return a 500 error I need to have my context_processor, in which I >> store some important vars used in my template. Is it possible? >> > > Your subject line says 404 errors but your text says 500. Which are you > asking about? > > sorry, the problem is on 500 errors. on 404 the context is correct (i've tried). -- Alessandro Ronchi SOASI Sviluppo Software e Sistemi Open Source http://www.soasi.com --~--~-~--~~~---~--~~ 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: Naive redirection programming question
I don't know if this is the best solution, but I made a context_preocessor which add content from session variable to every template i load. I then put in my layout a variable to show it. Finally, every time I want to show some message i add it to a given variable in session. Code for context processor looks like this: def flash(request): #return {'flash': {'notice': 'works'}} notice = request.session.get('flash_notice', False) request.session['flash_notice']=False warning = request.session.get('flash_warning', False) request.session['flash_warning']=False error = request.session.get('flash_error', False) request.session['flash_error']=False #sprawdza czy sa w ogole jakiekolwiek flashe if notice or warning or error: messages = True else: messages = False return {'flash': {'notice': notice, 'warning': warning, 'error': error, 'messages': messages}} it checks for three types of messages: notice, warning and error. It also add additional variable 'messages' to indicate if there is any message to show at all. So, the only thing you need to do is add a message to given session variable and reload/redirect a page. You can read up on context processors and how to use them in django documentation. Rodney Topor pisze: > Suppose you've just processed posted form data and successfully added > a new item to the database. Now you return HttpResponseRedirect('/ > items/') (I know, you should use a pattern name not an absolute URL > here) to display the list of items, including the newly added item. > > But, suppose you want to prefix the list of items with a message, > e.g., "Congratulations, your item was successfully added.". If you > were returning render_to_response('item_list.html"), you could pass in > a dictionary {"message": message}, and the template could display the > variable message if it is not empty. > > How can you do something similar when using HttpResponseRedirect()? > > Or am I thinking about this problem the wrong way? > > 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: Naive redirection programming question
On Sep 3, 3:36 am, Rodney Toporwrote: > Suppose you've just processed posted form data and successfully added > a new item to the database. Now you return HttpResponseRedirect('/ > items/') (I know, you should use a pattern name not an absolute URL > here) to display the list of items, including the newly added item. > > But, suppose you want to prefix the list of items with a message, > e.g., "Congratulations, your item was successfully added.". If you > were returning render_to_response('item_list.html"), you could pass in > a dictionary {"message": message}, and the template could display the > variable message if it is not empty. > > How can you do something similar when using HttpResponseRedirect()? > > Or am I thinking about this problem the wrong way? > > Thanks. If your user is logged in, you can use the authentication framework's Message class: http://docs.djangoproject.com/en/dev/topics/auth/#messages Otherwise, you could store it in the session temporarily, or use a GET parameter: HttpResponseRedirect('/items/?message=Thank+you+for+your+submission') and get your view to pass request.GET['message'] into the template context. -- DR. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---