Re: Check if in query set...

2007-12-09 Thread Tim Chase
> I want to check if the currently logged in user has permission to edit > a particular student. > > s = Student.objects.get(pk=student_id) > parents = s.parents.all() > > And then check if logged in user.id matches against any of the parent > ids. Looks like you're interested in something

Re: get choice value in Form

2007-12-07 Thread Tim Chase
> # Assume these are key-value pairs > AGE_CHOICES=( > (1, '0-3'), > (2, '3-6'), > (3, '6-15'), > ) > > class CustomForm(forms.Form): > age = forms.ChoiceField(label='Age', choices=AGE_CHOICES) > > How can I get the value (not the key) of the age attribute after validation? > >

Re: Sending two list...using for loop in template

2007-12-04 Thread Tim Chase
> return render_to_response('webpage.htm', {'manu': s, 'thelist': > mylist}) > > / > > Here is what I have in my template > > {% for a in manu %} > {{ thelist.{{forloop.counter0}} }} > {% endfor %} Given that you're not using "a" in your loop, is there

Re: making two-column table from one-column data

2007-12-02 Thread Tim Chase
> If your data is in the 'data' context variable, then try this: > > > {% for d in data %} > {% if forloop.counter0|divisibleby:"2" %}{% endif %} > {{d}} > {% if forloop.counter|divisibleby:"2" %}{% endif %} > {% endfor %} > {%

Re: INTERNAL_IPS and netmask/CIDR notation

2007-11-23 Thread Tim Chase
>> I don't know whether this would be better done by replacing the >> INTERNAL_IPS functionality, or adding a second similar means, but >> for my app, it's helpful to know if the user is "internal" or >> "external" as defined by several netmasks/CIDR addresses. Rather >> than adding every

INTERNAL_IPS and netmask/CIDR notation

2007-11-23 Thread Tim Chase
I don't know whether this would be better done by replacing the INTERNAL_IPS functionality, or adding a second similar means, but for my app, it's helpful to know if the user is "internal" or "external" as defined by several netmasks/CIDR addresses. Rather than adding every address in the

Re: Street address normalisation

2007-11-20 Thread Tim Chase
> I have an issue with users doing a lookup on street address. [snip] > This seems like asuch a common problem; are there any > libraries for this; what is the "correct" way to handle this? > How do google; Mapquest and Yahoo do this? (I don't have quite > their resources; but it would point me

Re: How to access method parameters

2007-11-20 Thread Tim Chase
> self.create(50, 50, "round") > > def create(self, wsize, hsize, shape): > var = self.get_shape_filename() > etc > > /// > > I get an error whenever it hits the line 'var = > self.get_shape_filename()'. The error is: > > object has no attribute

Re: Redacted Fields

2007-11-16 Thread Tim Chase
> Could you do something like a wrapper object in your view before it > hits the context? The wrapper below relies on a field list, but you > could easily have it inspect the Meta class on the model and build the > list. This is a nice sort of idea. Is there a way to expand it from an

Redacted Fields

2007-11-16 Thread Tim Chase
I've been playing around with some ideas and was hoping to get feedback about what the "right" sort of way to do it would be (the Django analog to "Pythonic"). Various models have sensitive fields associated with them that should only be available to a template if the requester is on a "secure"

Re: learning django and python

2007-11-13 Thread Tim Chase
> well I have a book on php,apache and mysql so are there? any > differences between mysql and postgreSQL for django > (proforanmce features etc.) They're becoming closer in terms of their features. A couple observations in my experience: - MySQL tends to be faster and have some nice "my

Re: webhostingbuzz, anyone tried

2007-11-08 Thread Tim Chase
> These guys seem to have very tempting packages. They say they support > django. What I'd like to know is what kind of support? Do I have to > install it on my home folder, or is it preinstalled on their servers? I know two folks using WHB, though not for Django. Both are using the basic

Re: Start development: which branch?

2007-11-07 Thread Tim Chase
> Should I use trunk for development? Or is there any branch > better for development? (with regard to the introduction of > newforms) I think the general rule of thumb is: If you absolutely must have a stable API, and don't need anything more than what 0.96 offers (lots of new features and

Re: Help With Modeling This

2007-11-06 Thread Tim Chase
> I've run into a problem trying to model something in Django > and could use some advice. In a nutshell, I'm trying to > relate a single table to multiple (other) tables using a > single foreign key field and foreign key type. I'm aware of > the manytomany relationship type of Django but I

Re: "and" type query over related objects

2007-11-06 Thread Tim Chase
> I need to be able to query an object that has a set of related > objects - the query is to find which objects contain the same > set of query objects. For example the main object could be a > research paper and the related object would be a set of topics > that the papers could contain. This

Re: 3 questions about user-defined Field types

2007-11-03 Thread Tim Chase
Malcolm, Thanks for taking the time to look into my questions. >> I'd like to build some automated tests as I go along, but I'm not >> sure how to go about building a test harness that creates a >> temporary model with my field-type, creates a table in the DB >> with that field in it, and then

3 questions about user-defined Field types

2007-11-03 Thread Tim Chase
Using this section of the Master Class notes found here http://toys.jacobian.org/presentations/2007/oscon/tutorial/#s103 I've been working to create a custom field-type for consolidating some of my work that was previously duplicated across several models. The field-type in question is a

Re: keeping SECRET_KEY secret

2007-11-02 Thread Tim Chase
> Personally I wonder if this is due to a conception that the *project* > is somehow the deliverable; I think James touches here on one of the key factors in this whole issue. If I have a project that I'm making publicly available, there are many project related settings that need to be

Re: Dynamic Query (PS)

2007-11-01 Thread Tim Chase
>> Depending on the checkbox selection it might produce a sql string >> like: >> SELECT user_id FROM Bio WHERE (race='A' OR race='W' OR race='H') AND >> (eye_color='B' OR eye_color='G' OR eye_color='H') AND (hair_color='W' >> OR hair_color='B') Though my solution would be logically about the

Re: Dynamic Query

2007-11-01 Thread Tim Chase
> class Bio(models.Model): > HEIGHT_CHOICES = ( > ('A',"< 5' (< 152cm)") [snip] > ,('Z',"7' 0'' (213cm)") > ,('*',"> 7'' (> 213cm)") > ) > WEIGHT_CHOICES = (('A',"<100lbs (<45kg)"),('B',"100lbs

Re: Off Topic: Slug regular expression

2007-10-31 Thread Tim Chase
>> Is there any difference between: >> >> r'^accounts/(?P[\w-]+)/$' >> >> and >> >> r'^accounts/(?P[-\w]+)/$' > > they match the same. To expand on Paul's answer, yes they're the same. The only time order matters is detailed at [1] where the character-set "[...]" notation is detailed. Namely

Re: datetime field < year 1900

2007-10-20 Thread Tim Chase
> I'm working on a brithdate/deathdate table and am having problems with > this limitation. Realize this is a result of python's datetime > strftime() issue but was wondering if anyone figured out a django > workaround that wasn't a total hackfest. Since I haven't noticed much feedback on this,

Re: Use .html at the end of the url instead of / ?

2007-10-17 Thread Tim Chase
> Having your URLs end with a slash is good. It looks better and shortens > your pages address. Also, in the future, you may find that not all of > your pages are going to be text/html. While I'm ambivalent about the trailing slash (the below assumes that it's disabled), many of my urls/views

Re: RegexField and Admin interface

2007-10-10 Thread Tim Chase
> class Property(models.Model): > def isValidUKPostcode(self, field_data): > p = re.compile(r'^(GIR > 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HIK-Y][0-9](| > [0-9]|[ABEHMNPRVWXY]))|[0-9][A-HJKSTUW]) [0-9][ABD-HJLNP-UW-Z]{2})$') > if not p.match(field_data['postcode']):

Re: static images with built-in django server

2007-10-06 Thread Tim Chase
> Thanks. Yes, using relative paths is the right idea - it's a shame that > the base url's have to be hard coded in the templates. I understand > from a web efficiency standpoint of Django not handling static content > but from an application development standpoint this is a real complexity

Re: Should Django have a road map?

2007-10-01 Thread Tim Chase
> similar - sooo, do you think it's worthwhile to pull this together on a > about / welcome / introduction page under a heading like "How Django > Works". Then when these comments come, they can be pointed to the > page. If you think it's worthwhile, I'll post some text to a > documentation

Re: Debugging Django scripts problem

2007-09-29 Thread Tim Chase
> the symlinks I've added. For completeness sake, here's the full > listing of my site-packages directory: > > www:/usr/local/lib/python2.5/site-packages# !ls > ls -lAF > total 1034 [stuff] > -rw-r--r-- 1 root staff885 Aug 30 19:30 easy-install.pth > lrwxrwxrwx 1 root staff 26 Sep 28

Re: Compiling views.py?

2007-09-27 Thread Tim Chase
> i have to quickly make a few changes. I have replaced one > email address in views.py by another. Now, i'd like to know if > i need to recompile this views.py file, and if so what is the > exact command ( will python views.py work). It's non-obvious if you're coming from the compiled-language

Re: about auth

2007-09-27 Thread Tim Chase
> hi people, I got a little question, how can I make some users add news > (model News), modify only news owned by him or even delete his news, not > others users news, but only admins can publish all of them? http://www.djangoproject.com/documentation/authentication/#permissions The stock

Re: many-to-many query

2007-09-26 Thread Tim Chase
> So I need to get the videos that match ALL the keywords that I provide > in the query, like "give me all the videos that contain the keywords > 'horse', 'country' and 'green'". These videos may contain another > keywords or not, but I need them to contain at least ALL the keywords > provided. >

Re: custom sql portability

2007-09-26 Thread Tim Chase
> an obvious one is to check whether the query uses standard syntax and > features. and if not, rewrite it so it does. > > also, try to test it on different databases. For those items that aren't quite so portable, it's helpful to follow the Django examples like you'll find in

Re: What's the best way to handle big sets of data?

2007-09-25 Thread Tim Chase
> I'm developing a Django project that's going to handle with > big sets of data and want you to advise me. I have 10 internal > bureaus and each of then has a 1.5 million registers database > and it really looks to keep growwing on size on and on. I > intend to use Postgres. > > The question:

Re: guid's in python

2007-09-25 Thread Tim Chase
>> I've been able to dig into this a little bit more and it >> looks like django.utils.simplejson.decoder doesn't support >> the '\x' escape character. Is this an intentional omission, >> a bug in Django, or just me misunderstanding Python? > > JSON does not support the '\x' escape; see json.org

Re: View didn't return an HttpResponse object?

2007-09-25 Thread Tim Chase
> if not request.GET.get('avatarkey',''): > raise Http404 > elif len(request.GET['avatarkey']) != 36: > raise Http404 Just as a side-note, these two are a bit redundant. I'd suggest either if 'avatarkey' not in request.GET or

Re: QuerySet filters. Making both sides of the comparison parametric

2007-09-24 Thread Tim Chase
> if (search_query['organisation']!=""): > jobs = jobs.filter(organisation=search_query['organisation']) > if (search_query['region']!=""): > jobs = jobs.filter(region=search_query['region']) > if (search_query['category']!=""): > jobs =

Re: How does Django know the PK of the newly created object

2007-09-23 Thread Tim Chase
http://code.djangoproject.com/browser/django/trunk/django/db/models/base.py#L266 In the function that Alex linked to, the answer to your question is on line 266: backend.ops.last_insert_id(...) This varies from backend to backend, but is abstracted enough to know what the most recent insert

Re: How to implement funky caching

2007-09-22 Thread Tim Chase
> "you redirect 404 errors to a script, which looks at the requested > URL, decides whether it should actually exist, and if it should it > builds the file from the database, saves it to the filesystem, and > then returns the page to whoever requested it. Next time that URL is > requested, the

Re: new field types

2007-09-21 Thread Tim Chase
> Obviously the Django field types provide more semantics than the basic > database datatypes. Thus I assume that whenever there is a new type of > field which does not fit in the given categories, it is a good idea to > define such a new datatype. Correct? most likely. > Example: I would like

Re: Is there a TRIM feature for templates in Django 0.91

2007-09-19 Thread Tim Chase
> TRIM would delete any whitespace from the string (tabs, newlines, > spaces, ...). SPACELESS comes close as it will convert all the > whitespace into just 1 space. Should TRIM delete *all* whitespace, or just leading/trailing whitespace? Trim functions usually just remove leading/trailing

Re: Trying to use order_by on a list object

2007-09-19 Thread Tim Chase
> I guess the order_by('price') is working. However, it's not > working how I want it to. When I do the order_by on price > django think that a price of 59.99 is greater than a price of > 129.99. I guess it's looking at the first character and since > a 1 is less than a 5 it puts the 129.99

Re: Django and Twitter

2007-09-19 Thread Tim Chase
> Thanks for taking a look. Still feeling my way on what I need to post > to be most helpful. I'd say you did correctly, describing the problem and not flooding the list with 20 diff. config files and code...if the list needs more info, we usually ask for it :) However, for future reference,

Re: Is there a TRIM feature for templates in Django 0.91

2007-09-18 Thread Tim Chase
>> I looked over the docs >> http://www.djangoproject.com/documentation/0_91/templates/ >> >> but the closest thing was SPACELESS > > - What does a TRIM filter do? Perhaps it change the colour of the trim > on your website? I suspect what some languages call Trim is the Python function/method

Re: ORM / Performance

2007-09-18 Thread Tim Chase
> Between caching, profiling, and having a good sense of what your Profiling...the #1 thing to do. Without profiling the app under "normal usage" (common actions & browsing patterns gleaned from the current deployment) scaled to high loads, you're just twiddling knobs and wasting time. If

Re: Django and Twitter

2007-09-18 Thread Tim Chase
> However, when I save the record in the Django admin, I get this: > > [Errno 25] Inappropriate ioctl for device > > Exception Location: build/bdist.linux-i686/egg/twitter.py in > _GetUsername, line 1498 A couple pieces of information would be helpful: Which OS? Could you provide the

Re: reassessing our Operating System

2007-09-18 Thread Tim Chase
> Any special reasons debian based installs are better than > fedora based ones? I can't say there should be any sort of major difference once meta-package programs were instituted for dependency tracking. My understanding is that Yum may do this sort of thing. I tried Red Hat early in the

Re: reassessing our Operating System

2007-09-18 Thread Tim Chase
> (live publicly viewable sites only) > 1. What OS are you using to run Django on? OpenBSD and Debian Linux > 2. What OS do you think is most popular for running Django on? Debian and its derivatives (Ubuntu, etc...anything using apt) > 3. What OS do you think is most suited for running

Re: Using a filter with many to many relationship

2007-09-17 Thread Tim Chase
>> Ok, the query should then be: >> >> Offer.objects.filter(Q(terms__term__exact = 'ThemePark') & >> Q(terms__term__exact = 'London')) > > Still returns an empty query set. Checking some of the other posts I > think this is a failing which is particular to ManyToMany > relationships the

Re: Generating Q objects for different model fields

2007-09-16 Thread Tim Chase
> I'd like to make a filter composed by ORing several Q objects, each of > which acts on a different model field. > For example I have a model with the fields "name", "title", > "description" and I want to make a Q object like the following: > Q_name = (Q(name__istartswith="hello") &

Re: Performance for django for years

2007-09-09 Thread Tim Chase
> Well, secondly I have one question: I have a model A that have a field > "year" that means the year that A was made. I just want to know if > it's best (for performance) to code as: > > class A(models.Model): > year = models.CharField(maxlength=4) > [...] > > or > class A(models.Model):

Re: ANN: Making some changes to djangoproject.com

2007-09-07 Thread Tim Chase
>> These changes are in preparation of some exciting news, but I'll leave >> y'all in suspense until next week. > > You're rewriting Django in Java! Finally, enterprise capability! I thought it was one of the following: - adding "2.0" to the official name to make it a "Web 2.0"

Re: Using multiples version of Django on the same server

2007-09-07 Thread Tim Chase
> I'm setting up a new server to host my Django projects and they don't > each use the same version of Django (0.95, 0.96 and svn). Is their a > way to configure each virtualhost to use their own version of Django ? I've done something like this whereby I had several of the development branches

Re: another complex SQL / extra() question

2007-09-06 Thread Tim Chase
> SELECT t > FROM ( > SELECT thing.thing_id AS t, COUNT > (thing.thing_id) AS c > FROM ( > SELECT thing_id > FROM myapp_thing_sources > WHERE

Re: Signing with mouse

2007-09-04 Thread Tim Chase
> I am looking for a python based utility that will allow a user to sign > their name with a mouse and save the resulting image for inclusion in > a PDF. Has anyone heard of something like this? Well, you're asking a python question on the Django list. Unless you're trying to do this in a

Re: hai am new one to django

2007-09-04 Thread Tim Chase
> am new one to django welcome > am working in php mysql I'm sorry ;) > me whats django and how its defer from php ruby on rails... Django is frequently describe as "Ruby on Rails, but using Python instead of Ruby". That alone is enough for me to like it ;) There are some other more

Re: markdown issue

2007-09-04 Thread Tim Chase
> i find this code translate enter once to "" , and enter twice is > still "". > i want keep "", ie. enter once i get a "", enter twice i get a > "" > is this possible? Ah...I misunderstood what you wanted. Yes, the same sort of thing could work: r = re.compile('([^\n])\n([^\n])') text =

Re: .latest() view not showing latest entry

2007-09-03 Thread Tim Chase
> particular table. I've got it working like this in my urls.py: > > latest_info_dict = { > 'queryset': Page.objects.all(), > 'slug': Page.objects.latest().slug, > } At this point, your urls.py has a semi-static dict in it...most importantly, latest_info_dict['slug'] is set to a

Re: Sharing models between applications

2007-09-02 Thread Tim Chase
> I've a projects that should share the db models > > I know I can create a models.py file in the project's home dir but > manage.py syncdb doesn't read it from there (and I really want to keep > it all on Python code without need to run mysql -u app -p) I've done this in one project by

Re: markdown issue

2007-09-02 Thread Tim Chase
> but this is the same as enter twice, user must remember to end with > one or more space. > > is there other plugin like markdown which is a truely what they is > what they get? Well, it's possible to pre-process the user's input with something like import re add_br_re = re.compile('\n+')

Re: newforms form processing

2007-08-31 Thread Tim Chase
> How can i best program a view that both adds and updates certain > values in a table. I know that django can tell the difference when you > want to update and when to insert. I tried using the > Classname.objects.create(args)...but this doesn't seem to work...it > just inserts instead of

Re: template image problem

2007-08-30 Thread Tim Chase
> Static content is served by http server not django. > http://www.djangoproject.com/documentation/static_files/ For development purposes, in my urls.py after defining all my "business" urls, I have from sys import argv if 'runserver' in argv: urlpatterns += patterns('',

Re: second query question

2007-08-28 Thread Tim Chase
> class Property(models.Model): > > thing = models.ForeignKey(Thing) > property_type = models.ForeignKey(PropertyType) > value = models.CharField(...) > ... > > I want to find, for a given PropertyType, all the Things that are > lacking any Property of that type. > >

Re: URL dispatcher with filter

2007-08-26 Thread Tim Chase
> What I currently have to do is to define each view (such as to handle > "foo" above) as: > > @login_required > def foo(request, cid): > c = get_object_or_404(C, pk=cid) > if user_can_access_c(request.user, c): > # do something that's allowed > # ... > else: >

Re: Free Django application hosting?

2007-08-24 Thread Tim Chase
> I'm developing a couple of ideas and I need other people's > input. The applications are currently on my development PC at > home. Are there any sites that offer free Django application > hosting (not source)? I don't believe I've come across any such generous soul. Likely, your best option

Re: Importing Excel/CVS into Database

2007-08-23 Thread Tim Chase
> Tim, in your code: > >filename = 'foo.tab' >for i, line in enumerate(open(filename)): > if i == 0: continue # skip the header row > (fieldname1, fieldname2, fieldname3 ... > ) = line.rstrip('\n').split('\t') > cursor.execute(""" >INSERT INTO app_foo >

Re: non-event driven method called?

2007-08-23 Thread Tim Chase
> But at the same time, this is *not* something Django is designed to > do. On the other hand, it *is* something cron is both designed to do > and quite good at. Django is not a replacement for the operating > system ;) "uh, yeah...I was trying to rewrite Emacs in Django..." :) -tim

Re: Arithmetic operations in a templete

2007-08-23 Thread Tim Chase
> I know my question could be a bit silly but... I dont know how to do > it. Do anybody know how to do arithmetic operations in a templete? > > {{elem}} > > what I want to do is something like {{ elem }} + 100 There's an "add" filter...

Re: Importing Excel/CVS into Database

2007-08-21 Thread Tim Chase
> Have any of you guys imported excel/cvs by using > Python/Django? I need to import 1000 products for a shopping > site and I'd like to learn the fastest and easiest way to do > so. I do this day in and day out :) I prefer tab-delimited because it's easy and clean, though Python's built-in

Re: Template within a Template?

2007-08-21 Thread Tim Chase
> I want all of my "views" (HTML pages) to use a common header, footer > etc. > > What is the python/django way of achieving this? http://www.djangoproject.com/documentation/templates/#template-inheritance It's somewhat backwards from how other template-languages work that I've used, but it

A "revision-controlled field" type?

2007-08-16 Thread Tim Chase
Has there been any work on a "RevisionControlledField" type? Likely, a standard text-field with some controls for selecting versions or branches thereof, and saving becomes a bit complicated. I'm looking for ideas/suggestions/caveats for such a field (and if such a beast already exists,

Re: How to reuse a component in numerous templates, like turbogears widgets?

2007-08-15 Thread Tim Chase
> I want to define just once how to render any arbitrary lists of > tickets into HTML, and then use that same operation in both places. > > In TurboGears, I would build a custom widget, and then use that inside > my template. I suspect that the Django community has a similiar tool > available,

Re: django hosting companies

2007-08-14 Thread Tim Chase
> Are you using a django friendly hosting company? One other distinction I would make in your data-collection is "Django-capable" versus "Django-friendly". This issue came out on the list earlier. Some providers "support" Django which means "if you can figure out how to make it run, we'll

Re: Access db module

2007-08-14 Thread Tim Chase
> Someone wants to create a browser UI for an access db. can't change the db, > even though A) access can talk to other engines via odbc and B) it will cost > someone else more. > > python does odbc, there is already a MsSql_oledb for django module, so all I > need to do is make one for

Re: 0.96 tarball is corrupt

2007-08-14 Thread Tim Chase
> I've downloaded the tarball several times - each time the archiver > shows it as corrupt (other tarballs work fine). Using Ubuntu Feisty. > (and the Feisty backport package is broken as well). Given the multiple responses that the tarball seems fine (tested on WinXP, OS X, FreeBSD, Ubuntu

Re: Filter on related model problem...

2007-08-13 Thread Tim Chase
> I have a "poem" model that belongs to "user". The "poem" model an > "approved" attribute. I want to print a list of users and display only > their poems that are approved. > > What do I specify in the Queryset to make this work? > > I want to do something like this: > u =

Re: basic testing procedure?

2007-08-13 Thread Tim Chase
> self.assertEquals(list(self.movie.details_genre.all()), "[ Action-Komödie>, ]") > ... > > output: > AssertionError: [, ] ! > = '[, \xc3\xb6die>]' First, it looks like you're comparing a list of objects to a string. I'm not sure if QuerySets override the magic method to determine if they're

Re: Static data on django

2007-08-13 Thread Tim Chase
> I'm quite new to django, but I'm rather confident that I have looked > for it pretty well. Feel free to yell, if I'm asking a stupid > question. We'll, you've at least learned somewhere that Django shouldn't be handling your media...that's at least something :) > I cannot understand how I

Re: urlconf for multiple page slugs

2007-08-10 Thread Tim Chase
> About the only way to do that is just grab (.*) from the url, and > parse it in your view, looking up slugs as needed Collin's suggestion may sound daunting, but it's really quite easy: your urls.py can have something like r"^(?P(?:[-\w]+/)*[-\w]+)/?$" and then in your view: def

Re: basic testing procedure?

2007-08-10 Thread Tim Chase
> if you have an app named "tests" and you add it to your INSTALLED_APPS > (which I guess is necessary) - does django create any tables or any > content (e.g., additional content-types) outside the test-database? I would proffer that unless there's a pressing reason to name your app "tests"

Re: folder security

2007-08-10 Thread Tim Chase
> My problem is that the application requires private folders > for all the logged in users to store their content, and hence > my problem. I know that you can password protect folders > using both apache and litehttpd however their methods don't > seem suitable. I need to dynamically add

Re: basic testing procedure?

2007-08-10 Thread Tim Chase
> 1. where to define the testing? in models.py or in tests.py? I´d like > to seperate the testing from models.py, so how can I write doctests > in a seperate file (the example in the django documentation only > explains seperate unit-testing)? my understanding is that doctests can only be

Re: Using Filter on a list of objects?

2007-08-09 Thread Tim Chase
> NO_COLOR = "---" > styles = Choice.objects.get(id=h.id).style_set.all() > if ('color' in request.POST) and (request.POST['color'] <> NO_COLOR): > styles = styles.filter(color_cat=request['color']) > for u in styles: > dict[u] = u > > > > I did notice that whenever I

Re: Using Filter on a list of objects?

2007-08-08 Thread Tim Chase
> Why do I need to do the following: > > if ('price' in request.POST) and (request.POST['price'] <> > NOT_PICKED): > > instead of > > if request.POST['price'] <> NOT_PICKED: In the event that for some reason that field hasn't been sent along. This could be some other site using you as a web

Re: Using Filter on a list of objects?

2007-08-08 Thread Tim Chase
> Thanks for the reply. Very helpful. In the past I did try the > statement: > > if 'price' in request and request['price'] <> NOT_PICKED: > > > > However when that line was accessed I would get the following error: > > KeyError at /rugs/searchresult/ > '0 not found in either

Re: Using Filter on a list of objects?

2007-08-08 Thread Tim Chase
> If anybody has any suggestions on how to make the code more > optimized would be appreciated. Here is my view: First, a style issue: it's considered bad form to shadow the python built-in "dict" by using a variable with the same name. Second, my eyes are bleeding from the convolution of

Re: multiple user account login

2007-08-07 Thread Tim Chase
>> How do I enable multiple user account login in one computer? >> I don't know what is the disadvantage if this works this >> way, I just need it for development and testing purpose. > > If I understood your question right, you don't have to enable > it. :-) Just create a new user in the

Re: Using Filter on a list of objects?

2007-08-07 Thread Tim Chase
> if request['color'] == "---": # This means no color was > selected > mycolor = ColorCategory.objects.all() > else: > mycolor = request['color'] > ... > i = Choice.objects.get(id=h.id).style_set.filter(color_cat=mycolor) > > > > So, as you can probably

Re: weird django orm behavior

2007-08-07 Thread Tim Chase
> `emplyoee_contract_id`=None,`employee_assignment_id`=10 > > as you can see the last update statement has employee_contract_id = > None ... which I don't know what make it happen? While it was likely just a transcription error, did you mean "emplyoee_contract_id" or "employee_contract_id"...I

Re: Question about {% url %}

2007-08-07 Thread Tim Chase
> r'^order_by_(?P-?(title|attachment|date))/(?P[0-9]+)/', > > regex error While I'm not sure on it, you might try making that a non-capturing group using "(?:...)": r'^order_by_(?P-?(?:title|attachment|date))/(?P[0-9]+)/' which may be less ambiguous to a reverse regexp-parser (which it

Re: DB queries with filter and exclude

2007-08-06 Thread Tim Chase
> Now I want to get all objects, which have set tag "food" *and* *have > not* set tag "cake". > > This get all objects with tag="food" set (obj1..obj5): > >Obj.objects.filter(tags__in=[Tags.objects.filter(name='food')]) > > This get all objects, which haven't set tag "cake" (obj1..obj3,

Re: The Django Book

2007-08-06 Thread Tim Chase
> I hope the community here knows the answer to this question: is this > gorgeous project available at http://www.djangobook.com/en/beta/ not > dead? > > It's very sad to see that it hasn't been updated since January. he's resting. Remarkable book, the Norwegian Django book. 'e's stunned.

Re: Using filter(...) to bring back all records?

2007-08-06 Thread Tim Chase
> I have a form that will contain 3 select input types. The user is > going to have the ability to narrow down the products by selecting a > value in these 3 select boxes (Price, Size, Color). However, the user > also has the ability to not select anything. In this case I would > want to

Re: an application with print on dot matrix printer

2007-08-05 Thread Tim Chase
> what is the nice way to provide a print function on a dot matrix > printer for django apps aside from generating a printer friendly page? My understanding is that there isn't any "nice way...aside from generating a printer friendly page". The web browser can render to a printer context.

OT: Adrian's mug on OSCON site

2007-08-01 Thread Tim Chase
Browsing the lineup of speakers at OSCON, I noticed a familar face in the top banner, front & center: http://conferences.oreillynet.com/pub/w/58/presentations.html How's it feel to be the poster-child for OSCON? ;) -tkc --~--~-~--~~~---~--~~ You received

Re: website template compatible with django

2007-08-01 Thread Tim Chase
> There are professional-looking website templates for sale in several > places (templatemonster, etc). > Can those be used easily with Django ? > Do they need to be designed specifically for Django ? Django's templates are considerably more friendly towards such uses than many templating

Re: Match from list in URLconf

2007-07-30 Thread Tim Chase
> For instance, if you also had categories of users and wanted to be > able to list the users in each category, a 'human-friendly' url > scheme might look like this: > > www.mysite.com/users/matt --> go to my area > www.mysite.com/users/jess --> go to Jess' area > www.mysite.com/users/mark -->

Re: Filter to find closest match

2007-07-30 Thread Tim Chase
> Seems to work now with: > w=240 > pricelisttable_set.extra(where=["""(table_pricelisttable.width - %s) > >= ( SELECT Min(Abs(pl.width - %s)) FROM table_pricelisttable pl) > """], params=[w, w])[0] I would be very surprised if it works now as described with ">=" rather than "=". It's basically

Re: Filter to find closest match

2007-07-29 Thread Tim Chase
> In pure sql we can do : > "select min(abs(width-150)) from quote_pricelisttable where name_id = > 1 and width >= 240-150 and width <=240+150;" > > How to make it work properly from django ORM? Did you try playing with the extra() call I included in my previous email? It should do what you

Re: newforms: common constraints

2007-07-27 Thread Tim Chase
>> but those min max constraints are so common? why not include >> it? > > Because "common" is different for any given user and/or site. > I think *I've* only written a single form with min/max > validation, FWIW. Designing a framework is hard; you've got to > search for things that are as close

Re: porting of an application

2007-07-27 Thread Tim Chase
> I have two different database file, so I can't copy it. I would like > to extract only the data of the app which I would port to other > machine. I'm not sure how you ended up with two database files. However, I suspect Daniel has the right idea: just copy the .db file. If there's stuff in

Re: There's got to be a better way

2007-07-26 Thread Tim Chase
>> events = {} # or SortedDict if order matters >> + new_lists = 0 >> + appended_lists = 0 >> for event in future_events: # one DB hit here >> - region = event.club.region >> + region = str(event.club.region) >> +if region in events: >> + appended_lists += 1 >> +

<    1   2   3   4   5   6   7   >