Re: Form not taking my input...

2010-09-14 Thread keynesiandreamer
Hey Daniel
I was able to get my form working yay! Not sure the defaults was what
I was looking for but you got me looking in the right direction.

Thanks very much.

-Ben

On Sep 13, 2:41 pm, Daniel Roseman  wrote:
> On Sep 13, 9:32 pm, keynesiandreamer  wrote:
>
>
>
> > Hi Daniel, thanks for looking at this!
>
> > Here is my views.py code related to this:
>
> > @login_required
> > def wine_add_page(request):
> >   if request.method == 'POST':
> >     form = WineAddForm(request.POST)
> >     if form.is_valid():
> >       #create or get dummy wine
> >       wine, dummy = Wine.objects.get_or_create(
> >         wine_name=form.cleaned_data['wine_name']
> >       )
>
> >       #update wine_name
> >       winerater.wine_name = form.cleaned_data['title']
> >       #if the bookmark is being updated, clear old tag list
> >       if not created:
> >         winerater.tag_set.clear()
> >       #create new tage list
> >       tag_names = form.cleaned_data['tags'].split()
> >       for tag_name in tag_names:
> >         tag, dummy = Tag.objects.get_or_create(name=tag_name)
> >         wnerater.tag_set.add(tag)
> >         #save wine to DB
> >       winerater.save()
> >       return HttpResponseRedirect(
> >         '/user/%s/' % request.user.username
> >       )
> >   else:
> >     form = WineAddForm()
> >   variables = RequestContext(request, {
> >     'form': form
> >   })
> >   return render_to_response('wine_add.html', variables)
>
> > HTH
>
> > -Ben
>
> The immediate issue here is that your `get_or_create()` call only
> passes a value for `wine_name` - if the wine doesn't exist, Django
> will try and create it, but doesn't have any of the other fields,
> hence the integrity error. You need to use the `defaults` argument to
> provide the rest of the data. See the 
> documentation:http://docs.djangoproject.com/en/1.2/ref/models/querysets/#get-or-cre...
>
> There are a few other issues with this code, which you'll discover
> once you've fixed that - eg you start off calling the new Wine object
> `wine`, then swap to `winerater`, which will lead to an error.
> Similarly you've used `dummy` as the second result from
> `get_or_create` but then later refer to `created`.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is it possible for template to use context variable as list index?

2010-09-14 Thread bruno desthuilliers
On 13 sep, 18:20, "David.D"  wrote:
> In my template:
>
> This is ok:
> {{ my_list.2 }}
>
> But it doesn't work:
> {{ my_list.index }}
>
> index is a context variable (index=2)

This first looks up my_list for an attribute named "index" - which
resolves to the "index" method of the list class if my_list is really
a list - then try to do a dict lookup (ie: my_list["index"]). So
technically speaking, it does "work" - in that does what the fine
manual says it should do !-)

Now, what's your use case exactly ? You don't need indexed access to
iterate over a sequence, and if you know both my_list and index in
your view (or templatetag or whatever), then you can just pass the
appropriate value in your context from the view code itself.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Not calling clean() properly

2010-09-14 Thread Daniel Roseman
On Sep 13, 10:50 pm, Christos Jonathan Hayward
 wrote:
> Other attempts to write a clean that would run a print statement and then
> call to_python(), validate(), and run_validators() did not result in that
> print statement being called.
>
> Am I missing something about data being cleaned? The hooks I've tried to
> override don't seem to be being called.
>

You don't say what is supposed to be calling clean. Are you using a
form? If not, read this:
http://docs.djangoproject.com/en/1.2/ref/validators/#how-validators-are-run
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django tinyMCE is normal text field instead of rich text formatting? a fix please.

2010-09-14 Thread bagheera
Dnia 13-09-2010 o 18:57:35 tricks...@googlemail.com   
napisał(a):



I installed Django tiny mce however i am getting a normal text area in
my admin. Can anyone help me to correct this to a rich text area where
i can access text formatting?


I just downloaded newest tinyMCE and placed it in 'js' directory, then i  
made proper cfg


in modelAdmin:


class Media:
js = ('js/tiny_mce/tiny_mce.js', 'js/tiny_mce/tiny_mce_config.js',)

and the config in tiny_mce_config.js file:


tinyMCE.init({
mode : "textareas",
width : "800",
height : "500",
theme : "advanced",
language : 'pl',
content_css : "../../css/style.css",
theme_advanced_toolbar_location : "top",
plugins : 'preview, searchreplace, paste, table, insertdatetime, media',
theme_advanced_buttons1 :  
'preview,undo,redo,visualaid,|,cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,anchor,image,cleanup,help,code',
theme_advanced_buttons2 :  
'bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect',
theme_advanced_buttons3 :  
'forecolor,backcolor,|,sub,sup,|,charmap,insertdate,inserttime,media,|,tablecontrols'

});

and it works fine in admin panel

--
Linux user

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Bug with distinct + aggregate ?

2010-09-14 Thread donato.gr
I managed in this way:
>>> subquery = Father.objects.filter(sons__in=[adam, bernard])
>>> Father.objects.filter(pk__in=subquery).aggregate(Sum('age'))

this gives the correct result.

Is there a better way to do so? (maybe more efficient?)


Thanks


On 13 Set, 17:51, "donato.gr"  wrote:
> Hi,
> when using 'aggregate(Sum(...))' on a queryset that is also using
> 'distinct()', 'DISTINCT' is misplaced in resulting SQL query...
>
> Here is a silly sample code:
>
> I have the following classes:
> class Son(models.Model):
>         name = models.CharField(max_length=20)
>
>         def __unicode__(self):
>                 return self.name
>
> class Father(models.Model):
>         name = models.CharField(max_length=20)
>         age = models.IntegerField()
>         sons = models.ManyToManyField(Son)
>
>         def __unicode__(self):
>                 return '%s - %s' %(self.name, self.age)
>
> I want to compute the total age of fathers who have a son called Adam
> or Bernard:
>
> so:
>
> >>> f = Father.objects.create(name='Chris', age=30)
> >>> adam = f.sons.create(name='Adam')
> >>> bernard = f.sons.create(name='Bernard')
> >>> f.sons.all() #Check that everything is ok
>
> [, ]
>
> >>> Father.objects.filter(sons__in=[adam, bernard]) #Let's see the fathers 
> >>> that have either Adam or Bernard among their sons
>
> [, ]
>
> >>> Father.objects.filter(sons__in=[adam, bernard]).distinct() #Since Chris 
> >>> have both, he appears twice; so, I have to apply 'distinct'
>
> []
>
> >>> Father.objects.filter(sons__in=[adam, 
> >>> bernard]).distinct().aggregate(Sum('age'))  #Let's see the total age...
>
> {'age__sum': 60}
>
> I think this is an error: the total age should be 30...
>
> The SQL query is:>>> from django.db import connection
> >>> connection.queries[-1]
>
> {'time': '0.000',
> 'sql': u'SELECT DISTINCT SUM(`testing_father`.`age`) AS `age__sum`
> FROM `testing_father` INNER JOIN `testing_father_sons` ON
> (`testing_father`.`id` = `testing_father_sons`.`father_id`) WHERE
> `testing_father_sons`.`son_id` IN (7, 6)'}
>
> So, Django applies DISTINCT on values already summed, while it shouls
> apply DISTINCT BEFORE summing.
>
> What do you think?
>
> Note that my actual problem is that I have to apply aggregation on a
> queryset which is provided by a 'black-box' function: the queryset is
> already provided with the '__in' filter and the 'distinct' clause and
> I cannot change its behaviour, nor taking distinct back...
>
> Any suggestion?
>
> Thanks a lot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Not calling clean() properly

2010-09-14 Thread Christos Jonathan Hayward
Thank you.

On Tue, Sep 14, 2010 at 3:01 AM, Daniel Roseman wrote:

> On Sep 13, 10:50 pm, Christos Jonathan Hayward
>  wrote:
> > Other attempts to write a clean that would run a print statement and then
> > call to_python(), validate(), and run_validators() did not result in that
> > print statement being called.
> >
> > Am I missing something about data being cleaned? The hooks I've tried to
> > override don't seem to be being called.
> >
>
> You don't say what is supposed to be calling clean. Are you using a
> form? If not, read this:
> http://docs.djangoproject.com/en/1.2/ref/validators/#how-validators-are-run
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
[image: Christos Jonathan Hayward] 
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio  • Books
 • *Email * •
Facebook
 • LinkedIn  •
Twitter
 • *Web * • What's
New?
I invite you to visit my "theology, literature, and other creative works"
site.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-mssql project... trying to update identity column?

2010-09-14 Thread jamescrowley
Hi guys - I'm not sure if this is the best place to post questions
about django-mssql but I couldn't find any mailing list specific to
that?

Anyway, I'm using django-mssql with the OSQA project (http://
www.osqa.net/) but it's doing an UPDATE statement like this:

UPDATE table SET fieldA='xyz',fieldB='abc',id=2 WHERE id in (2)

which is failing because ID is an auto-generated identity column which
has been created using the django tools (so don't think there's a
mapping issue or anything). Do you have any idea why this would be?

Many thanks

James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: tracking down a login issue (django 1.2)

2010-09-14 Thread Russell Keith-Magee
On Tue, Sep 14, 2010 at 3:09 AM, Cindy  wrote:
> OK, I have figured this out myself -- is there somewhere I should put
> in a bug report?

Almost certainly yes -- but based on the details you provide, it isn't
clear that the right place is Django's Trac instance. Django doesn't
provide an LDAP auth backend, and you haven't provided any details on
the backend that you are using.

I'm not ruling out the possibility that the fault may lie with Django,
but without more details on your auth setup, it's hard to provide
feedback.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: user created variables

2010-09-14 Thread nick.l...@gmail.com
cool glad to help! :)

On Tue, Sep 14, 2010 at 12:13 AM, pixelcowboy wrote:

> I see what you are saying, thanks for the advice!
>
> On Sep 13, 12:10 pm, "nick.l...@gmail.com" 
> wrote:
> > The problem I see with creating a model for each data type is that you
> have
> > LOTS of clutter in the admin...and what happens if you want to change the
> > value from a string to an int? You'd have to delete it one, then recreate
> it
> > in another...just a lot of steps. Also it means more models to
> maintain...if
> > you find yourself wanting to change a field on a data type model...and
> you
> > realize that would be a good change across the board...then your stuck
> with
> > running multiple migrations...(or I suppose you could sublclass the model
> > too...but that sounds yucky as well! :)
> >
> > I know it's more work up front to create a validator, but I also think
> it's
> > cleaner in the end to have just one model for Environmental Variables
> with a
> > type field. By creating the custom validation in the admin, you can give
> the
> > users a bit of help too when they are creating/changing variables. (ie
> > helping them along saying you chose data type int, and gave me a
> string...)
> >
> > n
> >
> > On Mon, Sep 13, 2010 at 6:55 PM, pixelcowboy  >wrote:
> >
> >
> >
> >
> >
> > > Yes, it totally does! Thanks again for your help. Another work around
> > > might be just creating different models for each data type that I want
> > > to validate, as in your first example maybe... but create a different
> > > model for each different data type possibility? What do you about this
> > > approach?
> >
> > > On Sep 13, 9:27 am, "nick.l...@gmail.com"  wrote:
> > > > hmm ok I'm thinking out loud here :)
> >
> > > > So you want your users to have the ability to create env variables
> > > through
> > > > the Django admin. You also want these variables to be validated (ie
> you
> > > > don't want people to put 123 in a char var).
> >
> > > > I still see this solution as being at least a starting ground. You
> would
> > > > just have to add some customization to the admin. Read:
> > >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom.
> ..
> >
> > > > Then in your form you can validate the data (ie check to make sure
> that
> > > the
> > > > value for the variable is of type what ever type they picked.)
> >
> > > > Then if your user attempted to put an int in a string you can have
> the
> > > > django admin raise errors to the user saying something to the effect
> "You
> > > > dingdong, the number 1 is not a string. If you want the number 1 to
> be a
> > > > string please put it in quotes"
> >
> > > > as an aside: You could also add a foreign key to the project (if you
> have
> > > a
> > > > project model)
> >
> > > > re: adding arbitrary models to django would be difficult, though i
> think
> > > you
> > > > can do it. The problem there is that each time you add a new model
> you'd
> > > > have to sync the database again. If you remove a model django won't
> > > remove
> > > > the tables in the DB you'd have to go and remove that table manually.
> >
> > > > The problem with validating an env-var pythonically in a database
> > > is..well
> > > > the database isn't python and vice versa. The way I think your're
> > > thinking
> > > > about it is you want to have a dynamic database where you can create
> > > > variables and destroy variables and change variable types the way you
> do
> > > in
> > > > python (ie a = 1, a= "1", del a, etc...)
> >
> > > > I think you're problem needs some creative thinking to create an
> > > environment
> > > > to create variables that replicates the way you can create variables
> in
> > > > Python.
> >
> > > > I hope I made some sense! :)
> >
> > > > n
> >
> > > > Once in there you can
> > > > On Mon, Sep 13, 2010 at 3:56 PM, pixelcowboy <
> pixelcowbo...@gmail.com
> > > >wrote:
> >
> > > > > The only reason I dont share the information is that I dont want to
> > > > > bore you to death. The application will need to provide (via a
> > > > > database) per project environment variables for use in external
> client
> > > > > applications. However, those variables might, or might not change
> from
> > > > > project to project.
> >
> > > > > The only problem that I see with your solution above is that it
> would
> > > > > not validate for type (in a pythonic sense). What way would there
> be
> > > > > to add an arbitrary number of a diverse set of django model types?
> > > > > Thanks again for your help.
> >
> > > > > On Sep 13, 6:40 am, "nick.l...@gmail.com" 
> wrote:
> > > > > > That's fine...well for data types ad a field for types say an
> integer
> > > > > field
> > > > > > and when youcome across a new type you need just increment your
> > > integer
> > > > > > count by one...
> >
> > > > > > ie:
> >
> > > > > > STRING = 1
> > > > > > INT = 2
> > > > > > CHAR = 3
> > > > > > TYPE_CHOICES = (
> > > > > > (STRING, 'string'),
> > > > > > (INT, 'integer'),
> > > > > > (CHA

Re: Is it possible for template to use context variable as list index?

2010-09-14 Thread David.D
It's a one-to-one relationship between queryset's content and
my_list's content.

in my view

return object_list( request,
 queryset=qs,
 template_name='my_template.html',
 extra_context={ 'my_list':
my_list, ... }, )

template(not work)
=
{% for object in object_list %}
{{ object.xx }}: {{ my_list.forloop.counter0 }}
{% endfor %}

I have other solution:
1. template tag
2.
[view]
zipped = []
for qs_obj in qs:
  list_value = find the list_value for qs_obj
  zipped.append( ( qs_obj, list_value) ) # add them as a tuple

[template]
{% for qs_obj, list_value in products %}
  {{qs_obj}}:  {{list_value}}
{% endfor %}

I wonder If django has a build-in way to do this. (It seems that
django has no build-in way...)
Thank you.

On Sep 14, 4:03 pm, bruno desthuilliers
 wrote:
> On 13 sep, 18:20, "David.D"  wrote:
>
> > In my template:
>
> > This is ok:
> > {{ my_list.2 }}
>
> > But it doesn't work:
> > {{ my_list.index }}
>
> > index is a context variable (index=2)
>
> This first looks up my_list for an attribute named "index" - which
> resolves to the "index" method of the list class if my_list is really
> a list - then try to do a dict lookup (ie: my_list["index"]). So
> technically speaking, it does "work" - in that does what the fine
> manual says it should do !-)
>
> Now, what's your use case exactly ? You don't need indexed access to
> iterate over a sequence, and if you know both my_list and index in
> your view (or templatetag or whatever), then you can just pass the
> appropriate value in your context from the view code itself.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



regular expressions

2010-09-14 Thread Imad Elharoussi
How do we make reference to a string that can contain a whitespace in the
urls.py

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



prepopulated_fields problem (+admin CSS issues)

2010-09-14 Thread Nick
Hello,

I'm running django 1.2.3 on a local server and am still quite new to
django. I was working with the "practical django projects second
edition" book and implemented the prepopulated_fields option to auto
populate slugs from titles.

It works when I add a new post but it does not work when I edit the
post, is this working as intended or broken? It seems for this option
to be useful it must update on change as well. If that's not a
supported option what can I do to hack it in?

The code I am using is (admin.py):

class CategoryAdmin(admin.ModelAdmin):
prepopulated_fields = { 'slug': ['title'] }

class EntryAdmin(admin.ModelAdmin):
prepopulated_fields = { 'slug': ['title'] }

class LinkAdmin(admin.ModelAdmin):
prepopulated_fields = { 'slug': ['title'] }

admin.site.register(Category, CategoryAdmin)
admin.site.register(Entry, EntryAdmin)
admin.site.register(Link, LinkAdmin)

I also tried using the django documentation's syntax with no luck, it
resulted in the same broken functionality. I tried it with Opera 10.x
and IE8, same results.

Also there appears to be a massive problem with the CSS when using the
filter sidebar. The admin is designed to be fluid width and
automatically generates the proper fluid width of columns but it fails
to make the column widths fluid when the filter sidebar is enabled.

Is there a known hack to correct this? It looks very awkward when you
have a 1600 width screen and 3 or 4 columns are shrunken to 75-100
pixels wide with a 1000 pixel white space before it shows the sidebar.

Thanks,
Nick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: regular expressions

2010-09-14 Thread Shawn Milochik
It depends on whether it can contain whitespace or must contain
whitespace, and whether that whitespace may appear anywhere in the
string or only in a certain location, or after (or before) some other
matched pattern.

Examples:

[\w\s]+ will match "word" and/or whitespace, mixed.

\w+[\w\s]+ will match word and/or whitespace mixed, but must be
preceded by "word" characters.

\w+\s+\d+ will match "word" characters followed by whitespace followed
by one or more digits.

Have a look at the regex syntax here:
http://docs.python.org/library/re.html

Regular expressions are intimidating at first, but once you're
familiar with the meaning of the most commonly-used characters (*, +,
\w, \s, \d, ., {}) then you're most of the way there.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: prepopulated_fields problem (+admin CSS issues)

2010-09-14 Thread nick.l...@gmail.com
Nick,

I can answer you first question...but not really the second...hopefully
someone else will come and explain that one to you...

re slugs: The prepopulated_fields are working as intended.

The reason being, say you've written a blog post. You've send that link out
to thousands and millions of people. Then you realize that you wanted to
change a word in your title (hence changing the slug).

As soon as you change that slug, you've broken a link on the internet that
was previously NOT broken before. Even if you change the title, don't change
the slug.

Django can figure out the "absolute_url" for what ever slug you pick. But
once the link has been published _outside_ your site, you don't want to have
broken links. Remember it's just a slug...just a url...the real title can be
what ever you want it to be.

BUT if you want django to behave the way you're expecting, the great thing
about django is you can change it to behave that way. All it takes is a
little customization of the change_view for the admin of your blog app (or
what ever app you want to change the behavior of).

Hope that helps

Nick (also)

On Tue, Sep 14, 2010 at 3:10 PM, Nick  wrote:

> Hello,
>
> I'm running django 1.2.3 on a local server and am still quite new to
> django. I was working with the "practical django projects second
> edition" book and implemented the prepopulated_fields option to auto
> populate slugs from titles.
>
> It works when I add a new post but it does not work when I edit the
> post, is this working as intended or broken? It seems for this option
> to be useful it must update on change as well. If that's not a
> supported option what can I do to hack it in?
>
> The code I am using is (admin.py):
>
> class CategoryAdmin(admin.ModelAdmin):
>prepopulated_fields = { 'slug': ['title'] }
>
> class EntryAdmin(admin.ModelAdmin):
>prepopulated_fields = { 'slug': ['title'] }
>
> class LinkAdmin(admin.ModelAdmin):
>prepopulated_fields = { 'slug': ['title'] }
>
> admin.site.register(Category, CategoryAdmin)
> admin.site.register(Entry, EntryAdmin)
> admin.site.register(Link, LinkAdmin)
>
> I also tried using the django documentation's syntax with no luck, it
> resulted in the same broken functionality. I tried it with Opera 10.x
> and IE8, same results.
>
> Also there appears to be a massive problem with the CSS when using the
> filter sidebar. The admin is designed to be fluid width and
> automatically generates the proper fluid width of columns but it fails
> to make the column widths fluid when the filter sidebar is enabled.
>
> Is there a known hack to correct this? It looks very awkward when you
> have a 1600 width screen and 3 or 4 columns are shrunken to 75-100
> pixels wide with a 1000 pixel white space before it shows the sidebar.
>
> Thanks,
> Nick
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can't get m2m_changed signal working

2010-09-14 Thread Jason
Is the m2m_changed() call in the models.py?

Also, it looks indented - if it is, it shouldn't be - in other words -
it doesn't belong to the model.

On Sep 13, 1:27 pm, allyb  wrote:
> I'm finding it difficult to denormalise a field in a django model. I
> have:
>
>     class AnswerSet(models.Model):
>         title = models.CharField(max_length=255)
>         num_answers = models.PositiveIntegerField(editable=False,
> default=0)
>         answers = models.ManyToManyField(Answer,
> through='AnswerSetAnswer')
>         ...
>
>     class AnswerSetAnswer(models.Model):
>         answer = models.ForeignKey(Answer)
>         answer_set = models.ForeignKey(AnswerSet)
>         ...
>
> I want num_answers to contain a count of the number of answers in the
> set.
>
> If 5 answers are initially associated with the AnswerSet "Food" and I
> edit one so it becomes associated with the AnswerSet "Colours", how
> can I recalculate the number of answers in the AnswerSet with "Food"?
> All the signals only seem to send the new data so I can't just
> override the save method.
>
> I've tried using the m2m_changed signal, but it never gets called when
> I edit relationships through the admin form.
>
> Here's my code anyway:
>
>     def update_answer_set_num_answers(sender, **kwargs):
>         """
>         Updates the num_answers field to reflect the number of answers
>         associated with this AnswerSet
>         """
>         print "hello"                                              #
> never gets here
>         instance = kwargs.get('instance', False)
>
>         print "no instance"
>
>         if not instance:
>             return
>
>         action = kwargs.get('action')
>
>         print "action: ", action
>
>         if (action != 'pre_remove' and action != 'pre_add' and action !
> = 'clear'):
>             return
>
>         reverse = kwargs.get('reverse')
>
>         if reverse:
>             answer_set = instance.answer_set
>         else:
>             answer_set = instance.answer_set
>         num_answers =
> AnswerSetAnswer.objects.filter(answer_set=answer_set.id).count()
>
>         if (action == 'pre_remove'):
>             num_answers -= int(kwargs.get('pk_set'))
>         elif (action == 'pre_add'):
>             num_answers += int(kwargs.get('pk_set'))
>         elif (action == 'clear'):
>             num_answers = 0
>
>         answer_set.num_answers = num_answers
>
>         print 'n a: ', answer_set.num_answers
>         answer_set.save()
>
>     m2m_changed.connect(update_answer_set_num_answers, \
>       AnswerSet.answers.through)
>
> Setting weak=False or weak=True makes no difference.
>
> How can I get the signal to work?
>
> Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Tools to ease template/ui development

2010-09-14 Thread payala

Hello everybody!

This is my first post over here, I'll briefly introduce myself saying
that I am an electronic engineer fiddling with a little bit of web
development. After trying asp and other nasty stuff, I have discovered
Django and I am LOVING it, it is just incredible.

As I said, I've been learning Django for a couple of months, and it
makes web development really easy... to the point that template/UI
design has become the hard part in my opinion.

What resources do you guys use to ease the pain of doing a nice user
interface??

Thank you all!
Pedro

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: prepopulated_fields problem (+admin CSS issues)

2010-09-14 Thread Nick
Yeah that makes sense. I guess we just need to be more careful when
adding live posts. Maybe it wouldn't be a bad idea to add the
functionality on change if a post is anything but live. This way the
slug stays relevant to the title for drafts if the editor feels like
experimenting with different titles.

As for my second question. Can you not help because you haven't
experienced this issue, or is it something you just don't have a
problem with?

On Sep 14, 11:20 am, "nick.l...@gmail.com" 
wrote:
> Nick,
>
> I can answer you first question...but not really the second...hopefully
> someone else will come and explain that one to you...
>
> re slugs: The prepopulated_fields are working as intended.
>
> The reason being, say you've written a blog post. You've send that link out
> to thousands and millions of people. Then you realize that you wanted to
> change a word in your title (hence changing the slug).
>
> As soon as you change that slug, you've broken a link on the internet that
> was previously NOT broken before. Even if you change the title, don't change
> the slug.
>
> Django can figure out the "absolute_url" for what ever slug you pick. But
> once the link has been published _outside_ your site, you don't want to have
> broken links. Remember it's just a slug...just a url...the real title can be
> what ever you want it to be.
>
> BUT if you want django to behave the way you're expecting, the great thing
> about django is you can change it to behave that way. All it takes is a
> little customization of the change_view for the admin of your blog app (or
> what ever app you want to change the behavior of).
>
> Hope that helps
>
> Nick (also)
>
> On Tue, Sep 14, 2010 at 3:10 PM, Nick 
>
>
>
>
> > wrote:
> > Hello,
>
> > I'm running django 1.2.3 on a local server and am still quite new to
> > django. I was working with the "practical django projects second
> > edition" book and implemented the prepopulated_fields option to auto
> > populate slugs from titles.
>
> > It works when I add a new post but it does not work when I edit the
> > post, is this working as intended or broken? It seems for this option
> > to be useful it must update on change as well. If that's not a
> > supported option what can I do to hack it in?
>
> > The code I am using is (admin.py):
>
> > class CategoryAdmin(admin.ModelAdmin):
> >    prepopulated_fields = { 'slug': ['title'] }
>
> > class EntryAdmin(admin.ModelAdmin):
> >    prepopulated_fields = { 'slug': ['title'] }
>
> > class LinkAdmin(admin.ModelAdmin):
> >    prepopulated_fields = { 'slug': ['title'] }
>
> > admin.site.register(Category, CategoryAdmin)
> > admin.site.register(Entry, EntryAdmin)
> > admin.site.register(Link, LinkAdmin)
>
> > I also tried using the django documentation's syntax with no luck, it
> > resulted in the same broken functionality. I tried it with Opera 10.x
> > and IE8, same results.
>
> > Also there appears to be a massive problem with the CSS when using the
> > filter sidebar. The admin is designed to be fluid width and
> > automatically generates the proper fluid width of columns but it fails
> > to make the column widths fluid when the filter sidebar is enabled.
>
> > Is there a known hack to correct this? It looks very awkward when you
> > have a 1600 width screen and 3 or 4 columns are shrunken to 75-100
> > pixels wide with a 1000 pixel white space before it shows the sidebar.
>
> > Thanks,
> > Nick
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Guadajuko! Vamos a correr!
>  -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: prepopulated_fields problem (+admin CSS issues)

2010-09-14 Thread nick.l...@gmail.com
If the slugs are something you're really concerned with... I would say
customize the change form to work the way you want.

Personally, I would rather the computer error on the side of not
breaking...instead of trying to anticipate what I want it to do this
time...vs next time vs a year from now.

Re the CSS of the admin: Well...I've noticed it...though I never thought of
it as an 'issue'.

CSS/Design isn't my strong point. In fact...I wouldn't even consider myself
average at it! Probably sufficiently below average. So I always take stuff
that's been designed by others to be purposeful.

I can't say why it was designed that way or if it was an accident of the way
the filter gets added...

hope that helps.

n

On Tue, Sep 14, 2010 at 3:30 PM, Nick  wrote:

> Yeah that makes sense. I guess we just need to be more careful when
> adding live posts. Maybe it wouldn't be a bad idea to add the
> functionality on change if a post is anything but live. This way the
> slug stays relevant to the title for drafts if the editor feels like
> experimenting with different titles.
>
> As for my second question. Can you not help because you haven't
> experienced this issue, or is it something you just don't have a
> problem with?
>
> On Sep 14, 11:20 am, "nick.l...@gmail.com" 
> wrote:
> > Nick,
> >
> > I can answer you first question...but not really the second...hopefully
> > someone else will come and explain that one to you...
> >
> > re slugs: The prepopulated_fields are working as intended.
> >
> > The reason being, say you've written a blog post. You've send that link
> out
> > to thousands and millions of people. Then you realize that you wanted to
> > change a word in your title (hence changing the slug).
> >
> > As soon as you change that slug, you've broken a link on the internet
> that
> > was previously NOT broken before. Even if you change the title, don't
> change
> > the slug.
> >
> > Django can figure out the "absolute_url" for what ever slug you pick. But
> > once the link has been published _outside_ your site, you don't want to
> have
> > broken links. Remember it's just a slug...just a url...the real title can
> be
> > what ever you want it to be.
> >
> > BUT if you want django to behave the way you're expecting, the great
> thing
> > about django is you can change it to behave that way. All it takes is a
> > little customization of the change_view for the admin of your blog app
> (or
> > what ever app you want to change the behavior of).
> >
> > Hope that helps
> >
> > Nick (also)
> >
> > On Tue, Sep 14, 2010 at 3:10 PM, Nick <
> iregisteratwebsiteswitht...@gmail.com
> >
> >
> >
> >
> >
> > > wrote:
> > > Hello,
> >
> > > I'm running django 1.2.3 on a local server and am still quite new to
> > > django. I was working with the "practical django projects second
> > > edition" book and implemented the prepopulated_fields option to auto
> > > populate slugs from titles.
> >
> > > It works when I add a new post but it does not work when I edit the
> > > post, is this working as intended or broken? It seems for this option
> > > to be useful it must update on change as well. If that's not a
> > > supported option what can I do to hack it in?
> >
> > > The code I am using is (admin.py):
> >
> > > class CategoryAdmin(admin.ModelAdmin):
> > >prepopulated_fields = { 'slug': ['title'] }
> >
> > > class EntryAdmin(admin.ModelAdmin):
> > >prepopulated_fields = { 'slug': ['title'] }
> >
> > > class LinkAdmin(admin.ModelAdmin):
> > >prepopulated_fields = { 'slug': ['title'] }
> >
> > > admin.site.register(Category, CategoryAdmin)
> > > admin.site.register(Entry, EntryAdmin)
> > > admin.site.register(Link, LinkAdmin)
> >
> > > I also tried using the django documentation's syntax with no luck, it
> > > resulted in the same broken functionality. I tried it with Opera 10.x
> > > and IE8, same results.
> >
> > > Also there appears to be a massive problem with the CSS when using the
> > > filter sidebar. The admin is designed to be fluid width and
> > > automatically generates the proper fluid width of columns but it fails
> > > to make the column widths fluid when the filter sidebar is enabled.
> >
> > > Is there a known hack to correct this? It looks very awkward when you
> > > have a 1600 width screen and 3 or 4 columns are shrunken to 75-100
> > > pixels wide with a 1000 pixel white space before it shows the sidebar.
> >
> > > Thanks,
> > > Nick
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com
> 
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
> >
> > --
> > Guadajuko! Vamos a correr!
> >  -"Cool! we are going to run!"
>
> --
> You received this message because you are subscribed to the Google Groups
> "D

Re: Is it possible for template to use context variable as list index?

2010-09-14 Thread bruno desthuilliers
On 14 sep, 16:54, "David.D"  wrote:
> It's a one-to-one relationship between queryset's content and
> my_list's content.
>
> in my view
> 
> return object_list( request,
>                                  queryset=qs,
>                                  template_name='my_template.html',
>                                  extra_context={ 'my_list':
> my_list, ... }, )

(snip)
>
> I have other solution:
(snip)

> [view]
>     zipped = []
>     for qs_obj in qs:
>       list_value = find the list_value for qs_obj
>       zipped.append( ( qs_obj, list_value) ) # add them as a tuple


or way simplier if the above fits your needs :

  return object_list(
 request,
 queryset=qs,
 template_name='my_template.html',
 extra_context={'products' : zip(qs, my_list) }
 )


If I may ask: how do you build that list anyway ?

> [template]
> {% for qs_obj, list_value in products %}
>   {{qs_obj}}:  {{list_value}}
> {% endfor %}


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Prepopulating fields from parent, or related models, in the admin

2010-09-14 Thread pixelcowboy
Hi, I want a project structure that is as follows:

I have an application with project model that has a subproject, and
that subproject has other subproject,etc. What I want to get is that
the subproject gets the same attributes that the parent project, but
is also able to override their values in its own instance (but not in
the parent instance).

My first idea is using something like a foreign key. This gives me
access to the parent values, but not the ability to override them.

The second option is multi-table inheritance from the parent class.
This gives me the parents class attributes, but I again I dont get the
fields in the admin, so Im not able to override them (at least not in
the admin). Is there any way to this?

The third option is to inherit an abstract class. The parent also
inherits from this class, so both have the fields I need. However, I
would like for the child class to inherit default values for this
fields from the parent class, but be free to override them. Is there
any way to pre-populate fields in the admin with the attribute values
from a parent or related files?

Thanks for your help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: regular expressions

2010-09-14 Thread Imad Elharoussi
thank you
I have two paramaters in my url how do I write the request function in my
views.py:
is it like this:

def function(request, parameter1, parameter2)??

2010/9/14 Shawn Milochik 

> It depends on whether it can contain whitespace or must contain
> whitespace, and whether that whitespace may appear anywhere in the
> string or only in a certain location, or after (or before) some other
> matched pattern.
>
> Examples:
>
> [\w\s]+ will match "word" and/or whitespace, mixed.
>
> \w+[\w\s]+ will match word and/or whitespace mixed, but must be
> preceded by "word" characters.
>
> \w+\s+\d+ will match "word" characters followed by whitespace followed
> by one or more digits.
>
> Have a look at the regex syntax here:
> http://docs.python.org/library/re.html
>
> Regular expressions are intimidating at first, but once you're
> familiar with the meaning of the most commonly-used characters (*, +,
> \w, \s, \d, ., {}) then you're most of the way there.
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



contrib.comments, admin section [unable to see comments]

2010-09-14 Thread Nick
Hello,

I tried to troubleshoot this with Google and #django on IRC but I'm
coming up empty. I've been following the practical django projects
second edition book using django 1.2.3 on a local server.

I have added 'django.contrib.comments' to my settings file + adjusted
my urls.py file just like the book said and ran syncdb. The admin
section is picking up the comments "model" fine. I can post comments
fine and they are visible within the post, great.

When I goto the admin section and click comments, then click comments
again I'm presented with what should be a page to allow me to see the
available comments and admin them (edit, delete, etc.). The issue is
that the rows are empty for each comment. Instead it just gives me a
count of the number of comments which makes it impossible to manage
the comments.

Here is a screenshot:
 http://i51.tinypic.com/awfjes.jpg

The URL is: http://localhost:8080/admin/comments/comment/ (I'm
developing it locally obviously)

Someone on IRC said this might actually be a bug but I can't imagine
it's a bug. I mean, this is a serious issue and surely would have been
found before releasing this build to the public.

My admin templates are unmodified too so it's not that.

What the heck is going on?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can't get m2m_changed signal working

2010-09-14 Thread allyb
hi,

yes, it is called in models.py, and no, it's not indented and neither
is the handler function.

On Sep 14, 4:28 pm, Jason  wrote:
> Is the m2m_changed() call in the models.py?
>
> Also, it looks indented - if it is, it shouldn't be - in other words -
> it doesn't belong to the model.
>
> On Sep 13, 1:27 pm, allyb  wrote:
>
> > I'm finding it difficult to denormalise a field in a django model. I
> > have:
>
> >     class AnswerSet(models.Model):
> >         title = models.CharField(max_length=255)
> >         num_answers = models.PositiveIntegerField(editable=False,
> > default=0)
> >         answers = models.ManyToManyField(Answer,
> > through='AnswerSetAnswer')
> >         ...
>
> >     class AnswerSetAnswer(models.Model):
> >         answer = models.ForeignKey(Answer)
> >         answer_set = models.ForeignKey(AnswerSet)
> >         ...
>
> > I want num_answers to contain a count of the number of answers in the
> > set.
>
> > If 5 answers are initially associated with the AnswerSet "Food" and I
> > edit one so it becomes associated with the AnswerSet "Colours", how
> > can I recalculate the number of answers in the AnswerSet with "Food"?
> > All the signals only seem to send the new data so I can't just
> > override the save method.
>
> > I've tried using the m2m_changed signal, but it never gets called when
> > I edit relationships through the admin form.
>
> > Here's my code anyway:
>
> >     def update_answer_set_num_answers(sender, **kwargs):
> >         """
> >         Updates the num_answers field to reflect the number of answers
> >         associated with this AnswerSet
> >         """
> >         print "hello"                                              #
> > never gets here
> >         instance = kwargs.get('instance', False)
>
> >         print "no instance"
>
> >         if not instance:
> >             return
>
> >         action = kwargs.get('action')
>
> >         print "action: ", action
>
> >         if (action != 'pre_remove' and action != 'pre_add' and action !
> > = 'clear'):
> >             return
>
> >         reverse = kwargs.get('reverse')
>
> >         if reverse:
> >             answer_set = instance.answer_set
> >         else:
> >             answer_set = instance.answer_set
> >         num_answers =
> > AnswerSetAnswer.objects.filter(answer_set=answer_set.id).count()
>
> >         if (action == 'pre_remove'):
> >             num_answers -= int(kwargs.get('pk_set'))
> >         elif (action == 'pre_add'):
> >             num_answers += int(kwargs.get('pk_set'))
> >         elif (action == 'clear'):
> >             num_answers = 0
>
> >         answer_set.num_answers = num_answers
>
> >         print 'n a: ', answer_set.num_answers
> >         answer_set.save()
>
> >     m2m_changed.connect(update_answer_set_num_answers, \
> >       AnswerSet.answers.through)
>
> > Setting weak=False or weak=True makes no difference.
>
> > How can I get the signal to work?
>
> > Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



HTML_REMOVED

2010-09-14 Thread Bobby Roberts
i'm using django comments and when someone uses special characters in
their comment (', &  etc...), when it is rendered to the screen it
says HTML_REMOVED... what is the fastest and best way to show the
correct character instead of HTML_REMOVED.

for example...


in the template we have

{{comment.comment}}


and it may print out something like

As you mentioned on last week[HTML_REMOVED]s e-newsletter...


(notice the ' mark has been replaced)

How do i get the right character to show?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Tools to ease template/ui development

2010-09-14 Thread pixelcowboy
Pydev supports Django templates in Aptana, and there is also an IDE
called PyCharm that is supposed to support them. I have begun learning
eclipse and I like it. Eric IDE and its Django plugin is also very
good, although I dont think it supports Django templates.

On Sep 14, 8:20 am, payala  wrote:
> Hello everybody!
>
> This is my first post over here, I'll briefly introduce myself saying
> that I am an electronic engineer fiddling with a little bit of web
> development. After trying asp and other nasty stuff, I have discovered
> Django and I am LOVING it, it is just incredible.
>
> As I said, I've been learning Django for a couple of months, and it
> makes web development really easy... to the point that template/UI
> design has become the hard part in my opinion.
>
> What resources do you guys use to ease the pain of doing a nice user
> interface??
>
> Thank you all!
> Pedro

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Looking for Django Developer(s) in & around Pune, india

2010-09-14 Thread Anand Agarwal
Hi

We are looking for python/django developer in & around Pune for full time
job.
We require passionate people ready to work in a startup product company.
Anyone interested can send me his/her resume.

Thanks & Regards
Anand

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Tools to ease template/ui development

2010-09-14 Thread payala
I agree about Aptana. I am trying it right now and it looks very good,
I already used eclipse and I think it rocks!

However, re-reading my post I realise that I didn't express myself as
well as I would have liked. Maybe a better title for my question would
have been:

OK, now we have rapid web development frameworks... where is the rapid
web DESIGN stuff??

;-)

regards,
Pedro


On 14 sep, 20:07, pixelcowboy  wrote:
> Pydev supports Django templates in Aptana, and there is also an IDE
> called PyCharm that is supposed to support them. I have begun learning
> eclipse and I like it. Eric IDE and its Django plugin is also very
> good, although I dont think it supports Django templates.
>
> On Sep 14, 8:20 am, payala  wrote:
>
>
>
> > Hello everybody!
>
> > This is my first post over here, I'll briefly introduce myself saying
> > that I am an electronic engineer fiddling with a little bit of web
> > development. After trying asp and other nasty stuff, I have discovered
> > Django and I am LOVING it, it is just incredible.
>
> > As I said, I've been learning Django for a couple of months, and it
> > makes web development really easy... to the point that template/UI
> > design has become the hard part in my opinion.
>
> > What resources do you guys use to ease the pain of doing a nice user
> > interface??
>
> > Thank you all!
> > Pedro

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Prepopulating fields from parent, or related models, in the admin

2010-09-14 Thread nick.l...@gmail.com
Hi again! :)

I haven't thought this idea through, and very well could be
wildly inefficient! :)

Though in your admin.py when registering the admin model do something like
this:

from myproject.myapp.models import MyModel, OtherModel


class MyModelAdmin(models.admin):
object_i_want = OtherModel.objects.get(field_i_care_about=whatever)
prepopulated_fields = { "field_i_care_about":
(object_i_want.field_i_care_about)

admin.site.register(MyModel, MyModelAdmin)


On Tue, Sep 14, 2010 at 3:59 PM, pixelcowboy wrote:

> Hi, I want a project structure that is as follows:
>
> I have an application with project model that has a subproject, and
> that subproject has other subproject,etc. What I want to get is that
> the subproject gets the same attributes that the parent project, but
> is also able to override their values in its own instance (but not in
> the parent instance).
>
> My first idea is using something like a foreign key. This gives me
> access to the parent values, but not the ability to override them.
>
> The second option is multi-table inheritance from the parent class.
> This gives me the parents class attributes, but I again I dont get the
> fields in the admin, so Im not able to override them (at least not in
> the admin). Is there any way to this?
>
> The third option is to inherit an abstract class. The parent also
> inherits from this class, so both have the fields I need. However, I
> would like for the child class to inherit default values for this
> fields from the parent class, but be free to override them. Is there
> any way to pre-populate fields in the admin with the attribute values
> from a parent or related files?
>
> Thanks for your help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can't get m2m_changed signal working

2010-09-14 Thread allyb
hi,

yes, it is called in models.py, and no, it's not indented and neither
is the handler function.

On Sep 14, 4:28 pm, Jason  wrote:
> Is the m2m_changed() call in the models.py?
>
> Also, it looks indented - if it is, it shouldn't be - in other words -
> it doesn't belong to the model.
>
> On Sep 13, 1:27 pm, allyb  wrote:
>
> > I'm finding it difficult to denormalise a field in a django model. I
> > have:
>
> >     class AnswerSet(models.Model):
> >         title = models.CharField(max_length=255)
> >         num_answers = models.PositiveIntegerField(editable=False,
> > default=0)
> >         answers = models.ManyToManyField(Answer,
> > through='AnswerSetAnswer')
> >         ...
>
> >     class AnswerSetAnswer(models.Model):
> >         answer = models.ForeignKey(Answer)
> >         answer_set = models.ForeignKey(AnswerSet)
> >         ...
>
> > I want num_answers to contain a count of the number of answers in the
> > set.
>
> > If 5 answers are initially associated with the AnswerSet "Food" and I
> > edit one so it becomes associated with the AnswerSet "Colours", how
> > can I recalculate the number of answers in the AnswerSet with "Food"?
> > All the signals only seem to send the new data so I can't just
> > override the save method.
>
> > I've tried using the m2m_changed signal, but it never gets called when
> > I edit relationships through the admin form.
>
> > Here's my code anyway:
>
> >     def update_answer_set_num_answers(sender, **kwargs):
> >         """
> >         Updates the num_answers field to reflect the number of answers
> >         associated with this AnswerSet
> >         """
> >         print "hello"                                              #
> > never gets here
> >         instance = kwargs.get('instance', False)
>
> >         print "no instance"
>
> >         if not instance:
> >             return
>
> >         action = kwargs.get('action')
>
> >         print "action: ", action
>
> >         if (action != 'pre_remove' and action != 'pre_add' and action !
> > = 'clear'):
> >             return
>
> >         reverse = kwargs.get('reverse')
>
> >         if reverse:
> >             answer_set = instance.answer_set
> >         else:
> >             answer_set = instance.answer_set
> >         num_answers =
> > AnswerSetAnswer.objects.filter(answer_set=answer_set.id).count()
>
> >         if (action == 'pre_remove'):
> >             num_answers -= int(kwargs.get('pk_set'))
> >         elif (action == 'pre_add'):
> >             num_answers += int(kwargs.get('pk_set'))
> >         elif (action == 'clear'):
> >             num_answers = 0
>
> >         answer_set.num_answers = num_answers
>
> >         print 'n a: ', answer_set.num_answers
> >         answer_set.save()
>
> >     m2m_changed.connect(update_answer_set_num_answers, \
> >       AnswerSet.answers.through)
>
> > Setting weak=False or weak=True makes no difference.
>
> > How can I get the signal to work?
>
> > Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



View to serve dumpdata output

2010-09-14 Thread David Somers Harris
Is it possible to write a view which serves the JSON output of dumpdata?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using IDs for upload_to path

2010-09-14 Thread Scott Gould
Your ID: if it's a new object, you can't.

Another field in the model: if it's calculated instead of database-
provided, sure. I use UUIDs for this:

def get_uuid():
import uuid
return str(uuid.uuid4())

class UploadedFileModel(models.Model):
physical_file = FileField(verbose_name='Physical File',
max_length=200, upload_to=get_upload_path)
uuid = models.CharField(max_length=36, default=get_uuid,
editable=False)


On Sep 13, 8:27 am, Tereno  wrote:
> Hi there, I've an ImageField and it requires a upload_to path or a
> callable. From what I read in the docs, the callable takes two
> arguments, one of which is the instance of model. It is stated that
> the model may not have been saved in the database at this point and
> thus, we cannot assume to obtain a valid id number. How would I be
> able to save an image in a path that is related to my id or another
> field within the model?
>
> Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Tools to ease template/ui development

2010-09-14 Thread bruno desthuilliers
On 14 sep, 20:23, payala  wrote:
> I agree about Aptana. I am trying it right now and it looks very good,
> I already used eclipse and I think it rocks!

Emacs is the OneTrueEditor !-)

> However, re-reading my post I realise that I didn't express myself as
> well as I would have liked. Maybe a better title for my question would
> have been:
>
> OK, now we have rapid web development frameworks... where is the rapid
> web DESIGN stuff??

blueprint && uniform come to mind.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



getting force_update to work

2010-09-14 Thread Anomal
According to the Django docs,  a new row is created with the new value
primary key when  when I change the value of a primary key and save
the object.

In this case, I am looking to change the value. So, I use
force_update=True. Instead of changing the value of the primary key, I
get a DatabaseError. Any ideas of what I am doing incorrectly?

class BuildState(models.Model):
build_state = models.CharField(primary_key=True, max_length=32)

class Meta:
db_table = u'buildstate'

def __unicode__(self):
return  "BuildState{'build_state' : '%s'}" %
(self.build_state)

>>> from orm.models import BuildState
>>> foo = BuildState.objects.get(build_state='failed')
>>> foo

>>> foo.build_state='nirvana'
>>> foo.save(force_update=True)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/pymodules/python2.6/django/db/models/base.py", line
410, in save
self.save_base(force_insert=force_insert,
force_update=force_update)
  File "/usr/lib/pymodules/python2.6/django/db/models/base.py", line
476, in save_base
raise DatabaseError("Forced update did not affect any rows.")
DatabaseError: Forced update did not affect any rows.
>>>
>>>
>>> foo.save()
>>> # This works as expected. A new row is added.
>>>

Thanks,
 -Rick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: View to serve dumpdata output

2010-09-14 Thread nick.l...@gmail.com
one way to do it would be to do this (on an app by app basis)

http://docs.djangoproject.com/en/dev/topics/serialization/#serializing-data

Then have your view return data

n

On Tue, Sep 14, 2010 at 8:01 PM, David Somers Harris <
da...@somers-harris.com> wrote:

> Is it possible to write a view which serves the JSON output of dumpdata?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Tools to ease template/ui development

2010-09-14 Thread pixelcowboy
I would really love something like pyjamas but that works with jquery
or something like that. What I would really love is to forget every
other programming language and just use python everywhere. Wouldn't
that be sweet?

On Sep 14, 1:20 pm, bruno desthuilliers
 wrote:
> On 14 sep, 20:23, payala  wrote:
>
> > I agree about Aptana. I am trying it right now and it looks very good,
> > I already used eclipse and I think it rocks!
>
> Emacs is the OneTrueEditor !-)
>
> > However, re-reading my post I realise that I didn't express myself as
> > well as I would have liked. Maybe a better title for my question would
> > have been:
>
> > OK, now we have rapid web development frameworks... where is the rapid
> > web DESIGN stuff??
>
> blueprint && uniform come to mind.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



error after upgrading to 1.2.3

2010-09-14 Thread Börni
Hello together,
after upgrading to django 1.2.3 i got the following error:

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/MySQLdb/__init__.py:34: DeprecationWarning:
the sets module is deprecated
  from sets import ImmutableSet
Traceback (most recent call last):
  File "./manage.py", line 20, in 
execute_manager(settings)
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/core/management/base.py", line 209, in execute
translation.activate('en-us')
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/utils/translation/__init__.py", line 66, in activate
return real_activate(language)
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/utils/functional.py", line 55, in _curried
return _curried_func(*(args+moreargs), **dict(kwargs,
**morekwargs))
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/utils/translation/__init__.py", line 36, in delayed_loader
return getattr(trans, real_name)(*args, **kwargs)
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/utils/translation/trans_real.py", line 193, in activate
_active[currentThread()] = translation(language)
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/utils/translation/trans_real.py", line 177, in translation
current_translation = _fetch(language,
fallback=default_translation)
  File "/Users/boerni/Projects/ldb/external/django/django-current/
django/utils/translation/trans_real.py", line 142, in _fetch
res._info = res._info.copy()
AttributeError: 'NoneType' object has no attribute '_info'

Any suggestions what's could be wrong?

Thanks and best regards,
Börni

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Prepopulating fields from parent, or related models, in the admin

2010-09-14 Thread pixelcowboy
I'll try when I get home, but thanks again for your help!

On Sep 14, 11:31 am, "nick.l...@gmail.com" 
wrote:
> Hi again! :)
>
> I haven't thought this idea through, and very well could be
> wildly inefficient! :)
>
> Though in your admin.py when registering the admin model do something like
> this:
>
> from myproject.myapp.models import MyModel, OtherModel
>
> class MyModelAdmin(models.admin):
>     object_i_want = OtherModel.objects.get(field_i_care_about=whatever)
>     prepopulated_fields = { "field_i_care_about":
> (object_i_want.field_i_care_about)
>
> admin.site.register(MyModel, MyModelAdmin)
>
> On Tue, Sep 14, 2010 at 3:59 PM, pixelcowboy wrote:
>
>
>
>
>
> > Hi, I want a project structure that is as follows:
>
> > I have an application with project model that has a subproject, and
> > that subproject has other subproject,etc. What I want to get is that
> > the subproject gets the same attributes that the parent project, but
> > is also able to override their values in its own instance (but not in
> > the parent instance).
>
> > My first idea is using something like a foreign key. This gives me
> > access to the parent values, but not the ability to override them.
>
> > The second option is multi-table inheritance from the parent class.
> > This gives me the parents class attributes, but I again I dont get the
> > fields in the admin, so Im not able to override them (at least not in
> > the admin). Is there any way to this?
>
> > The third option is to inherit an abstract class. The parent also
> > inherits from this class, so both have the fields I need. However, I
> > would like for the child class to inherit default values for this
> > fields from the parent class, but be free to override them. Is there
> > any way to pre-populate fields in the admin with the attribute values
> > from a parent or related files?
>
> > Thanks for your help.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Guadajuko! Vamos a correr!
>  -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Querying Exact Foreign Key Sets

2010-09-14 Thread Jason
Say for example you have two models:

Article
Category


Articles can have multiple categories.

How would you go about finding the Articles that contain only a
certain set of Categories?

The 'in' operator doesn't do me any good. Excludes look like they are
needed...


I'm in a situation where quickly sorting by SETS of categories is
needed and I'm having a tough time. My database programming skills are
pretty weak.

I'm thinking of making an intermediate model called CategorySets.

Articles would then have a relationship to a CategorySet and I can
sort very easily on this.


(note my actual project isn't using Articles but it's quicker to
explain in these terms).

Does anyone have any tips or experience here?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Tools to ease template/ui development

2010-09-14 Thread Javier Guerra Giraldez
On Tue, Sep 14, 2010 at 4:18 PM, pixelcowboy  wrote:
> I would really love something like pyjamas but that works with jquery
> or something like that. What I would really love is to forget every
> other programming language and just use python everywhere. Wouldn't
> that be sweet?

the problem with pyjamas (and similar 'translators') is that you use
Python syntax with all the common limitations of JavaScript.  for
example, in JS you use 'objects' for dicts, and they can only use
strings for keys.  another one: when i first tried it, it didn't
support yield(), so many built-in iterators just didn't work.  i guess
it has improved, but you could only forget about JS if they reproduce
all of python standard libraries.  that would be a _huge_ bloat for
the browser.

-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can't get m2m_changed signal working

2010-09-14 Thread Jason
Not sure it'll help but I've always used the 'sender' kwarg (I've used
it a total of once to be fair):

for example:

m2m_changed.connect(update_answer_set_num_answers,
sender=AnswerSet.answers.through)

On Sep 14, 11:43 am, allyb  wrote:
> hi,
>
> yes, it is called in models.py, and no, it's not indented and neither
> is the handler function.
>
> On Sep 14, 4:28 pm, Jason  wrote:
>
> > Is the m2m_changed() call in the models.py?
>
> > Also, it looks indented - if it is, it shouldn't be - in other words -
> > it doesn't belong to the model.
>
> > On Sep 13, 1:27 pm, allyb  wrote:
>
> > > I'm finding it difficult to denormalise a field in a django model. I
> > > have:
>
> > >     class AnswerSet(models.Model):
> > >         title = models.CharField(max_length=255)
> > >         num_answers = models.PositiveIntegerField(editable=False,
> > > default=0)
> > >         answers = models.ManyToManyField(Answer,
> > > through='AnswerSetAnswer')
> > >         ...
>
> > >     class AnswerSetAnswer(models.Model):
> > >         answer = models.ForeignKey(Answer)
> > >         answer_set = models.ForeignKey(AnswerSet)
> > >         ...
>
> > > I want num_answers to contain a count of the number of answers in the
> > > set.
>
> > > If 5 answers are initially associated with the AnswerSet "Food" and I
> > > edit one so it becomes associated with the AnswerSet "Colours", how
> > > can I recalculate the number of answers in the AnswerSet with "Food"?
> > > All the signals only seem to send the new data so I can't just
> > > override the save method.
>
> > > I've tried using the m2m_changed signal, but it never gets called when
> > > I edit relationships through the admin form.
>
> > > Here's my code anyway:
>
> > >     def update_answer_set_num_answers(sender, **kwargs):
> > >         """
> > >         Updates the num_answers field to reflect the number of answers
> > >         associated with this AnswerSet
> > >         """
> > >         print "hello"                                              #
> > > never gets here
> > >         instance = kwargs.get('instance', False)
>
> > >         print "no instance"
>
> > >         if not instance:
> > >             return
>
> > >         action = kwargs.get('action')
>
> > >         print "action: ", action
>
> > >         if (action != 'pre_remove' and action != 'pre_add' and action !
> > > = 'clear'):
> > >             return
>
> > >         reverse = kwargs.get('reverse')
>
> > >         if reverse:
> > >             answer_set = instance.answer_set
> > >         else:
> > >             answer_set = instance.answer_set
> > >         num_answers =
> > > AnswerSetAnswer.objects.filter(answer_set=answer_set.id).count()
>
> > >         if (action == 'pre_remove'):
> > >             num_answers -= int(kwargs.get('pk_set'))
> > >         elif (action == 'pre_add'):
> > >             num_answers += int(kwargs.get('pk_set'))
> > >         elif (action == 'clear'):
> > >             num_answers = 0
>
> > >         answer_set.num_answers = num_answers
>
> > >         print 'n a: ', answer_set.num_answers
> > >         answer_set.save()
>
> > >     m2m_changed.connect(update_answer_set_num_answers, \
> > >       AnswerSet.answers.through)
>
> > > Setting weak=False or weak=True makes no difference.
>
> > > How can I get the signal to work?
>
> > > Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



haystack problem - already registered error

2010-09-14 Thread Kenneth Gonsalves
hi,

I have installed haystack with xapian backend. My relevant code is like
this:

import haystack
haystack.autodiscover()

from haystack.indexes import *
from haystack import site
from web.models import Stock

class StockIndex(RealTimeSearchIndex):
text = CharField(document=True, use_template=True)

stockist = CharField(model_attr='stockist')
location = CharField(model_attr='location')

def get_queryset(self):
return Stock.objects.all()

site.register(Stock, StockIndex)

but on runserver (python2.6, django-trunk, fedora12):

[law...@xlquest clearplus]$ python manage.py
runserver  
Traceback (most recent call
last):  

  File "manage.py", line 11, in


execute_manager(settings)   

  File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 438, in execute_manager  

utility.execute()   

  File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 379, in execute  

self.fetch_command(subcommand).run_from_argv(self.argv) 

  File
"/usr/lib/python2.6/site-packages/django/core/management/base.py", line
191, in run_from_argv
self.execute(*args, **options.__dict__)
  File
"/usr/lib/python2.6/site-packages/django/core/management/base.py", line
209, in execute
translation.activate('en-us')
  File
"/usr/lib/python2.6/site-packages/django/utils/translation/__init__.py",
line 66, in activate
return real_activate(language)
  File "/usr/lib/python2.6/site-packages/django/utils/functional.py",
line 55, in _curried
return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
  File
"/usr/lib/python2.6/site-packages/django/utils/translation/__init__.py",
line 36, in delayed_loader
return getattr(trans, real_name)(*args, **kwargs)
  File
"/usr/lib/python2.6/site-packages/django/utils/translation/trans_real.py", line 
193, in activate
_active[currentThread()] = translation(language)
  File
"/usr/lib/python2.6/site-packages/django/utils/translation/trans_real.py", line 
176, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File
"/usr/lib/python2.6/site-packages/django/utils/translation/trans_real.py", line 
159, in _fetch
app = import_module(appname)
  File "/usr/lib/python2.6/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
  File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line
124, in 
handle_registrations()
  File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line
121, in handle_registrations
search_sites_conf = __import__(settings.HAYSTACK_SITECONF)
  File "/home/lawgon/clearplus/web/search_indexes.py", line 17, in

site.register(Stock, StockIndex)
  File "/usr/lib/python2.6/site-packages/haystack/sites.py", line 45, in
register
raise AlreadyRegistered('The model %s is already registered' %
model.__class__)
haystack.exceptions.AlreadyRegistered: The model  is already registered

-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: contrib.comments, admin section [unable to see comments]

2010-09-14 Thread Karen Tracey
On Tue, Sep 14, 2010 at 12:52 PM, Nick <
iregisteratwebsiteswitht...@gmail.com> wrote:

> Hello,
>
> I tried to troubleshoot this with Google and #django on IRC but I'm
> coming up empty. I've been following the practical django projects
> second edition book using django 1.2.3 on a local server.
>
> I have added 'django.contrib.comments' to my settings file + adjusted
> my urls.py file just like the book said and ran syncdb. The admin
> section is picking up the comments "model" fine. I can post comments
> fine and they are visible within the post, great.
>
> When I goto the admin section and click comments, then click comments
> again I'm presented with what should be a page to allow me to see the
> available comments and admin them (edit, delete, etc.). The issue is
> that the rows are empty for each comment. Instead it just gives me a
> count of the number of comments which makes it impossible to manage
> the comments.
>
> Here is a screenshot:
>  http://i51.tinypic.com/awfjes.jpg
>
> The URL is: http://localhost:8080/admin/comments/comment/ (I'm
> developing it locally obviously)
>
> Someone on IRC said this might actually be a bug but I can't imagine
> it's a bug. I mean, this is a serious issue and surely would have been
> found before releasing this build to the public.
>
> My admin templates are unmodified too so it's not that.
>
> What the heck is going on?
>
>
When I have seen this type of thing before, it has been due to some invalid
data in the database, see for example:
http://code.djangoproject.com/ticket/11460.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: contrib.comments, admin section [unable to see comments]

2010-09-14 Thread Nick
Thank you Karen, I never would have thought to look for something like
this.

Here's the situation though, there was invalid data however it's
related to contrib.comments due to how contrib.comments is structured.

My comments were displaying perfectly fine in the threads they
belonged to (not in the admin). They were pointing to the correct PKs
and all of the data was there. The problem is contrib.comments has a
"site_id" column which defaults to 1 but I didn't have contrib.sites
setup or installed (didn't feel it was necessary).

After I installed contrib.sites then it works as intended after adding
a site. I tried to set the site_id to 0 before installing
contrib.sites but that didn't fix it (random shot in the dark :D).

Perhaps contrib.comments depending on contrib.sites is a design flaw /
issue, especially with it not being documented. I'm a Django newbie
(I've been watching djangocon videos, reading community sites, reading
books, poking around the documentation in small doses) but after using
Django for only a few hours I'm already scared. Stuff like this which
can't really be Googled successfully is a newbie's worst nightmare.

On Sep 14, 8:19 pm, Karen Tracey  wrote:
> On Tue, Sep 14, 2010 at 12:52 PM, Nick <
>
>
>
>
>
> iregisteratwebsiteswitht...@gmail.com> wrote:
> > Hello,
>
> > I tried to troubleshoot this with Google and #django on IRC but I'm
> > coming up empty. I've been following the practical django projects
> > second edition book using django 1.2.3 on a local server.
>
> > I have added 'django.contrib.comments' to my settings file + adjusted
> > my urls.py file just like the book said and ran syncdb. The admin
> > section is picking up the comments "model" fine. I can post comments
> > fine and they are visible within the post, great.
>
> > When I goto the admin section and click comments, then click comments
> > again I'm presented with what should be a page to allow me to see the
> > available comments and admin them (edit, delete, etc.). The issue is
> > that the rows are empty for each comment. Instead it just gives me a
> > count of the number of comments which makes it impossible to manage
> > the comments.
>
> > Here is a screenshot:
> >  http://i51.tinypic.com/awfjes.jpg
>
> > The URL is:http://localhost:8080/admin/comments/comment/(I'm
> > developing it locally obviously)
>
> > Someone on IRC said this might actually be a bug but I can't imagine
> > it's a bug. I mean, this is a serious issue and surely would have been
> > found before releasing this build to the public.
>
> > My admin templates are unmodified too so it's not that.
>
> > What the heck is going on?
>
> When I have seen this type of thing before, it has been due to some invalid
> data in the database, see for 
> example:http://code.djangoproject.com/ticket/11460.
>
> Karen
> --http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Overriding queryset for admin.ModelAdmin

2010-09-14 Thread Brandon Taylor
The solution is to add the foreign key field as a list_filter, then
Django will accept the querystring parameter.

Hope that helps someone!

On Sep 13, 7:29 pm, Brandon Taylor  wrote:
> Hi everyone,
>
> I have a very strange problem I'm trying to get a handle on. I need to
> filter a model admin with a value from the querystring, so I am doing
> an override of queryset in my ModelAdmin like so:
>
> def queryset(self, request):
>     id = request.GET.get('id', None)
>     if id:
>         return BidLocationGroup.objects.filter(bid__pk=id)
>     else:
>         return BidLocationGroup.objects.all()
>
> When I watch the development server in Terminal and print out the
> variable "id", here's what I see:
>
> [13/Sep/2010 19:20:10] "GET /admin/bids/bidlocationgroup/ HTTP/1.1"
> 200 3292
> [13/Sep/2010 19:20:10] "GET /static/js/jquery-1.4.2.min.js HTTP/1.1"
> 200 72174
> [13/Sep/2010 19:20:10] "GET /static/js/admin_shared.js HTTP/1.1" 200
> 1239
> [13/Sep/2010 19:20:10] "GET /static/js/parseuri.js HTTP/1.1" 200 1055
> [13/Sep/2010 19:20:10] "GET /static/css/custom_admin.css HTTP/1.1" 200
> 1657
> bid_id: 19
> [13/Sep/2010 19:20:16] "GET /admin/bids/bidlocationgroup/?bid_id=19
> HTTP/1.1" 302 0
> bid_id: None
> [13/Sep/2010 19:20:16] "GET /admin/bids/bidlocationgroup/?e=1 HTTP/
> 1.1" 200 3292
>
> What the hell?! Why is passing in a parameter causing a redirect? How
> can I prevent this from happening?
>
> TIA,
> Brandon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Need to access fieldsets for custom model admin from ModelForm

2010-09-14 Thread Brandon Taylor
Hi everyone,

I need to add a checkbox field to an ModelForm, which is easy enough
by overriding __init__ on the ModelForm, but I'm also using a custom
fieldset on the ModelAdmin.

So, I need to be able to add the field to the fieldset from the form's
__init__

Possible? I'm not sure how I can get to the ModelAdmin through the
Model...

#my forms.py
class BidAdminForm(forms.ModelForm):
class Meta:
model = Bid

def __init__(self, *args, **kwargs):
super(BidAdminForm, self).__init__(*args, **kwargs)
#Only show the inherit checkbox for a new Bid
if not self.instance.id:
self.fields['inherit_entity_location_groups'] =
forms.BooleanField()

...at this point, self.instance will get me to the Bid model, but when
I try to access the model_admin on the instance, I get an
AttributeException.

I'd really appreciate some help!

TIA,
Brandon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Tools to ease template/ui development

2010-09-14 Thread Brandon Taylor
I use Aptana with PyDev and get code completion for Python, HTML, CSS,
JavaScript (and jQuery) and more. It's cross-platform, free and the
Beta 3 version has even more Django support thanks to the latest
version of PyDev.

There are plugins for Git, Mercurial, SVN and more.

Brandon

On Sep 14, 5:38 pm, Javier Guerra Giraldez  wrote:
> On Tue, Sep 14, 2010 at 4:18 PM, pixelcowboy  wrote:
> > I would really love something like pyjamas but that works with jquery
> > or something like that. What I would really love is to forget every
> > other programming language and just use python everywhere. Wouldn't
> > that be sweet?
>
> the problem with pyjamas (and similar 'translators') is that you use
> Python syntax with all the common limitations of JavaScript.  for
> example, in JS you use 'objects' for dicts, and they can only use
> strings for keys.  another one: when i first tried it, it didn't
> support yield(), so many built-in iterators just didn't work.  i guess
> it has improved, but you could only forget about JS if they reproduce
> all of python standard libraries.  that would be a _huge_ bloat for
> the browser.
>
> --
> Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Prepopulating fields from parent, or related models, in the admin

2010-09-14 Thread pixelcowboy
Im not sure Im getting this properly. In the example above, how would
you know what the word "whatever", the query value, stands for? How
could you keep it dynamic in that the values of that field is taken
from whatever the actual parent object is? Thanks.


On Sep 14, 2:34 pm, pixelcowboy  wrote:
> I'll try when I get home, but thanks again for your help!
>
> On Sep 14, 11:31 am, "nick.l...@gmail.com" 
> wrote:
>
>
>
> > Hi again! :)
>
> > I haven't thought this idea through, and very well could be
> > wildly inefficient! :)
>
> > Though in your admin.py when registering the admin model do something like
> > this:
>
> > from myproject.myapp.models import MyModel, OtherModel
>
> > class MyModelAdmin(models.admin):
> >     object_i_want = OtherModel.objects.get(field_i_care_about=whatever)
> >     prepopulated_fields = { "field_i_care_about":
> > (object_i_want.field_i_care_about)
>
> > admin.site.register(MyModel, MyModelAdmin)
>
> > On Tue, Sep 14, 2010 at 3:59 PM, pixelcowboy wrote:
>
> > > Hi, I want a project structure that is as follows:
>
> > > I have an application with project model that has a subproject, and
> > > that subproject has other subproject,etc. What I want to get is that
> > > the subproject gets the same attributes that the parent project, but
> > > is also able to override their values in its own instance (but not in
> > > the parent instance).
>
> > > My first idea is using something like a foreign key. This gives me
> > > access to the parent values, but not the ability to override them.
>
> > > The second option is multi-table inheritance from the parent class.
> > > This gives me the parents class attributes, but I again I dont get the
> > > fields in the admin, so Im not able to override them (at least not in
> > > the admin). Is there any way to this?
>
> > > The third option is to inherit an abstract class. The parent also
> > > inherits from this class, so both have the fields I need. However, I
> > > would like for the child class to inherit default values for this
> > > fields from the parent class, but be free to override them. Is there
> > > any way to pre-populate fields in the admin with the attribute values
> > > from a parent or related files?
>
> > > Thanks for your help.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com > >  groups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Guadajuko! Vamos a correr!
> >  -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



virtualenv used with mod_wsgi

2010-09-14 Thread Jagdeep Singh Malhi
I am try to use Multiple version of Django on same machine.
I am using the Virtual Python Environment builder (virtualenv 1.5). I
am able to install this using documentation.
http://pypi.python.org/pypi/virtualenv#downloads

but now i am facing problem with mod-wsgi.
i am not able to understand how mod-wsgi work with virtualenv.
when i try this, it use the same python , not created by virtualenv

file used for virtualenv is:- django.wsgi
{
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'djangocms.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
sys.path.append('/home/jagdeep/')
}

Actually, I want mod-wsgi is working with different version of Django.
Now, what i can do?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: virtualenv used with mod_wsgi

2010-09-14 Thread Colin Bean
Have you tried the steps described here:
http://code.google.com/p/modwsgi/wiki/VirtualEnvironments ?

Colin

On Tue, Sep 14, 2010 at 10:44 PM, Jagdeep Singh Malhi
 wrote:
> I am try to use Multiple version of Django on same machine.
> I am using the Virtual Python Environment builder (virtualenv 1.5). I
> am able to install this using documentation.
> http://pypi.python.org/pypi/virtualenv#downloads
>
> but now i am facing problem with mod-wsgi.
> i am not able to understand how mod-wsgi work with virtualenv.
> when i try this, it use the same python , not created by virtualenv
>
> file used for virtualenv is:- django.wsgi
> {
> import os
> import sys
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'djangocms.settings'
>
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
> sys.path.append('/home/jagdeep/')
> }
>
> Actually, I want mod-wsgi is working with different version of Django.
> Now, what i can do?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.