Re: Problem on 'if' on templates

2012-07-25 Thread Micky Hulse
On Jul 25, 2012, at 3:11 PM, fnando wrote: > Hello, beginner here. I'm getting an error at the IF statement, line 2 of > this snippet: Could it be that you're using object as the loop variable, and object is also the global var? I might change it to: for item in

Re: render a models slug field as a url

2012-07-25 Thread Matthew Meyer
HI daniel, thanks for the reply After your comments, I have used ModelForm to simplify my code. I have also achieved redirecting the desired url by using the redirect() function. My issues are still basically the same however: - I do not know how to tell Django to render a template at the

Models: Referencing A Model In Another App and Different Project

2012-07-25 Thread JJ Zolper
Hello fellow Django developers, So here is my model that interfaces with my Artists database: from django.db import models class Artist(models.Model):       name = models.CharField(max_length=30)       genre = models.CharField(max_length=30)        city = models.CharField(max_length=30)       

Re: Variable # of fields in a form

2012-07-25 Thread Doug Ballance
It seems to me that two fields might be the simple solution? class SomeForm(Form): internal = forms.ModelMultipleChoiceField( , widget=forms.CheckboxSelectMultiple) externa = forms.ModelMultipleChoiceField( , widget=forms.CheckboxSelectMultiple) Then

Problem on 'if' on templates

2012-07-25 Thread fnando
Hello, beginner here. I'm getting an error at the IF statement, line 2 of this snippet: {% for object in object.list|slice:":5" %} {% if object.person == "String" and forloop.counter0 == 5 %} {% else %} {{ object.paper }}

'QuerySet' object has no attribute '_meta' ... but I'm not using a QuerySet!

2012-07-25 Thread Deathweasel
Hello, guys. This is Django 1.4. I have this code from my view: my_art = ArtworkModel.objects.get(id=pk) comments = CommentModel.objects.filter(artwork=pk) artForm = ArtworkForm(instance=my_art) ... These models: class ArtworkModel(models.Model): """ This class contains the

error to use cursor to save escaped characters

2012-07-25 Thread fanchyna
I have a url which I want to save into the MySQL database using the "cursor" tool offered by django, but I keep getting the "not enough arguments for format string" error because this url contains some escaped characters (non-ascii characters). The testing code is fairly short: #test.py# >

Re: Return SQL calculation within queryset

2012-07-25 Thread Andre Terra
Please read the following bits of documentation: https://docs.djangoproject.com/en/dev/topics/db/sql/#performing-raw-sql-queries https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.extra Cheers, AT On Tue, Jul 24, 2012 at 9:03 PM, jondbaker

Prevent direct access to some URLs

2012-07-25 Thread Blaxton
Hi I have set up a login page, using "django.contrib.auth.views.login" and user's would be forwarded to  their own web page after being authenticated, but they can access to their web page directly with placing the related uri.  how can I prevent direct access to those page ? Thanks -- You

Re: Overriding save to create and save related entity

2012-07-25 Thread Mattias Linnap
It is possible to override the save() method in a model to add functionality: https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methods Another choice would be to register a receiver for the pre_save or post_save signals:

Re: Overriding save to create and save related entity

2012-07-25 Thread Nicolas Emiliani
On Wed, Jul 25, 2012 at 12:34 PM, Sithembewena Lloyd Dube wrote: > Hi all, > > I have the following code: > > class Points(models.Model): > blah blah > > class TrainingSession(models.Model): > confirmed = models.BooleanField() > points =

Overriding save to create and save related entity

2012-07-25 Thread Sithembewena Lloyd Dube
Hi all, I have the following code: class Points(models.Model): blah blah class TrainingSession(models.Model): confirmed = models.BooleanField() points = models.ForeignKey(Points, null=True, blank=True) When a training session is saved, if confirmed is True I wish to create and

Re: get_absolute_url returning empty string

2012-07-25 Thread Victor Rocha
your get absolute url method is in the wrong format:: if should be. @models.permalink def get_absolute_url(self): return ("view_name", #view name, (), #tuble of positional args {}, #dict of name kwargs ) In your case, this is what the method should look like:

Re: get_absolute_url returning empty string

2012-07-25 Thread Victor Rocha
Your get_absolute_url method is in the wrong format::: it should be: @models.permalink def get_absolute_url(self): return ("view_name", #view name ) On Tuesday, July 24, 2012 1:58:26 PM UTC-4, Jeff Green wrote: > > I am stuck in trying to figure out why the get_absolute_url call

Re: All of the sudden getting TemplateDoesNotExist error

2012-07-25 Thread rmschne
Karen, All sorted now. Thanks! Well (tail between legs), the problem was not the template that was being called, but a template being "included" inside that template. That second template is loaded based on a few "if" statements, and a bug/flaw in my logic (undetected until now ... code in

Re: Query Distances from User

2012-07-25 Thread JJ Zolper
I agree I can have the user input city and state and do a lat lon as a basic search and let the user put in their home address or pan on a map for an advanced search. However given the large amounts of data Im striving for pure speed and efficiency. By possibly deciding againist geolocation and

Testing against a multi-db app with un-managed models [django 1.2.3]

2012-07-25 Thread kit.ran...@otago.ac.nz
Hi there, I would like to test a django 1.2.3 application that uses both a sqlite db for auth/users, and an *unmanaged* postgres database for the application itself. Given that the models are unmanaged, and the postgres database has a very involved, long running set of scripts to build, the

Re: Variable # of fields in a form

2012-07-25 Thread Daniel Roseman
On Wednesday, 25 July 2012 08:02:14 UTC+1, Alex Strickland wrote: > > On 2012/07/23 03:08 PM, Alex Strickland wrote: > > > https://docs.djangoproject.com/en/dev/topics/forms/formsets/ ? > > No. > > This is my html that shows a nice looking control using bootstrap, with > lists of users broken

Re: render a models slug field as a url

2012-07-25 Thread Daniel Roseman
On Wednesday, 25 July 2012 02:42:45 UTC+1, Matthew Meyer wrote: > > Hello all, > > I'm trying to load the url of a model created with get_absolute_url() > programmatically in my view. There are basically three steps I need to > accomplish this: > > 1. make sure @permalink is working correctly.

Re: Variable # of fields in a form

2012-07-25 Thread Alex Strickland
On 2012/07/23 03:08 PM, Alex Strickland wrote: https://docs.djangoproject.com/en/dev/topics/forms/formsets/ ? No. This is my html that shows a nice looking control using bootstrap, with lists of users broken up into their groups: {% for group in group_list %}

It's that possible to modify context views from middleware?

2012-07-25 Thread yodi aditya
Hi, Is that posible to make context manipulation (in every views) before send to templates from middleware? I use Django 1.3 at this case. Eg: views.py def view_function: return render(request, templates, data) def other_function: return render(request, templates, data) Middleware