Re: Last object of a set?

2009-09-03 Thread watusee
Thank you Brandon! That worked great. kind regards, -raymond On Sep 3, 10:07 pm, Brandon wrote: > 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

Cloning/using Django admin without auth_ and django_ database tables?

2009-09-03 Thread Ulf Kronman
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

Getting values set across relation spanning multiple tables

2009-09-03 Thread bvemu
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

Re: What happened to djangoplugables.com?

2009-09-03 Thread Anthony
Awesome, thanks! It looks very nice as well. On Sep 3, 8:53 pm, Andy McKay wrote: > 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

Re: Serializing with not just the query data but also some additional columns

2009-09-03 Thread Russell Keith-Magee
On Fri, Sep 4, 2009 at 11:58 AM, Andy McKay wrote: > > > 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

Re: how do you use session variables in template tags?

2009-09-03 Thread Brandon
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 Roberts wrote: > I

Re: Last object of a set?

2009-09-03 Thread Brandon
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 %}

Re: 'function' object has no attribute 'fields' errror on first access to development server

2009-09-03 Thread Andy McKay
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

Re: Last object of a set?

2009-09-03 Thread Andy McKay
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

Last object of a set?

2009-09-03 Thread watusee
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

Re: Serializing with not just the query data but also some additional columns

2009-09-03 Thread Andy McKay
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,

Re: What happened to djangoplugables.com?

2009-09-03 Thread Andy McKay
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

Re: extending objects.get()

2009-09-03 Thread Andy McKay
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:

zxJDBC.DatabaseError: driver [org.postgresql.Driver] not found Jython

2009-09-03 Thread Brandon Taylor
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:

extending objects.get()

2009-09-03 Thread dwh
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

'function' object has no attribute 'fields' errror on first access to development server

2009-09-03 Thread hamdiakoguz
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.

Re: Outputing an integer value in a template, but with some calculation done on it

2009-09-03 Thread Tim Chase
> 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

Re: how to deploy an app that gets used by people in multiple time zones

2009-09-03 Thread Margie
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

What happened to djangoplugables.com?

2009-09-03 Thread Anthony
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

Serializing with not just the query data but also some additional columns

2009-09-03 Thread Neeraj
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

"Stupid newbie" question - why does this IntegrityError happen?

2009-09-03 Thread Johnson Earls
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

Re: Imagefield, PIL and save()

2009-09-03 Thread aa56280
On Sep 3, 5:31 pm, Rob Broadhead wrote: > 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

wrong links when using deployment server

2009-09-03 Thread turkan
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"

Outputing an integer value in a template, but with some calculation done on it

2009-09-03 Thread Neeraj
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,

Re: Re-usable/pluggable app form question.

2009-09-03 Thread Peter Coles
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

Re: Imagefield, PIL and save()

2009-09-03 Thread Rob Broadhead
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

Imagefield, PIL and save()

2009-09-03 Thread aa56280
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 =

Re: how to deploy an app that gets used by people in multiple time zones

2009-09-03 Thread Tim Chase
> 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

Re: how to deploy an app that gets used by people in multiple time zones

2009-09-03 Thread Tracy Reed
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

how to deploy an app that gets used by people in multiple time zones

2009-09-03 Thread Margie Roginski
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

Re: Parsing / Deserializing a JSON String

2009-09-03 Thread J. Cliff Dyer
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:

Assign a User/Group to a Site

2009-09-03 Thread Liquidrums
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

Re: JSON serialization of related records.

2009-09-03 Thread Amir Habibi
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

Add buttons to change_form

2009-09-03 Thread Sandra Django
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

Re: Which query to use?

2009-09-03 Thread edkirin
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

Re: Parsing / Deserializing a JSON String

2009-09-03 Thread Eric
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

Re: are you using mptt, treebeard or something else?

2009-09-03 Thread Ben Davis
>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

Re: Return FK model

2009-09-03 Thread Ben Davis
@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

Re: context processors in 404 errors

2009-09-03 Thread Karen Tracey
On Thu, Sep 3, 2009 at 4:27 AM, Alessandro wrote: > 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

Re: are you using mptt, treebeard or something else?

2009-09-03 Thread Sandra Django
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

Re: Return FK model

2009-09-03 Thread Javier Guerra
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

Re: Return FK model

2009-09-03 Thread Ben Davis
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

are you using mptt, treebeard or something else?

2009-09-03 Thread Aljosa Mohorovic
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

Re: Return FK model

2009-09-03 Thread Yanik
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

Re: Return FK model

2009-09-03 Thread Ben Davis
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,

Re: django profiles question and http404

2009-09-03 Thread aschmid
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 schmid

Need help with a small Django project

2009-09-03 Thread Happyrainb
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.

Return FK model

2009-09-03 Thread Yanik
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"

Re: Model field vs Form field vs Widget

2009-09-03 Thread Joshua Russo
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

django profiles question and http404

2009-09-03 Thread andreas schmid
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

Add buttons to change_form

2009-09-03 Thread Sandra Django
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

Model field vs Form field vs Widget

2009-09-03 Thread alexandre...@gmail.com
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

Re-usable/pluggable app form question.

2009-09-03 Thread Shawn Milochik
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

how do you use session variables in template tags?

2009-09-03 Thread Bobby Roberts
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

UserProfile StackedInLine without #1 showing.

2009-09-03 Thread dezza
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:

Which query to use?

2009-09-03 Thread edkirin
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 =

Re: No Module named ... problem

2009-09-03 Thread Maksymus007
On Thu, Sep 3, 2009 at 12:13 PM, phoebebright wrote: > > 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 >

Re: No Module named ... problem

2009-09-03 Thread phoebebright
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

Re: djangol_tables

2009-09-03 Thread Andrew McGregor
On Thu, Sep 3, 2009 at 11:05 AM, luca72 wrote: > > 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

djangol_tables

2009-09-03 Thread luca72
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

Re: context processors in 404 errors

2009-09-03 Thread Alessandro
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

Re: Naive redirection programming question

2009-09-03 Thread Spajderix
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

Re: Naive redirection programming question

2009-09-03 Thread Daniel Roseman
On Sep 3, 3:36 am, Rodney Topor wrote: > 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