using File storage

2008-08-28 Thread Jiri Barton
What is the preferred way of storing generated content into file models? class Chart(models.Model): xml = models.FileField(upload_to='charts') ... I would like compute the image on the fly, using some data in the database. How should I store the generated data? How should I use File

Re: Saving image

2007-12-19 Thread Jiri Barton
Thanks for the quick reply. I have had request.FILES in there; my problem was I misspelled the field name in the template. My question is still the same though; is this the right way to work with ImageField (FileField)? I still feel this is awkward. One has to call methods on the model instead

Saving image

2007-12-19 Thread Jiri Barton
I used to store images in the database. Now I want to store them on a disk. I have the following model: class User(models.Model): image = modes.ImageField(upload_to='userimages') ... then, I have a new form like class Information(forms.Form): image =

query parameters for search

2007-06-04 Thread Jiri Barton
What is the best way of adding query parameters (aka GET parameters) to a URL? return HttpRedirect(reverse('animal-search') + '?q=%s=%d' % (animal.name, current_page)) seems awkward to me (not to mention escaping the name). How can I avoid creating query parameters manually? Or, should I avoid

Re: OR lookups across related tables

2007-05-15 Thread Jiri Barton
That is actually the same :-) However neither Author.objects.filter( Q(name='Jiri Barton') | Q(article__title__icontains='revealed')) works. :-( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

OR lookups across related tables

2007-05-15 Thread Jiri Barton
__str__(self): return self.name Now, onto the action: -- In [10]: Author.objects.create(name='Jiri Barton') In [11]: Author.objects.filter(name='Jiri Barton') Out[11]: [] In [12]: Author.objects.filter(name='Jiri Barton') | Author.objects.filter

Re: assertRedirects

2007-05-15 Thread Jiri Barton
> Redirecting to a GET with data is a fairly eclectic edge case, and I > can't say I'm a huge fan of an assertion statement modifying the > variables it is asserting. I have but to agree with both statements. Let's leave it the way it is. > I'm inclined to put this in the 'not a common use

Re: assertRedirects

2007-05-14 Thread Jiri Barton
Another thing. I don't know if that's legal or not but I'd also need to check the query: self.client.post('/usermanagement/users/create/', { 'firstname': 'Sherlock', 'lastname': 'Holmes', }) redirects to /usermanagement/users/filter/?edit=1 (I use some search

Re: assertRedirects

2007-05-12 Thread Jiri Barton
I could live with doing multiple checks. In fact, I may want to check every URL in the redirecting chain to make sure the flow is just what I wanted. Then, I can just hard code the URLs in the chain: response = self.client.get('/page') self.assertRedirects(response, '/first/') # no need to

Re: assertRedirects

2007-05-11 Thread Jiri Barton
Thank you Russ, that has fixed the problem. I have a problem with the fix though; what if there were multiple redirects? This just happened when I jumped to use your fix today: /usermanagement redirects to /usermanagement/ which redirects to /usermanagement/users/ in my application. I

Re: dumpdata/loaddata does not use database encoding

2007-05-09 Thread Jiri Barton
You can use the YAML serializer until this is fixed. It worked for me. You will have to install PyYaml first (http://pyyaml.org/) - or easy_install pyyaml. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

assertRedirects

2007-05-09 Thread Jiri Barton
Why does assertRedirects of TestCase succeeds only if the response code is 302? One would think any 3xx should do - they are *redirects* at all. At least, I would think 301 were okay because that is what django.views.generic.simple.redirect_to generates. How am I supposed to think about that?

Re: Get to fields of a model

2007-03-28 Thread Jiri Barton
Why, I thought Person.position would be the straightforward way. I mean that was the first thing that came to my mind - I have a class and its attributes. So, the class name + dot + the class attribute name. I thought, well, if Django can detect I'm accessing a class attribute and throw an

Get to fields of a model

2007-03-28 Thread Jiri Barton
Is there a way of accessing fields of a model? I have class Position(models.Model): class Person(models.Model): position = models.ForeignKey(Position) Now, I'd like to get to this position member. Is there another way besides the following *oh my*:

check for none

2006-04-12 Thread Jiri Barton
Hello girls and boys, how do I check if a variable is None in a template? The following do not work... {% ifequal variable None %} {% ifequal variable|default_if_none:"skip" "skip" %} I want to be able to discern among None, empty list, and non-empty list; then, I want to tell the user - say

checklist

2006-03-29 Thread Jiri Barton
Hello there, I want to display a checklist dynamically: 1 apple [ ] 3 pears [ ] 8 plums [ ] ([ ] stands for checkboxes) The items are generated on the fly. I can create the form fields in a manipulator __init__ dynamically, such as in: for item in items:

Re: recommended javascript books/tutorials/howtos?

2006-02-14 Thread Jiri Barton
The javascript language itself (plus browser javascript interface - this is rather messy IMHO): http://wp.netscape.com/eng/mozilla/3.0/handbook/javascript/ I have found the following reference very valuable. It describes the MSIE web browser javascript interface. Surprisingly, it is from

validators combined

2006-01-30 Thread Jiri Barton
I have two text input fields in a form. At least one of them is required. My question is, how can I check for this? class MyManipulator = (formfields.Manipulator): def __init__(self, request=None): self.fields = [ formfields.TextField(

Custom field

2006-01-27 Thread Jiri Barton
I would like html2python be instance method. Consider the following RelaxedDateField class which can accept date in various formats. It can use day, month, and year from another date (reference date) if they are not provided. The following inputs are valid: 27 2006-27-01 27.1.2006 27.1. 27-01

Test cookie's age

2005-12-03 Thread Jiri Barton
I don't know if I'm getting it all right... The test cookie's age is the same as the age of any other cookie. My application is using views/auth/login.py, SESSION_SAVE_EVERY_REQUEST = True, and SESSION_COOKIE_AGE = 600. Let's have the following scenario. A user logs out of the application. This

Re: Declare a variable in a template

2005-12-02 Thread Jiri Barton
Wow, dorodok, that is elegant, indeed. I have already implemented by the inclusion_tag as the guys suggested, but I'm going to do it the CSS way. Robert: autocorrected it to register.inclusion_tag in my code already :-) thanks Jiri

Re: Declare a variable in a template

2005-12-02 Thread Jiri Barton
I like it! Thanks

Declare a variable in a template

2005-12-02 Thread Jiri Barton
Hello there, I have the following problem. Here's my template fragment; it defines a menu: mushrooms cheese tomatoes onion Now, I'd like to be able to highlight one item in some templates, and another item in other templates. Only the templates know what should be

Re: What is the documentation format?

2005-10-16 Thread Jiri Barton
The format is reStructuredText, also referred to as reST or rst. You can transform it to HTML using docutils. You can learn more about this and the format at http://docutils.sourceforge.net/rst.html HTH, Jiri

Re: User Authentication - What's the best way?

2005-09-19 Thread Jiri Barton
I am struggling with the builtin authentication interface. I have initialized the tables and entered some data in the authentication tables. I have a couple of questions though, (A) I want to use django.views.auth.login.login. I have entered this in the url patterns. The implementation of this