Re: Database Model Layout Advice

2009-07-14 Thread Jonathan Buchanan
2009/7/14 The Danny Bos : > > Hey there, this may not be appropriate, but I'm building in Django so > here goes ... > > I'm creating an Interviews app/table in my Django 'Books' (test) > project. Just wrapping my head around it before I start on my music > based website ...

Re: Manipulating post data before sending?

2009-07-10 Thread Jonathan Buchanan
> I'm making a small app which is kind of like a blog. I have an Entry > class which has "ForeignKey(User)" as one of its members. I'm using > ModelForm to generate the form and I'm excluding the User ForeignKey > because it will just ask for you to pick a user from a drop-down > list. > > Where

Re: Automatic slugs

2009-07-09 Thread Jonathan Buchanan
2009/7/9 Viktor Semykin : > > Hi everyone. > > I'm trying to generate slugs automatically and disallow user to > interfere with this. I think way to go is something like: > > class Entry(Model): >     title=CharField(max_length=100) >    

Re: How does admin generate HTML for adding objects?

2009-07-03 Thread Jonathan Buchanan
On Fri, Jul 3, 2009 at 6:06 AM, TechnicalBard wrote: > > To clarify, the djangobook states: > > << On the admin site’s edit forms, each field’s label is generated > from its model field name. The algorithm is simple: Django just > replaces underscores with spaces and

Re: Global custom tags

2009-07-02 Thread Jonathan Buchanan
On Thu, Jul 2, 2009 at 10:55 PM, diogobaeder wrote: > > Hi there, > > Is there a way to create a custom tag that can be used in different > applications at the same time, so that I could make the call on the > "base.html" template? The custom tag, here, is a blog subjects

Re: Building a widget from zero

2009-06-17 Thread Jonathan Buchanan
On Tue, Jun 16, 2009 at 4:43 PM, MiratCanBayrak wrote: > > Hi i wrote an application called category. As you guess it an > application to hold categories. Than i wanted to use it on my site. I > wrote a function that builds html code for displaying categories, but > now

Re: passing css classes in forms

2008-11-11 Thread Jonathan Buchanan
Bobby Roberts wrote: > how can I assign form fields to certain css classes in django? django-html [1] can be used to do this quite easily in your templates (and lets you render form fields using HTML4 if you like, yay!). Jonathan. [1] http://code.google.com/p/django-html/

Re: Recommendation system problem

2008-11-09 Thread Jonathan Buchanan
Mr. Z wrote: > I have these models: > > KindOfTea(models.Model): > name = models.CharField(max_length=100, unique=True) > description = models.TextField() > > Person(models.Model): > name = models.CharField(max_length=100, unique=True) > likes = models.ManyToManyField(KindOfTea,

Re: "Mix and match" model form?

2008-11-04 Thread Jonathan Buchanan
On Tue, Nov 4, 2008 at 9:59 AM, Håkan Waara <[EMAIL PROTECTED]> wrote: > > I would love any ideas or feedback around this area, and to hear of > how others in the community do it. > > /Håkan I would just use two Forms. Forms: class EditUserForm(forms.ModelForm): class Meta:

Re: Python package names

2008-11-03 Thread Jonathan Buchanan
On Mon, Nov 3, 2008 at 1:59 PM, Valts Mazurs <[EMAIL PROTECTED]> wrote: > Usually Django applications are specific to Django and are not really usable > outside Django. That's why seeing "tagging" in my site-packages directory > might confuse me as I could think that this package supports some

Re: Accessing SQL result by column name

2008-07-10 Thread Jonathan Buchanan
Michael Burton wrote: > Hi everyone, > > I'd like to use column names rather than positions to access the > results of my Django SQL queries. > > For example, > > > cursor = connection.cursor() > > cursor.execute('select a, b, c from foo') > > rows = cursor.fetchall() > > print

Re: integer form fields

2008-07-08 Thread Jonathan Buchanan
On Tue, Jul 8, 2008 at 4:28 PM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > I need to limit an integerfield form type to 6 digits. I've tried > max_length and max_digits but those don't work. Is there anything > that does that or will I need to do a custom validation? How about

Re: displaying/editing multiple records at once

2008-05-16 Thread Jonathan Buchanan
ken wrote: > One thing I've wanted for a long time is a way to enter and view > financial information for stocks I follow. However, this typically > involves working with a table (in the graphical sense) of data, > wherein each piece of data in the table is modeled as a single SQL > record.

Re: [OT] Django based full fledged forum app

2008-04-11 Thread Jonathan Buchanan
On Thu, Apr 10, 2008 at 6:12 PM, myst3rious <[EMAIL PROTECTED]> wrote: > > Hi, > I am working on a Django project for Intranet. and I took a lots time > in developing apps, just opposite to the Django philosophy of quick > but clean development. That is completely my fault, and overtime in >

Re: ensuring uniqueness in newforms

2008-04-01 Thread Jonathan Buchanan
On Tue, Apr 1, 2008 at 4:00 AM, msoulier <[EMAIL PROTECTED]> wrote: > > If I have a field, for example a CharField named 'name', which must be > unique, what's the best way to ensure uniqueness whether creating a > new entry or editing an existing one? > > By default, the form won't know if

Re: Complicated relations

2008-03-31 Thread Jonathan Buchanan
On Mon, Mar 31, 2008 at 2:31 PM, R. Akerman <[EMAIL PROTECTED]> wrote: > > I'm co-writing a site for a student nation ( > http://en.wikipedia.org/wiki/Nations_at_Swedish_universities ) and > I've run into some issues in the first step of creating the site, > making the models. > > I have a

Re: permalink decorator

2008-03-31 Thread Jonathan Buchanan
On Mon, Mar 31, 2008 at 12:35 PM, Panos Laganakos <[EMAIL PROTECTED]> wrote: > > I've switched my code from: > def get_absolute_url(self): > return '/store/products/%s' % self.slug > > to: > @models.permalink > def get_absolute_url(self): >

Re: Issues with IE7 and {% for %} {% endfor %} tag

2008-02-21 Thread Jonathan Buchanan
On Thu, Feb 21, 2008 at 8:26 AM, merric <[EMAIL PROTECTED]> wrote: > > I have a template that uses {% for i in prize %} {{ i.description }} > {% endfor %} > > This iterates fine in Firefox, but in IE7 it keeps coming up blank. > I can't see any html issues. I am working off my localhost.

Re: Outputting individual fields of a Model form

2008-01-26 Thread Jonathan Buchanan
almostvindiesel wrote: > I have a ModelForm called RecipeForm built from a Recipe model. > > In the template, I'd like to output the individual components of the > form. Writing {{ form.as_table }} successfully renders the entire > form, however, I just want to output individual fields. > > I

Re: Update multiple rows at once and allow direct updates

2008-01-18 Thread Jonathan Buchanan
On Jan 18, 2008 4:03 AM, Wolfram Kriesing <[EMAIL PROTECTED]> wrote: > > What about an extension to the Queryset like this: > > User.objects.filter(username__istartswith="a").update(is_active=True) > > it would trigger something like this: > >UPDATE auth_user SET is_active=1 WHERE username

Re: Is there a HTML table widget for Django?

2007-12-19 Thread Jonathan Buchanan
shabda wrote: > Is there a widget which can generate HTML tables from within django? > > My requirement is that I have a list of ModelObjects. Now I want to > provide a UI where user can select a number of the ModelObjects, and > then press the delte button to delte them or take a action on all

Re: Allowing downloads for only certain users

2007-12-18 Thread Jonathan Buchanan
Ryan K wrote: > What is the best way to serve static media and only letting certain > users (using django.contrib.auth) download that data? > > Thanks, > Ryan Kaskel http://blog.lighttpd.net/articles/2006/07/02/x-sendfile http://tn123.ath.cx/mod_xsendfile/ Jonathan.

Re: Burning question about forums .. and I guess this applies to gmail as well

2007-12-13 Thread Jonathan Buchanan
On Dec 13, 2007 8:59 AM, Roboto <[EMAIL PROTECTED]> wrote: > > How do forums ie PHPBB and gmail know if I've viewed a topic or not? > > I can think of only 2 methods - 1 is session, and the second is > database. However, if I change computers and therefore changing my > session it's still able

Re: Partial Validation in newforms

2007-11-28 Thread Jonathan Buchanan
On Nov 28, 2007 7:44 AM, PlanarPlatypus <[EMAIL PROTECTED]> wrote: > > On Nov 28, 2:10 am, Thejaswi Puthraya <[EMAIL PROTECTED]> > wrote: > > On Nov 27, 8:32 pm, PlanarPlatypus <[EMAIL PROTECTED]> > > wrote: > > > > > Does anyone know of a clean way to do partial validation in djangos > > >

Re: Default value with SLUGFIELD

2007-11-27 Thread Jonathan Buchanan
On Nov 27, 2007 8:56 AM, Miguel Galves <[EMAIL PROTECTED]> wrote: > Hi, > > I've created a slugfield, which should accept 3 values from a list > > STATUS = ( > ('PUBLICADO', "Publicado"), > ('ESPERA', "Aguardando Aprovação"), > ('REJEITADO', "Rejeitado"), >

Re: {% include %} or template_tag?

2007-11-27 Thread Jonathan Buchanan
On Nov 27, 2007 5:42 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi, > > A small question about template godd practices. > I have to display lists of elements in various pages, with each > element formatted as HTML table (with progress bars and other widgets, > without going in too deep

Re: using geneirc views to delete more than one row

2007-11-27 Thread Jonathan Buchanan
On Nov 27, 2007 3:07 AM, Sawan V <[EMAIL PROTECTED]> wrote: > > Hello, > > Is there any way to use the > django.views.generic.create_update.update_object to update all the > rows in a table? > > Example: my model contains a table with 2 columns, role and name. For > a given row, role is

Re: Django Web Hosting Service

2007-11-24 Thread Jonathan Buchanan
Kenneth Gonsalves wrote: > > On 22-Nov-07, at 2:15 AM, Daniel Roseman wrote: > >>> http://www.webfaction.com/ >>> >>> They are amazing and reasonably priced. Their support is great. They >>> have exceeded my expectations many times. >>> >>> Chuck >> Second this recommendation. I am very happy

Re: url tag difficulties

2007-11-10 Thread Jonathan Buchanan
[EMAIL PROTECTED] wrote: >> hello, >> >> I am learning a lot from the B-List blog >> Here is an entry, which could be interesting for >> you:http://www.b-list.org/weblog/2007/nov/06/urlconf/ >> (specially the named URL patterns) > > Thanks Bernd, > > I'd seen that before, and decided I

Re: Checking for duplicate with newforms

2007-11-07 Thread Jonathan Buchanan
[EMAIL PROTECTED] wrote: > > > On Nov 7, 1:53 pm, Jonathan Buchanan <[EMAIL PROTECTED]> > wrote: >> [EMAIL PROTECTED] wrote: >>> Here's what I've done: >>> if request.method == 'POST': >>> submission = request.POST.copy() >&g

Re: Checking for duplicate with newforms

2007-11-07 Thread Jonathan Buchanan
[EMAIL PROTECTED] wrote: > Here's what I've done: > > if request.method == 'POST': > submission = request.POST.copy() > submission['slug'] = slugify(submission['name']) > form = ClubFormClass(submission) > if Club.objects.get(slug=submission['slug']): >

Re: ChoiceField get choices from objects.all(), but isn't updated

2007-11-02 Thread Jonathan Buchanan
On 11/2/07, Simone Cittadini <[EMAIL PROTECTED]> wrote: > I think I'm in need of a for dummy example here ... > > in the view code : > > def list_filters(request): > [...] > else: > form = FormFilters() > form.filter_name.choices = [(f.name, f.name) for f in >

Re: keeping SECRET_KEY secret

2007-11-02 Thread Jonathan Buchanan
On 11/1/07, Carl Karsten <[EMAIL PROTECTED]> wrote: > > So before I go hacking up a patch, any comments ? > > Carl K Don't put your production settings into version control if it's publicly accessible? Personally speaking, if my project's codebase is going to be publicly accessible, I either

Re: prepopulate week number from given date

2007-10-29 Thread Jonathan Buchanan
On 10/29/07, dimitri pater <[EMAIL PROTECTED]> wrote: > > Hi, > > I want to prepopulate a database with the weeknumber (as a separate > filed) from a given date. This is what the models looks like: > class Item(models.model): > day=models.DateField() >

Re: Correctly referencing media files in templates.

2007-10-24 Thread Jonathan Buchanan
On 10/24/07, Leo Shklovskii <[EMAIL PROTECTED]> wrote: > > You also want to look here for a suggestion on how to access > settings.MEDIA_URL: > > http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/ > > I know (at least one of) the ticket(s) for embedding access to

Re: Method calls in templates

2007-10-05 Thread Jonathan Buchanan
Andreas Ahlenstorf wrote: > Hi, > > At the moment, it's to possible to retrieve more data in the > templates using method calls like all() [1]. While this may be fine > in controlled environments, it may pose a risk at services where you > have to deal with user supplied templates (think

Re: Ideas for adding default records

2007-10-01 Thread Jonathan Buchanan
On 10/1/07, Paddy Joy <[EMAIL PROTECTED]> wrote: > > I have a many to one relationship between domain and DNSRecord. When > adding a domain I need to add some default DNSRecords. I do this after > saving the domain using the following code. > > > domain = form.save(commit=True) > > d =

Re: How would I construct this query using Django?

2007-09-25 Thread Jonathan Buchanan
On 9/25/07, Michael <[EMAIL PROTECTED]> wrote: > > Using SQLite I can pull out the data I want using a query along the > line of: > > select * from event where date(event_date) in > ( > select date(event_date) from event > group by 1 order by 1 desc > limit 5 > ); > > Now, the problem is >

Re: admin media

2007-09-24 Thread Jonathan Buchanan
On 9/24/07, Anurag <[EMAIL PROTECTED]> wrote: > > Hi, > Sorry for this repeat post - but i am getting desperate and > seeking some quick kindly help. > > I am unable to get my admin media to be served by Apache. I am runinng > on windows. > > Here is my httpd.conf > > > SetHandler

Re: shemas evolution

2007-09-23 Thread Jonathan Buchanan
Alexandre Forget wrote: > I wonder what people are using *right now* to evolve their data ? > > I'm using this: > > # create a fixture with all data in the current db > python manage.py dumpdata --indent=4 > initial_data.json > > # delete de database > rm db.sqlite > > # edit the model > >

Re: Django alongside other web apps

2007-09-19 Thread Jonathan Buchanan
On 9/19/07, tonybanjo <[EMAIL PROTECTED]> wrote: > > I'm configuring a new server that needs to run a standard website > alongside a Django application. Everything is installed correctly but > browsing to the site goes straight to the Django app, I can't see the > main site at all as it seems

Re: Getting an object's meta value

2007-09-18 Thread Jonathan Buchanan
Rob Slotboom wrote: > For a class method I want to use the value of the > Model>Meta>verbose_name. > Can someone tell me how to get this value? > > Thanks, Rob You almost had it: Model._meta.verbose_name Jonathan. --~--~-~--~~~---~--~~ You received this

Re: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan
On 9/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On Sep 14, 11:29 am, "Jonathan Buchanan" <[EMAIL PROTECTED]> > wrote: > > Pesky kids these days, with your music and your anticipation... > > :-) > > > I agree that what you pro

Re: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan
> Thanks for the response. But to be fair to you I must disclose that I > anticipated that someone would present this as an answer. I would have > added this discussion into the original but it was already a bit > long... :-) Pesky kids these days, with your music and your anticipation... > Now

Re: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan
> However, simply dodging the question doesn't address the original point: > why does Django adhere to such a nannyish philosophy, and how do you > solve the problem I presented *within Django* in a reasonable way? > > Thanks and regards, > -scott anderson Template tags really are the best place

Re: GET and POST in a template

2007-09-05 Thread Jonathan Buchanan
On 9/5/07, Rufman <[EMAIL PROTECTED]> wrote: > > hey > > how can i read the get or post dictionary in a template. i tried > reading it like a session (request.session.) but this doesn't > seem to work. I need to get the value of the parameter to be able to > define what the users sees in the

Re: how to select posts in this situation?

2007-09-03 Thread Jonathan Buchanan
On 9/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > there are many users and submit many posts, user1, user2,user3 etc. > are my friends, now i want to select all posts which submitted by my > friends? > can somebody gelp me, thx! Try this: Post.objects.filter(user__in=[user1,

Re: markdown issue

2007-09-02 Thread Jonathan Buchanan
[EMAIL PROTECTED] wrote: > i use markdown for beautify content, but i found if enter once, there > will be no new line. > i need to enter twice to get a new line (as ) > > how can i get a new line when enter once, you know our user do not > know they need to enter twice. "When you do want to

Re: Django-based forum software?

2007-08-31 Thread Jonathan Buchanan
Aaron Maxwell wrote: > Hi, > > Does anyone know of a django forum app? I.e., to build a site providing a > user forum. > > This is kind of hard to search on - try googling for "django forum"... > I've been hacking on a forum app [1] (because the world really needs another one) over the

Re: subfolder for 'Views'

2007-08-22 Thread Jonathan Buchanan
> polls/ > __init__.py > models.py > views.py > views/ > main.py > main2.py You need an __init__.py in your views directory as well - Python won't recognise a directory as being a module without it. Jonathan.

Re: How to link SVN Django to Python? (for easy update)

2007-08-22 Thread Jonathan Buchanan
On 8/22/07, b3n <[EMAIL PROTECTED]> wrote: > > I did search but didn't find anything. Probably because the answer is > too obvious... > > I checked out django using SVN but how do I do the next bit? > > "Symlink django_src/django so that django is within your Python site- > packages directory, or

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

2007-08-15 Thread Jonathan Buchanan
On 8/15/07, Matt Wilson <[EMAIL PROTECTED]> wrote: > > I'm working on a django view for my office's homemade ticket-based > workflow system. > > I have a view that shows all tickets assigned to each employee. > > I also have a view that shows all tickets attached to parent tickets. > > I want to

Re: Newforms file upload

2007-08-15 Thread Jonathan Buchanan
On 8/15/07, Brian Morton <[EMAIL PROTECTED]> wrote: > > As I understand it, ticket 3297 is closed as resolved. However, I am > still experiencing problems uploading files in newforms as of the > latest svn checkout. Am I incorrect in my assumption that this has > been fixed? Or am I

Re: DRY? I have a field lists to manage in 4 places

2007-08-14 Thread Jonathan Buchanan
On 8/14/07, Pigletto <[EMAIL PROTECTED]> wrote: > > > Out of interest, where do you find newforms to be inflexible? Are you > > referring to the form_for_* convenience functions or the bulk of > > newforms itself? > I also found some 'inflexible' places. > > I had a lot of work with form_for_*

Re: DRY? I have a field lists to manage in 4 places

2007-08-14 Thread Jonathan Buchanan
On 8/14/07, eXt <[EMAIL PROTECTED]> wrote: > > On 14 Sie, 03:47, "Russell Keith-Magee" <[EMAIL PROTECTED]> > wrote: > (...) > > What you have described is three different pieces of information that > > are similar in the trivial case, and one that you don't need to > > manage. > > > > - fields in

Re: get object qs with certain generic relation

2007-08-03 Thread Jonathan Buchanan
> '%s.%s = %s.object_id' % > (backend.quote_name(Model._meta.db_table), > > backend.quote_name(Model._meta.pk.column), > rel_table) Aargh, mangled by Gmail - these lines should look like this (with the proper level of indentation

Re: get object qs with certain generic relation

2007-08-03 Thread Jonathan Buchanan
> I have a generic relation Flag, with a FlagType: > > class FlagType(models.Model): > name = models.CharField(maxlength=50) > description = models.TextField() > > class Flag(models.Model): > type = models.ForeignKey(FlagType) # type of flag > content_type =

Re: age in years calculation

2007-08-03 Thread Jonathan Buchanan
On 8/3/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > > Hey Everyone, > > > does anyone have a good age in years calculation function for usage with > datetime.date that returns the age in nr of years of a person? > > We were using: > > def get_age(self): > now = datetime.today() >

Re: Newforms w/ *dynamic* ChoiceField choices?

2007-08-03 Thread Jonathan Buchanan
> Newforms has a spiffy way to dynamically set the "initial" values of > fields, in the view code when the Form is constructed. > choosecolorform = ChooseColorForm(initial={'color': 'black'}) > > I was hoping it would be just as easy to dynamically define the > choices available in a

Re: "News" application?

2007-07-31 Thread Jonathan Buchanan
> I have an application named "news". Running python manage.py sqlall news > I just discovered that django would create a table I did not define in > my models.py - "news_news" (no, there's no M2M fields there). What's > that? Why? I even don't have a model for this data. Do you have a Model

Re: filter by if object exists

2007-07-27 Thread Jonathan Buchanan
> I just know this is a dumb question, and I've seen this done > somewhere, but what I'm after is something like > > GpUser.objects.filter('image'=True) > > To only get the Gpuser objects that actually have an image, rather > than all of them. Can someone point me in the right direction?

Re: Forms for complex model hierarchies

2007-07-26 Thread Jonathan Buchanan
On 7/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi group, > > I have a rather complex hierarchy of models. Say, I have a model A. A > has a 1:N relation to model B, which itself has a 1:N relation to > model C. > > What I want is a single web page, on which an instance of A and all >

Re: How to make use of the hooks in newforms-admin?

2007-07-23 Thread Jonathan Buchanan
AndyB wrote: > Page 18 and 19 of this PDF: > http://www.vanpyz.org/Djangojam/django_vancouver.pdf > > give examples of some of the new hooks available in newforms-admin. > This is the only documentation I can find anywhere for this at the > moment. > > The examples involve declaring a class

Re: Menu implementation

2007-07-18 Thread Jonathan Buchanan
On 7/18/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote: > Have anybody implemented a tree with django, for example, a menu? > > -- > Lic. José M. Rodriguez Bacallao > Cupet I've implemented a tree of comments in django-discussion:

Re: Logging in a newly created user

2007-07-18 Thread Jonathan Buchanan
LaundroMat wrote: > Hi, > > When running this, I get a "NoneType has no attribute > is_authenticated()" error, and I cannot understand why: > > 1 new_user = User.objects.create_user(username, "your.email", > password) > 2 new_user.is_active = False > 3 new_user.save() > 4 user =

Re: form processing

2007-07-13 Thread Jonathan Buchanan
> I have a form on one of my pages that has two fields with the same > name. When I process the POST in my view I only get one of the values > ( the last one ). > > EXAMPLE: > HTML > > > > DEBUG > POST: > > VIEW > request.POST['version'] > > the above line is = 35 if both checkboxes are checked

Re: get_FOO_url() returns empty string

2007-07-12 Thread Jonathan Buchanan
wolfds wrote: > I ran into a problem which I tried to solve for several hours now. The > situation is simple and straightforward: > > models.py: > > class Foo(models.Model) > img = model.ImageField(upload_to='pix') > > settings.py: > > MEDIA_ROOT = '/home/wolf/appl/media/' > MEDIA_URL =

Re: syncdb building freaky database

2007-07-12 Thread Jonathan Buchanan
> 1. All fields have 'NOT NULL' and are required - this does not reflect > my model If you want a field to be nullable, use null=True - the default is False. [1] If you want a field to not be required in the admin application, use blank=True - the default is False. [2] > 2. I get strange

Re: Question about AddManipulator/ChangeManipulator

2007-07-09 Thread Jonathan Buchanan
> It would be good if the a Django core developer could confirm its > removal in 1.0 though. There are quite a lot of methods calling > AddManipulator for slightly different purposes and rewriting them. "django.newforms is new in Django's 0.96 release, but, as it won't be new forever, we plan

Query-light retrieval of generic relations

2007-06-04 Thread Jonathan Buchanan
Hi all, I'm trying to write a utility method to retrieve generically related content (the particular model I'm using has the standard ContentType FK, object id and GenericFK) without ending up with one database hit per object: http://dpaste.com/11633/ from

Re: Returning a list of entries associated with a tag (using django-tagging)

2007-05-30 Thread Jonathan Buchanan
On May 25, 5:56 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm trying to write a view to return a list of blog entries associated > with a specific tag (using the django-tagging app). You can do the following to get a BlogEntry QuerySet for the appropriate entries:

Re: relation-spanning lookups with generic relations?

2007-05-28 Thread Jonathan Buchanan
On 5/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > > Hi there, > > > > Say I have: > > class TaggedItem(models.Model): > """A tag on an item.""" > tag = models.SlugField() > content_type = models.ForeignKey(ContentType) > object_id = models.PositiveIntegerField()

Re: Bug in django related to sqlite3?

2007-05-14 Thread Jonathan Buchanan
> Indeed I have to use the query/cursor mode. The query is a way more > complex than that and I need some ordering based on calculated fields > (which is not supported at the moment from the QuerySet api). I > simplified the query simply to isolate the problem. > some_id is indeed a foreign key

Re: Restructured text parsing not showing h1 levels.

2007-04-02 Thread Jonathan Buchanan
Michael Lake wrote: > Hi all > > I have a problem I think when I use the markup package. This provides > markdown, > textile and restructuredtext markups. I have the following in views.py: > > def testwiki: > > content = ''' > Restructured Text Test > == > > How de

Re: Count foreignkey(self)

2007-03-17 Thread Jonathan Buchanan
[EMAIL PROTECTED] wrote: > If I have a model with something like > > class A (models.model): > parent = meta.ForeignKey('self', blank=True, null=True, > related_name='child') > > Is it possible to do a select for some results in A along with a count > of all their children? > > -Dougal

Re: Allowing no value for a DateField

2007-03-12 Thread Jonathan Buchanan
On 3/12/07, Roland Hedberg <[EMAIL PROTECTED]> wrote: > > Hi! > > I have designed a model which contains among other things a couple of > DateFields. > > Some, actually one, of these must have a value but the other may not. > > So, I tried to use the construct: > > done_planned =

Re: customizing how the slug fields are populated

2007-01-29 Thread Jonathan Buchanan
On 1/29/07, omat * gezgin.com <[EMAIL PROTECTED]> wrote: > > About a year ago, there had been a discussion on a similar topic: > http://groups.google.com/group/django-users/browse_thread/thread/ > 006108ff1b23c36c > > But most of the important points were left unanswered. The topic is > expired,

Re: doing calculations

2007-01-23 Thread Jonathan Buchanan
On 1/23/07, Ramdas S <[EMAIL PROTECTED]> wrote: > I am simplyfying a rather complex model I have here, so that some one can > give me the right advice. > > I have a class called Bill > > class Bill(models.Model): > no_of_units = models.IntegerField() > price=

Re: Is there an easy to "humanize" a list?

2006-12-20 Thread Jonathan Buchanan
On 12/20/06, Austin Govella <[EMAIL PROTECTED]> wrote: I have a list from a queryset: * foo * bar * twinky Is there an easy way to output that as: "foo, bar, and twinky" (There are handy functions for this in PHP, ColdFusion, and Rails, but my Google-fu fails for Python or Django.)

Re: generic and message

2006-12-11 Thread Jonathan Buchanan
On 12/11/06, sedat <[EMAIL PROTECTED]> wrote: > > Hi, > I am trying to show a message as a result of create,update or deletion > of an object by generic. > How can I do that? I mean As far as I know I can give a > post_save_redirect url but I want to show a message also like 'Object X > saved

Re: Filtering on the existance of a "reverse" foreign key relationsship

2006-10-25 Thread Jonathan Buchanan
On 10/25/06, Christian Joergensen <[EMAIL PROTECTED]> wrote: > Daniel Roseman wrote: > >>> Country.objects.all().extra( > >>> where=['(SELECT COUNT(*) FROM appname_soccerteam WHERE > >>> appname_soccerteam.country_id = appname_country.id) > 0'] > >>> ) > >> Great idea! I did not think about

Re: Alternate colors - when returing a list.

2006-10-19 Thread Jonathan Buchanan
On 10/19/06, MerMer <[EMAIL PROTECTED]> wrote: > > Does anybody know of a filter/tag that will return a table list with > rows of an alternate color. > I have a hazy recollection that I've seen this somewhere - but I've > relooked through the documentation and can't seem to find it. > > MerMer

Re: Returning an average from a Related Field.

2006-10-16 Thread Jonathan Buchanan
> Jonathan, > > Many thanks for this. > > Sorry to be a pain , but I have a couple of follow on questions, so I'm > clear. > > 1. How should I best implement this code. As a custom tag or in the > view? > > 2. Any suggestions on how I should pass the product.id to the code? > > Thanks > > MerMer

Re: Returning an average from a Related Field.

2006-10-16 Thread Jonathan Buchanan
On 10/15/06, MerMer <[EMAIL PROTECTED]> wrote: > > I have two Models. > > 1. Product > 2. Review - There can be many reviews for any product (one -to many > relationship) > > One of the fields of Review is "Rating". This holds an integer between > 1 and 5. > > I want to display a list of

Re: Dynamic Menus...

2006-08-25 Thread Jonathan Buchanan
> And (obviously?) dont rely on the correct make and model coming back > from your form. You'll eventually get someone constructing their own > POST data for a laugh and seeing what happens if they had selected > Renault Impala... :) Here's example source for an implementation of just that in

Re: compare integers in template (newbie question)

2006-08-15 Thread Jonathan Buchanan
> Folks, > > I'd really love to be able to do something like this: > {% if videoObject.rating > 0 %}*{% endif %} > {% if videoObject.rating > 1 %}*{% endif %} > {% if videoObject.rating > 2 %}*{% endif %} > > To display an appropriate number of stars for a video clip in a > template. > > Right

Re: List all categories, list all objects within these categories

2006-08-05 Thread Jonathan Buchanan
[EMAIL PROTECTED] wrote: > Hi, > > Using the models below, I want a single page to show: > > bookcategory1 > book1 > book2 > bookcategory2 > book1 > book2 > ... > bookcategory3 > ... > ... > ... > > ## > > # Models > >

Re: Getting the Django Admin Working in Apache

2006-07-07 Thread Jonathan Buchanan
> If I do this.. the whole administration interface will work straight > away? Or will it need additional configuration? I was assuming you'd already configured mod_python and the admin app just couldn't find its media files - if that's not the case, have a look at

Re: Getting the Django Admin Working in Apache

2006-07-07 Thread Jonathan Buchanan
Assuming "/media/" as the media URL, what I do locally is create a "media" folder under Apache's htdocs folder and use the Junction tool described in the first comment on http://www.djangoproject.com/documentation/install/ to symlink admin and application media in there, like so: junction

Re: Cant open static files on IE

2006-05-12 Thread Jonathan Buchanan
On 5/11/06, Gacha <[EMAIL PROTECTED]> wrote: > > I'm using django with mod_python. When someone using internet explorer > is trying to download some file and in the promt box he chose "Open" > then the file is downloaded, but IE says that the file doesn't exists, > but if chose to "Save" the file