Re: Best way to build a search form

2009-07-26 Thread Erik Vorhes
On Sun, Jul 26, 2009 at 3:55 PM, Rams3377 wrote: > > > In Django 1.0.2, what is the best way to perform a user submitted > search? For instance if someone wanted to search through a profile > which has several parameters that the user may or may not fill out. > What is the

Re: Make three columns without violating DRY

2009-07-09 Thread Erik Vorhes
On Thu, Jul 9, 2009 at 4:49 PM, Wiiboy wrote: > > The columns are actually categories.  The left column is sports, etc. > So I can't make it a grid like that. > If each column is a discrete category, why not just filter the object/model by category for each column? You're

Re: model subclasses

2009-06-26 Thread Erik Vorhes
Why not do this: class Polygon(models.Model): sides = models.IntegerField() side_length = models.IntegerField() def perimeter(self): return sides * side_length (Forgive the syntax. I'm a bit rusty.) This doesn't help with irregular polygons, but with your example, it

Re: Empty [] using objects.all() on legacy database

2009-06-22 Thread Erik Vorhes
first % escapes the second % sign, and thus allows for the actual symbol to display. This is because Python uses % to include variables, etc., into a string. So it's not a bug at all. Erik Vorhes --~--~-~--~~~---~--~~ You received this message because you are subscribe

Re: order by the count of backward related fields?

2008-04-25 Thread Erik Vorhes
Or check out James Bennett's comment_utils: http://code.google.com/p/django-comment-utils/ It has what you need. On Fri, Apr 25, 2008 at 9:52 PM, realfun <[EMAIL PROTECTED]> wrote: > I am writing a simple Django App, the model is like this: > class MyPosts(models.Model): > > content =

Re: Django and CSS

2008-04-24 Thread Erik Vorhes
Put your CSS files in your media directory. If your media url is "http://yoursite/media/;, then you could do something like and you should see your intended style. On Thu, Apr 24, 2008 at 10:01 PM, gmacgregor <[EMAIL PROTECTED]> wrote: > > > On Apr 24, 10:49 pm, Rodney Topor <[EMAIL

Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.

2008-04-23 Thread Erik Vorhes
There's nothing wrong with parceling out models across different apps. And unless you're planning on distributing each app separately, don't worry about cross-app dependencies. In this case, I'd encourage you to--since you'll probably want to do more than just book-related stuff with your

Re: how do designers create content

2008-04-22 Thread Erik Vorhes
I'm (currently) a low-budget developer, so I'll do mock-ups on graph paper, edit images in Acorn, and then hand code in BBEdit (which I got a great deal on, before TextMate was as robust & awesome as it is now). A good solution for the cost-conscious, aside from TextMate, is Coda. (If you're

Re: How to get ':' in address?

2008-04-22 Thread Erik Vorhes
This is more mundane, but ':' is called a colon. On Tue, Apr 22, 2008 at 5:17 AM, Manuel Meyer <[EMAIL PROTECTED]> wrote: > > Hey, > > I wonder how to get a ':' (btw: what's its name in english?) in my > url, so it is shown as : in the address and not as %3A . > > Like wikipedia does: >

Re: Looping....

2008-04-18 Thread Erik Vorhes
Or you can add something to your view to take care of this: def your_view(request): ... some_subset = Model.objects.all()[:10] ... Add it to 'extra_context' and you won't need to do anything trickier than this: {% for model in some_subset %} some stuff {% endfor %} On Fri,

Re: One app installed several times

2008-04-15 Thread Erik Vorhes
Also, there are things happening that will make this possible without hacking at Django directly: http://www.jacobian.org/writing/2008/mar/19/pycon/ (near the bottom of the article) Here's what will (probably) be able to happen: INSTALLED_APPS = ( "some.app", app("some.app",

Re: Images

2008-04-15 Thread Erik Vorhes
In production environments, you need to use something like Apache or Lighttpd (sp?) to serve media--it's not something you should be doing directly through Django. Check the URL for your image and compare it to MEDIA_URL in your settings.py file (plus anything you're adding through

Re: Exception in template

2008-04-12 Thread Erik Vorhes
> {% for a in list %} > a.foo a.bar > {% endfor %} If you really need something to happen other than an empty string, you can always use the "if" tag: {% for a in list %} {% if a.foo %}{{ a.foo }}{% else %}Whatever exception text you want{% endif %} {{ a.bar }} {% endfor %}

Re: I'd like to learn more about Django internals

2008-04-12 Thread Erik Vorhes
You might be thinking of this flowchart: http://www.djangobook.com/en/1.0/chapter03/#cn60 Erik On Sat, Apr 12, 2008 at 7:00 AM, Tim Chase <[EMAIL PROTECTED]> wrote: > > > As the subject says, I'd love to learn more about how django > > works internally. > > One of the best pages I've found

Re: tutorial question

2008-04-11 Thread Erik Vorhes
Using a database doesn't by default make your site searchable. It's a more efficient storage system (usually) than having a bunch of static files. SQLite is an easy way to develop, especially if you're running Python 2.5, but I usually move to a PostgreSQL backend for "production" sites, since

Re: Catch-all route?

2008-04-11 Thread Erik Vorhes
Check out the documentation on URL configuration, if you need something more customized than the default 404.html template. (You don't need to write a special regex for 404 situations, but you could just use, as the *absolute last* pattern something like r'^.*$' (I think). For the most part,

Re: Allowing html tags for filter.

2008-04-11 Thread Erik Vorhes
> I have a custom filter that outputs some html code. The problem is > that it converts all "greater than" and "less than" symbols to > appropriate and symbols. How is it possible to say to > filter not to do this? You're running into the autoescape tag, which is on by default in

Re: Application Concepts

2008-04-11 Thread Erik Vorhes
It doesn't necessarily hurt to have apps inside the project folder, but it does make it harder to extract and reuse them. If I remember correctly, you don't need much, aside from settings.py, urls.py, and __init__.py. On Fri, Apr 11, 2008 at 1:09 PM, andy baxter <[EMAIL PROTECTED]> wrote: > >

Re: Custom ID field with random string

2008-04-06 Thread Erik Vorhes
I'm not sure how this is more transparent. Don't you mean *less* transparent for your user? Instead of a simple number (or more usable user-defined slug), you're giving them a random string, which will be almost impossible to remember and contains no discernibly useful information. If you

Re: 'module' object has no attribute 'day_abbr' --Problem editing using Admin

2008-04-01 Thread Erik Vorhes
That's because the table storing your information doesn't have an "EventDate" field, and it can't be ordered by something that doesn't exist. You'll need to update the table before it will work correctly. On Mon, Mar 31, 2008 at 1:25 AM, Ryan Vanasse <[EMAIL PROTECTED]> wrote: > > I just

Re: extra arguments in generic views

2008-03-28 Thread Erik Vorhes
end of each. That's the discussion I wanted to have. I know I > can get around this, but sometimes I am stubborn especially when I > don't really see a downside to the generic objects receiving extra > arguments. > > Maybe I am just being difficult. > > > > On Thu, Mar 27

Re: extra arguments in generic views

2008-03-27 Thread Erik Vorhes
This should help: http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/ Say you've got this in "yourproj.yourapp.views" (assuming there's a ForeignKey on Thing2): from django.views.generic import date_based from yourproj.yourapp.models import Thing1 from

Re: tutorial __str__() method not working

2008-03-26 Thread Erik Vorhes
It looks like the issue is one of indentation. There's nothing for "self" to refer to if the method isn't part of the class. --And you're probably better off using __unicode__ than __str__ Try: class Poll(models.Model): question = models.CharField(max_length=200) pub_date =

contextual ForeignKey?

2007-04-25 Thread Erik Vorhes
In my app I have a model, "Review," that uses a different (ForeignKey) citation form depending on the type of thing I'm reviewing. I'd like to be able to call a different ForeignKey dynamically based on the citation type but keep running into a bunch of errors. Here's my current "Review" model