View returns no queryset

2009-11-28 Thread R. Gorman
I've got a real stumper. Well, a stumper for me; I'm hoping someone has some insight. Here's the view I'm calling: def season_schedule_month(request, league_slug, year, month): """Given a league slug, retrieve the season's schedule month by month. return date_based.archive_month(

Re: Help a newbie with his simple foreignkey problem?

2009-11-12 Thread R. Gorman
> b = Book.objects.get(id=1)  #new book > request.user.get_profile().shelf1.add(b)  #add book to shelf1 > request.user.shelf1.remove(b)     #remove from shelf1 > request.user.shelf2.add(b)      #add to shelf2 Looks like you're trying to add the foreignkey to the User model instead of the

Re: CSV to JSON snippet

2009-11-12 Thread R. Gorman
What is the error message you are receiving? R. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to

Re: How periodically import content to Django?

2009-11-12 Thread R. Gorman
If the file can be parsed you could setup a script to read the file and use the get_or_create query to add new entries. R. On Nov 12, 10:31 am, bowlby wrote: > Is there a way to periodically import content to Django by means of > uploading a file of some sort? > > The use

Re: Why does form.is_valid() throw ValueError?

2009-05-23 Thread R. Gorman
Is your form variable the problem? Based on using f.is_valid() the code prior to this should be: f = *YourFormObject*(request.POST) R. On May 23, 12:07 am, Rex <rex.eastbou...@gmail.com> wrote: > On May 22, 4:33 pm, "R. Gorman" <r.m.gor...@gmail.com> wrote: >

Re: Why does form.is_valid() throw ValueError?

2009-05-22 Thread R. Gorman
You are correct in your understand that .is_valid() returns False if the data is invalid. Are you sure you are not processing data irrespective of whether the data validated or not? A little more detail on how your processing your data might provide some insight. R. On May 21, 10:48 pm, Rex

Re: How to convert 10 digit mysql date to django date format

2009-05-22 Thread R. Gorman
As the previous post mentioned, I'm assuming that is a unix timestamp. The module you want to use is datetime. import datetime mysql_date = datetime.datetime.fromtimestamp(1219848914) mysql_date can be save directly to a datetime model field. However, if you are wanting the date formatted as

Re: Shared connection stuff?

2009-05-22 Thread R. Gorman
You can control database connections and transactions using transaction management: http://docs.djangoproject.com/en/dev/topics/db/transactions/ On May 22, 7:41 am, "m...@nysv.org" wrote: > Hi! > > I'm using python-processing to run things in parallell based > on

Re: i have a question about model

2009-05-22 Thread R. Gorman
I do not see any reason why the models you have provided would behave in that manner. I would suggest posting the view you are using to return the records. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

Re: i need a unlimited subcategories

2009-04-27 Thread R. Gorman
Treebeard is another option. http://code.google.com/p/django-treebeard/ I'm sure between mptt or treebeard, you'll find something suitable. R. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group.

Re: graph tools

2009-04-23 Thread R. Gorman
There's also Google visualizations (http://code.google.com/apis/ visualization/). They have a python library that can easily interact with Django (http://code.google.com/apis/visualization/documentation/ dev/gviz_api_lib.html). --~--~-~--~~~---~--~~ You received

Re: Why does django add settings to be part of my urls and then give me a reverse url lookup error?

2009-04-18 Thread R. Gorman
Your likelihood in resolving this issue would be much higher if you include your code (urls.py, form html, etc.) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: Fwd: Default ManyToMany ordering

2009-04-12 Thread R. Gorman
If it's for the admin interface the admin option ordering (http:// docs.djangoproject.com/en/dev/ref/contrib/admin/#ordering) might do the trick. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group.

Re: Simple Query?

2009-04-12 Thread R. Gorman
The easiest answer is your foreignkey is pointing the wrong way. With your current model definitions you could do MediaAndContainer.objects.select_related('name'). To go in the opposite direction you need to use _set (http://docs.djangoproject.com/

Re: Local Server seems to not work with typing parameter in the url?

2009-03-24 Thread R. Gorman
If that's an exact copy, you have a typo in your URL variable; you're missing a / after CSserver. R. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: User Auth... is_group in a template?

2009-02-09 Thread R. Gorman
Just an idea, but what about using a user profile and then using the get_profile function? ex. {% if user.get_profile.customer %} customer block {% endif %} R. On Feb 9, 11:01 am, Alfonso wrote: > I'm wondering, I can easily add a if statement to detect whether a >

Re: running template filters after the page has loaded.

2008-12-08 Thread R. Gorman
You're likely going to need to need to run to urlencode function within the view that processes your ajax request. Should be able to import using 'from urllib import urlencode' and then 'urlencode(*your string variable*)'. R. --~--~-~--~~~---~--~~ You received

Re: i18n and l10n of templates for emails

2008-12-08 Thread R. Gorman
I ran into the same issue, but different encoding. I found that adding a special comment line to the beginning of the python file allowed for the desired encoding (source: 2.2.3 from http://www.python.org/doc/2.5.2/tut/node4.html). Hope that helps, R.

Re: Sending automatic emails

2008-11-30 Thread R. Gorman
It is also possible to use a cronjob to initiate a script to send an e- mail. --~--~-~--~~~---~--~~ 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

Re: Access the HTTP request from a model

2008-11-24 Thread R. Gorman
The request data is available in your views as a dictionary. For example: def memberView(request): if request.method == 'POST': request.POST['foo'] ... R. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

Re: Access the HTTP request from a model

2008-11-24 Thread R. Gorman
The request object is accessed in your view. def memberView(request): --~--~-~--~~~---~--~~ 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

Re: Help for crontab

2008-11-23 Thread R. Gorman
Here's a third option that I've found useful when wanting to run a cron job: http://blog.capstrat.com/articles/making-django-environmentally-friendly/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users"

Re: Browser access to manage.py / django command extensions

2008-11-10 Thread R. Gorman
Oh the weight of various risks... If you're just looking to execute a command and the response is quick an os.system command in a view might work. If it's a longer running process you might want to look at subprocess. R. --~--~-~--~~~---~--~~ You received this

Re: ifequal and numbers

2008-10-27 Thread R. Gorman
You would probably be better off writing a custom template tag (http:// docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom- template-tags). R. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: nOOb alert, accessing set variables in template

2008-10-17 Thread R. Gorman
You could use {{ for obj in A.a_set.all }} and print out the {{ obj }}. R. --~--~-~--~~~---~--~~ 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

Re: Search functionality over the DB

2008-10-16 Thread R. Gorman
The is a view I have to search some of my models: def search(request): query = request.GET.get("s", "") q = Q() for term in query.split(): q |= Q(abstract__icontains=term) | Q(next_field__icontains=term) results = [i for i in

Re: error on live server, 'module' object has no attribute 'models'

2008-10-03 Thread R. Gorman
If it only happens some of the time it often indicates you need to restart your http server. R. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: 'get_latest' is not a valid tag library

2008-09-25 Thread R. Gorman
Post your template code as well. R. --~--~-~--~~~---~--~~ 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

Re: update or add object?

2008-09-22 Thread R. Gorman
get_or_create http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-create-kwargs R. On Sep 22, 7:55 pm, John M <[EMAIL PROTECTED]> wrote: > Is there a method I can call in a view that given a key, it checks to > see if that object exists and if it does returns that object, or if

Re: Authentication: user_passes_test() - issue

2008-09-22 Thread R. Gorman
I'm not 100% sure I understand your question, but I believe you're asking how to pass the model object to the view that will verify if the request was made by a certain user. If so, you should look at using the url template tags (http://docs.djangoproject.com/en/dev/ref/

Re: development environment versus production environment

2008-09-18 Thread R. Gorman
As you guessed, the abstraction layer can take care of *most* code. Because it is possible to write custom SQL commands it would be possible to have code not compatible with all database types. Beyond that exception though, you should be fine. R.

Re: mod_python errors in production deployment. apache vs django

2008-09-17 Thread R. Gorman
<[EMAIL PROTECTED]> wrote: > On Sep 17, 4:54 pm, "R. Gorman" <[EMAIL PROTECTED]> wrote: > > > Glad to hear you have some of your setup up and running. > > > Your comment on defining fields in the models surprised me though. > > All the fields

Re: Render to Response or Another Ways to Getting Data

2008-09-17 Thread R. Gorman
If there is data you would like available to every template you want to look into context processors. There's a good tutorial for it here: http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/ R. --~--~-~--~~~---~--~~ You received this

Re: mod_python errors in production deployment. apache vs django

2008-09-17 Thread R. Gorman
Glad to hear you have some of your setup up and running. Your comment on defining fields in the models surprised me though. All the fields for your models in Django should start with model, followed by the field-type, as the documentation states. Are you sure you have models module being

Re: Introducing myself and first question

2008-09-17 Thread R. Gorman
"@login_required(redirect_field_name='next')" statement in views.py > > I'm very confused. > > What can I try? > There is any documentation about an entire site under access control? > > Thanks >     Mirto > > R. Gorman ha scritto: > > > > >

Re: mod_python errors in production deployment. apache vs django

2008-09-16 Thread R. Gorman
What is in your urls.py file? That's where your urlpatterns should be stored. R. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Introducing myself and first question

2008-09-16 Thread R. Gorman
Ah, I see. I didn't see that on the first read through - I think I need a nap. Your URLs are lacking the /djmsb/ because that's how you currently have your url.py patterns setup. You just need to add 'djmsb/' to the front of your urls: from django.conf.urls.defaults import * from

Re: Getting specific data from a many to many field.

2008-09-16 Thread R. Gorman
> > > try: > >     return > > self.system_pictures.filter(image_category__name='Header_Pic')[0] > > except IndexError: > >     pass > Make sure you have the indentation set correctly. The second and third line of the posted code should actually be one line. I think the formatting was changed

Re: Getting specific data from a many to many field.

2008-09-16 Thread R. Gorman
> > try: > >     return > > self.system_pictures.filter(image_category__name='Header_Pic')[0] > > except IndexError: > >     pass > > > which will always get the first related image in that category, and > > silently swallows the error that's thrown if there's no such picture. > > Can't seem to

Re: Introducing myself and first question

2008-09-16 Thread R. Gorman
On Sep 16, 11:32 am, Mirto Silvio Busico <[EMAIL PROTECTED]> wrote: > > DJMSB.VIEWS-- > > from django.shortcuts import render_to_response > from django.contrib.auth.decorators import login_required > from

Re: similar method for get_or_create()

2008-07-18 Thread R. Gorman
Why do you need a method other than get_or_create? Could you not try to retrieve the object using get_or_create and then update the object if retrieved? R. On Jul 18, 5:57 am, leppy <[EMAIL PROTECTED]> wrote: > hi everyone, > > Can anyone tell me a method similar to django model's