Django Standalone Template

2011-10-28 Thread Stefan Lisowski
Hi Django folks - I'm new to Django, and I just want to use the template system now, independent of the rest of Django. But I can't get it to see a template. Even the system templates as was suggested when I started Googling for my error. >>> import django.template >>>

CacheMiddleware with generation-style caching

2011-10-28 Thread jonathan
Hi all, I'm trying to implement a generation-style caching system with django [1]. I found django-jimmypage [2] which implements an alternative version of @cache_page, and it uses johnny-cache [3] for an "infinite" cache timeout. However, most of the code in django-jimmypage appears quite

Re: Comparing two ManyToMany fields for same entries

2011-10-28 Thread Brett Epps
I'm going to guess that my version is slow since a new query would be run for each row returned by the initial one. Check out an app called django-debug-toolbar. It has a view that will show you all of the SQL queries generated as a page is built. It will also tell you how long each query took

Re: update other objects when saving an object:

2011-10-28 Thread Tim
Hi Brian, That helps indeed! The code is working now; seems like I need to work on the logic, but now I'm getting somewhere. thanks, --Tim -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Admin Custom Template

2011-10-28 Thread Vishnu vg
Hi Django guys, I want to customize an admin form. I heard that we can customize django admin template by putting template file called template change_list.html in template folder. My model is like this cms.model.application. So for the application model how can i create custom templates in

Re: Comparing two ManyToMany fields for same entries

2011-10-28 Thread Kevin
I think the filter I used does work to detect related friends, here is a Pythonic example of the same code, but done differently without filters: Person.objects.get(name='Person1').friends.get().friends.all() Instead of returning back 'Person1', when using filters, this returns back 'Person0'.

Re: Comparing two ManyToMany fields for same entries

2011-10-28 Thread Kevin
Thanks. Is this way good for database optimization though? I guess I could use select_related(). I was hoping there was a QuerySet I could run. I made this one, although I'm not sure if it works correctly: Person.objects.filter(name='Person1').filter(friends__friends__name='Person0') This

Re: update other objects when saving an object:

2011-10-28 Thread Brett Epps
Hi Tim, The problem is your use of the self keyword when trying to get at the ChapterMembership manager. Instead of: chapters = self.objects.filter… Try: chapters = ChapterMembership.objects.filter… Hope that helps, Brett From: Tim >

Re: Comparing two ManyToMany fields for same entries

2011-10-28 Thread Brett Epps
Try this: for friendof0 in Person0.friends.all(): for friendof1 in Person1.friends.all(): if friendof0 == friendof1: # Person 0 and Person 1 share a friend. else: # They have no shared friends. Brett On 10/28/11 12:59 PM, "Kevin"

Re: Long usernames in auth_user?

2011-10-28 Thread Ian Clelland
On Wed, Oct 26, 2011 at 3:00 PM, Kurtis Mullins wrote: > Check out userena as well. But a custom authentication back-end was the > approach I originally took. And to answer your question, yes -- your chances > of finding people w/ email addresses longer than 75 chars are

How to load data to auth_permissions from initial_data.json when the auth_groups is also loaded from fixture?

2011-10-28 Thread ycseattle
Hi, In my application, I have fixed groups (like admin, staff, subscribers) etc, and this data in auth_groups is not intended to change in the program, so I am loading them in initial_data.json. I also want to load data into auth_group_permissions as the application is not expected to change

Re: Comparing two ManyToMany fields for same entries

2011-10-28 Thread Kevin
Just thought I'd add another example using Python script: Person0 = Person() Person1 = Person() Person2 = Person() Person0.friends.add(Person2) Person2.friends.add(Person0) Person2.friends.add(Person1) Person1.friends.add(Person2) Now, I would like to do the following, but it seems to fail:

Re: No module named django after upgrade to os x Lion

2011-10-28 Thread Kurtis
Okay, I think I've got the exact steps down needed to get this running right. If these are actually it, I'm not sure if I had any other prerequisites I can't think of at the moment, then it's a matter of copying and pasting 3 lines into your terminal. (Less than 5-10 minutes total) 1. Install

Re: Database management commands

2011-10-28 Thread Ian Clelland
On Fri, Oct 28, 2011 at 2:35 AM, Daniele Procida wrote: > COuld it still be the case that the issue is the result of the older Django > database having used one engine by default, and the new one the other? > > That is possible -- in a MySQL shell, run "SHOW TABLE STATUS", and

Comparing two ManyToMany fields for same entries

2011-10-28 Thread Kevin
Hello, I am building a model which shares a relation with another model using a ManyToManyField. What I need to do, is find out which models are on both on two seperate ManyToManyField lists. Here is a simple example of what I am trying to do: Person: friends=ManyToManyField(self) To find

update other objects when saving an object:

2011-10-28 Thread Tim
Hi, I've modeled a Book that has Chapters, with each Chapter having an ordering 'sequence'. So when someone decides the first chapter in the book should become the third, they can just change the sequence number. That's fine, but when that happens, I want the other chapters to automatically

Re: Help in adding jQuery to my pages

2011-10-28 Thread Andre Terra
Oh, that's right! Too often I miss the closing );, especially when *reading* code. It's very unfortunate javascript didn't have someone like Guido van Rossum as BDFL. Life for web developers would surely be easier if it too were developed with "be as readable as English" as a goal. Glad to know

Re: No module named django after upgrade to os x Lion

2011-10-28 Thread creecode
Hello Angelika, On Friday, October 28, 2011 2:13:20 AM UTC-7, angelika wrote: creecode, I tried the commands you suggested first. No matter which > version I switched to, it still said No module named django, which > seems weird but there it is. If your curious about where the old Django

Re: No module named django after upgrade to os x Lion

2011-10-28 Thread angelika
Alright, I'm gonna give PostgreSQL a try over the weekend, I'll let you know how it works out. Thanks, guys! /Angelika On Oct 28, 12:49 pm, Kurtis Mullins wrote: > I'd give PostgreSQL a shot and see if it magically works for you. It's an > awesome database. If you have

Re: Help in adding jQuery to my pages

2011-10-28 Thread Leonardo Giordani
Sorry Andy and thank for your patience, as I though the problem is simply simply bad JQuery. $(document).ready(function() { $('li').addClass("active"); } what about some ");" to close statements? Thanks 2011/10/28 Andre Terra : > I'm sorry if I'm not understanding

Re: Help in adding jQuery to my pages

2011-10-28 Thread Leonardo Giordani
You are right, sorry. jQuery is loaded, I can see it in Firefox and in Firebug. If I write this statement $(document).ready(function() { } in a working JS file, that file stops working, can be reached through Firefox (it is loaded) but not by Firebug. 2011/10/28 Andre Terra

Re: Help in adding jQuery to my pages

2011-10-28 Thread Andre Terra
I'm sorry if I'm not understanding you, but regarding 2 and 3, if jQuery isn't being loaded, shouldn't you be getting a 404 error for the jquery-1.6.4.js file? Cheers, AT On Fri, Oct 28, 2011 at 11:30 AM, Leonardo Giordani < giordani.leona...@gmail.com> wrote: > Hi, thank you for your detailed

Re: Help in adding jQuery to my pages

2011-10-28 Thread Leonardo Giordani
Hi, thank you for your detailed answer. 1. I'm on Django 1.3 (1.3.0-final). I'll take a look at staticfiles for sure, thanks. 2. I'm getting no errors at all, other JS files in that directory load perfectly. Firefox can reach them in source view. 3. I'll try it, but it seems to me strange not

Re: Help in adding jQuery to my pages

2011-10-28 Thread Andre Terra
Hello, Leonardo First, which django version are you using? I recommend using the contrib staticfiles app to handle your static files [1]. Once you get the hang of it, it will pay off. Second, see that you aren't getting 404 errors in the js URL. Using the dev server, you can easily read through

Help in adding jQuery to my pages

2011-10-28 Thread Leonardo Giordani
Hi all, I'm trying to add a bit of jQuery to a page in a Django site. It seems that my jQuery scripts are simply not loaded, while JS scripts work perfectly. Evan Firebug does not see the jQuery file as loaded. This is what I do in base.html                            {% block javascript %}{%

Re: create object instance with ManyToManyField

2011-10-28 Thread Leonardo Giordani
The add() method of a ManyToMany field adds the indexes of the given objects to the field. If you add a list, each index in the list is added to the field. In the admin interface, when you edit a Company object, you see a convenient automagically-created menu which lists all Index object in your

changelist_view

2011-10-28 Thread kichawa
How can i call changelist_view from my_app.views ? I'd like to save the render html into the datebase. i need sth like that: http://paste.ofcode.org/MVDJR2RhjnNL5QCBDVK3w6 -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

Re: Django inline admin max_num, extra not working

2011-10-28 Thread Jose
Hi Tom, Thanks for your reply. Yes I want to have just one user profile. And yes I have tried both OneToOne field and ForeignKey with unique=True but it makes no difference in both cases I have this problem Regards, José On Oct 28, 11:41 am, Tom Evans wrote: > On

Re: create object instance with ManyToManyField

2011-10-28 Thread Jaroslav Dobrek
Hello Leonardo, thanks your your answer. > n = Company(name=my_name, country=my_country, isin=my_isin) > n.save() > n.indices.add(my_indices) This causes that the company object has all indices in my_indices (such as Dow Jones S 100, Dax, ...) as *choices*. I.e. someone who manipulates these

Re: CBV "Router"

2011-10-28 Thread Kurtis Mullins
Nevermind! Thanks to FunkyBob, I have a solution. I didn't realize you could do this so easily, so I'll share it with others. # views.py def my_router(request): view = MyCBV.as_view(template_name = 'foo.html') return view(request) Of course, I actually have logic in my function -- but

CBV "Router"

2011-10-28 Thread Kurtis
Hey Guys, I'm trying to create a "router" as recommended in IRC for several different views. My Views are UpdateViews, so they are the new CBVs. I don't mind my router being a simple function based view, though. Basically, a User can edit some data. This data changes based upon the user's

Re: No module named django after upgrade to os x Lion

2011-10-28 Thread Kurtis Mullins
I'd give PostgreSQL a shot and see if it magically works for you. It's an awesome database. If you have any problems with it though, here's the "easy way out" I took. I just installed Mac Ports and never had another problem. Of course, you'll have to make sure you're using the Mac Ports tools you

Re: Model Inheritance and ModelForms

2011-10-28 Thread Tom Evans
On Fri, Oct 28, 2011 at 7:50 AM, Alex wrote: > I've been scouring Google and the Django documentation and I can't > figure out how to do this. I'm working on an inventory management > system for my shop. My inventory models.py similar to the following: > >    class ItemType(

Re: No module named django after upgrade to os x Lion

2011-10-28 Thread Andre Terra
PostgreSQL is great, you will have no regrets! Cheers, AT On Fri, Oct 28, 2011 at 6:13 AM, angelika wrote: > Thank you all for your help and suggestions. Last time I installed > Django it took a full two days and I was nearly in tears at the end. > Most of the time

Re: Django inline admin max_num, extra not working

2011-10-28 Thread Tom Evans
On Fri, Oct 28, 2011 at 9:47 AM, Jose wrote: > I have extended the User model as explained here and in many other > sites. > > However, when defining the User Profile Inline in admin.py, no matter > what values I use for max_num or extra, in the admin site it will > always show

Re: Database management commands

2011-10-28 Thread Daniele Procida
On Fri, Oct 28, 2011, Russell Keith-Magee wrote: >On Fri, Oct 28, 2011 at 12:49 AM, Leonardo Giordani > wrote: >> This is a problem related to Innodb and MyISAM. Django uses this >> latter, > >Incorrect. Django doesn't have any built in

Re: No module named django after upgrade to os x Lion

2011-10-28 Thread angelika
Thank you all for your help and suggestions. Last time I installed Django it took a full two days and I was nearly in tears at the end. Most of the time was spend trying to solve the problems that Kurtis is talking about, with the MySQLdb package. Although I am usually not a person who takes

Django inline admin max_num, extra not working

2011-10-28 Thread Jose
I have extended the User model as explained here and in many other sites. However, when defining the User Profile Inline in admin.py, no matter what values I use for max_num or extra, in the admin site it will always show one inline for the user profile I have already created and another blank

Model Inheritance and ModelForms

2011-10-28 Thread Alex
I've been scouring Google and the Django documentation and I can't figure out how to do this. I'm working on an inventory management system for my shop. My inventory models.py similar to the following: class ItemType( models.Model ): def __unicode__( self ): return "blah

Re: Database management commands

2011-10-28 Thread Leonardo Giordani
You are right, thanks. 2011/10/28 Russell Keith-Magee : > On Fri, Oct 28, 2011 at 12:49 AM, Leonardo Giordani > wrote: >> This is a problem related to Innodb and MyISAM. Django uses this >> latter, > > Incorrect. Django doesn't have any built