Re: Custom Admin Form for ManyToMany, missing Green Plus Sign?

2010-02-13 Thread john
Maybe I didnt fully explain the issue, and it seems that Google added a couple of extra lines to the code above. Ive got an app with 2 Model classes. The first one describes a product (the Item model above). The second one (the Stuff model above), along with other data references the Product via

Re: AJAX Autocompletion Field

2010-02-13 Thread Margie Roginski
Hi Jon, I have used this very successfully: http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/ The demo is here: http://loopj.com/tokeninput/demo.html One thing that differentiates it from the jquery autocomplete package is that it allows you to specify multiple

Re: Custom Admin Form for ManyToMany, missing Green Plus Sign?

2010-02-13 Thread Matt Schinckel
On Feb 14, 9:30 am, john wrote: > Hi, I just had fun creating a new Custom Admin Form to sort a > ManyToMany field by ABC order (why isnt it in ABC order by default on > the "def __unicode__" item?)  It works great, but now the Green Plus > Sign to add more items to the

Custom tag within template

2010-02-13 Thread DakotaPete
Hi All - I'm a bit of a newbie with django, but I think I bit off more than I can chew. I'm trying to build a brick wall via html table, tds and colspans: 0. The "bricks" will lay out as follows | -- | 20 | 21 | 22 | - | | 16 | 17 | 18 | 19 | -- | | -- | 12 | 13

Re: Session errors with mod_wsgi

2010-02-13 Thread DavidMck
I've given up. There seems to be an issue with pickling some objects when you're using mod_wsgi - rather than using xlrd, I just attempted to add the uploaded file (small file held in memory) to the session data. The error log was essentially the same, but complaining about an attempt to pickle a

Re: InlineModelAdmin related items on two levels

2010-02-13 Thread Matt Schinckel
Oh, and it is not flawless, there were still some issues I didn't get sorted out. I had some validation errors of some sort, I think, when updating data under certain circumstances, but I never quite completely tracked it down. -- You received this message because you are subscribed to the

Re: InlineModelAdmin related items on two levels

2010-02-13 Thread Matt Schinckel
On Feb 14, 6:19 am, Ogi Vranesic wrote: > Hi all > > I read the very good tutorial > onhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/ > and understood that the admin interface has the ability to edit models on the > same page as a parent model and these are called

Re: Session errors with mod_wsgi

2010-02-13 Thread DavidMck
Hmm: My relevant codes seems to be: @login_required def upload(request): if request.method == "POST": form = ExcelUploadForm(request.POST, request.FILES) if form.is_valid(): request.session['sheet'] = form.cleaned_data["excelfile"] If I put something boring into

Session errors with mod_wsgi

2010-02-13 Thread DavidMck
Alo! Written an app, works fine on dev server, gives a 500 Internal Server Error with apache + mod_wsgi. It's a form to upload an excel file - the file is uploaded, verified (using xlrd) and then one of the excel sheets is saved as session data. Redirect to a "view" page which retrieves the

Re: Django Generator

2010-02-13 Thread Philippe Ombredanne
Brice: Very nice start. There is a long history of similar tools and they all have a place and a purpose. I remember fondly of some tool that generated CRUD dbase apps from a db schema .. that was last century ... So carry on! Just a few notes: - the generator page takes quite a bit of vertcal

Custom Admin Form for ManyToMany, missing Green Plus Sign?

2010-02-13 Thread john
Hi, I just had fun creating a new Custom Admin Form to sort a ManyToMany field by ABC order (why isnt it in ABC order by default on the "def __unicode__" item?) It works great, but now the Green Plus Sign to add more items to the list is missing, where did it go? I guess its not enabled by

Re: dynamic variable in templates

2010-02-13 Thread Daniel Roseman
On Feb 13, 7:20 pm, Madis wrote: > http://push.cx/2007/django-template-tag-for-dictionary-access > > This is basically what I'm looking for but I'm not sure that this is > the best way to do this. Yes, this is the right way to do it. -- DR. -- You received this message

Re: AJAX Autocompletion Field

2010-02-13 Thread Shawn Milochik
I don't know of any cons regarding jQuery, unless the others who you work with or communicate with all use something else. Here's a fully-working example (from which you can easily create yours). It's not exactly a tutorial, but it should be all you need.

Re: Returning array of integers as part of json dump, how to access in Javascript

2010-02-13 Thread Daniel Roseman
Unfortunately your question is not clear, and this "clarification" does not really help matters. As far as I can tell, obj.PythonList is already an array. If you do: jArray = [obj.PythonList] then yes, jArray[0] is indeed the whole contents of obj.PythonList. But I don't understand why you want

Re: AJAX Autocompletion Field

2010-02-13 Thread Sam Walters
There probably isnt a good whole tutorial. Which looks at the operation from client side to server side... You should read about writing your own autocomplete field in JS. And for server side look at writing a view which returns a JSON or list of options which corresponds with the JS / JS

AJAX Autocompletion Field

2010-02-13 Thread Jon Loeliger
Folks, For likely the umpteenth time, can someone recommend a good AJAX auto completion tutorial or example that I might use to crib-together a text-field selection that would otherwise be a very large drop-down selection field? My use case would be essentially like having a table full of say,

nested lists

2010-02-13 Thread Madis
Could someone please explain what kind of a list would make this work: {% for country in countries %} {% for city in country.city_list %} Country #{{ forloop.parentloop.counter }} City #{{ forloop.counter }} {{ city }} {% endfor %} {%

Re: Getting uploaded images to show

2010-02-13 Thread thanos
If your images are uploaded_to='media' I do in my settings.py STATIC_DOC_ROOT = os.path.join(ROOT,'media') ADMIN_MEDIA_PREFIX = '/media/admin/' MEDIA_ROOT = STATIC_DOC_ROOT MEDIA_URL = '/media/' And my urls.py includes this: urlpatterns = patterns('', . . . (r'^admin/media/(?P.*)$',

Re: INSERT INTO "db_model" ("id") VALUES (DEFAULT)

2010-02-13 Thread Petr van Blokland
Hi Karen, I just hoped it would sound like something familiar, to give me a clou for the direction to search. Obviously it isn't. I'll make a scale down of the problem and try to make the question more specific. Regards, Petr van Blokland On Feb 13, 2010, at 7:42 PM, Karen Tracey wrote: > In

Re: dynamic variable in templates

2010-02-13 Thread Madis
http://push.cx/2007/django-template-tag-for-dictionary-access This is basically what I'm looking for but I'm not sure that this is the best way to do this. On Feb 13, 8:55 pm, Madis wrote: > Sorry for not explaining it more: > > chain is a dictionary of lists chains

InlineModelAdmin related items on two levels

2010-02-13 Thread Ogi Vranesic
Hi all I read the very good tutorial on http://docs.djangoproject.com/en/dev/ref/contrib/admin/ and understood that the admin interface has the ability to edit models on the same page as a parent model and these are called inlines. For two related models is this easy: class A (models.Model):

Re: Returning array of integers as part of json dump, how to access in Javascript

2010-02-13 Thread robinne
I put in wrong variable name: > var PIDS = obj.PackageIDS; //this brings back 3,2 for example, an > array of integers. should be... var PIDS = obj.PythonList; On Feb 13, 10:10 am, robinne wrote: > I am trying to pass an array of integers from a view to

Re: Check if django is getting a page from memcache

2010-02-13 Thread Alessandro Ronchi
2010/2/13 Alessandro Ronchi > Thank you. > It seems it's working. > It's strange because some time requests waits 300ms to be processed > (calculated by firefox firebug plugin), and other times (few seconds after) > the same page waits 1.5seconds to begin

Re: dynamic variable in templates

2010-02-13 Thread Madis
Sorry for not explaining it more: chain is a dictionary of lists chains {'project1': ['item1', 'item2'], 'project2': ['item3']} So the key to the dictionary is basically a project name which I get when looping over the projects in the first loop. Now the second loop should be over the list of

Re: dynamic variable in templates

2010-02-13 Thread Karen Tracey
On Sat, Feb 13, 2010 at 1:30 PM, Madis wrote: > I'm trying to write the following but there seems to be no solution on > the web for this. > > In a template: > {% for project in projects %} > {% for chain in chains.project.name %} <--- project.name should be > dynamic > {%

dynamic variable in templates

2010-02-13 Thread Madis
I'm trying to write the following but there seems to be no solution on the web for this. In a template: {% for project in projects %} {% for chain in chains.project.name %} <--- project.name should be dynamic {% endfor %} {% endfor %} -- You received this message because you are subscribed

INSERT INTO "db_model" ("id") VALUES (DEFAULT)

2010-02-13 Thread Karen Tracey
In the future please click the "Switch to copy-and-paste view" and post just the contents of the resulting text box. You started out by saying you had defined a Django model named Element with a couple of fields (CharField name, IntegerField elementtype) and that you got this error when you

Re: Check if django is getting a page from memcache

2010-02-13 Thread Alessandro Ronchi
2010/2/13 Daniel Roseman > On Feb 13, 4:50 pm, Rob Hudson wrote: > > You can telnet to memcached and run the `stats` command. That'll tell > > you overall hits and misses (plus other info). If you're using > > Django's page caching middleware, you'll

Re: Reversing post_change_redirect argument in django.contrib.auth.views.password_change

2010-02-13 Thread Kev Dwyer
On Sat, 13 Feb 2010 13:22:54 +, Kev Dwyer wrote: > Hello List, > > > Does anyone know how I can avoid hardcoding the post_change_redirect > argument to change_password, either in urls.py or perhaps by some > trickery in the template or form? > > Many thanks, > > Kev I've worked around

Returning array of integers as part of json dump, how to access in Javascript

2010-02-13 Thread robinne
I am trying to pass an array of integers from a view to javascript in an ajax call. I know how to return json dump from a View so that javascript can access it as an object like this: VIEW response_dict = {"PythonList": MyList, "EditType": edittype} return

Re: Getting uploaded images to show

2010-02-13 Thread Jon Loeliger
> 2010/2/13 holger : > > I am new to django and I am trying to get an image upload to work. > > > > My media url is > > MEDIA_URL =3D 'http://127.0.0.1:8000/media/' > > > > and my media_root is > > MEDIA_ROOT =3D os.path.join(PROJECT_ROOT, 'media') > > > > where

Re: Check if django is getting a page from memcache

2010-02-13 Thread Daniel Roseman
On Feb 13, 4:50 pm, Rob Hudson wrote: > You can telnet to memcached and run the `stats` command.  That'll tell > you overall hits and misses (plus other info).  If you're using > Django's page caching middleware, you'll see 2 hits per page because > Django caches both headers and

Re: INSERT INTO "db_model" ("id") VALUES (DEFAULT)

2010-02-13 Thread Karen Tracey
On Sat, Feb 13, 2010 at 11:47 AM, Petr van Blokland wrote: > Hi, > I got at question, that may or may not sound familiar and gives me some > direction where to search. > I made a normal model description including > > class Element(models.Model): > name = models.CharField() >

Re: Check if django is getting a page from memcache

2010-02-13 Thread Rob Hudson
You can telnet to memcached and run the `stats` command. That'll tell you overall hits and misses (plus other info). If you're using Django's page caching middleware, you'll see 2 hits per page because Django caches both headers and page content. The page load you should see 2 misses. Then all

Re: INSERT INTO "db_model" ("id") VALUES (DEFAULT)

2010-02-13 Thread Petr van Blokland
Hi, I got at question, that may or may not sound familiar and gives me some direction where to search. I made a normal model description including class Element(models.Model): name = models.CharField() elementtype = models.IntegerField() database connection is ok, filled fields

Django, randomization of “default” parameter of a model

2010-02-13 Thread Hellnar
Hello, I want to set the "default" value as a randomly generated String for the promotion_code part of my Promotion model, for that the code_generate function is used. The issue with the code below that it seems like default=code_generate() generates this random string once every server start

Re: weird request.user problem in view

2010-02-13 Thread Anders Eide
I know. Just a typo in this post. Thanks for trying to help anyway :) the error was in the urls.py /user// /user/page/ When loading /user/page/ /user/ wrote: > On 13 February 2010 13:46, Anders Eide wrote: > > > > > did a stupid PEBCAK i the urls.py file. Works fine now

Re: weird request.user problem in view

2010-02-13 Thread rebus_
On 13 February 2010 13:46, Anders Eide wrote: > did a stupid PEBCAK i the urls.py file. Works fine now > > On Feb 13, 1:33 pm, Anders Eide wrote: >> Why on earth doesn't this user_page view work? Getting "404, No User >> matches the given query." >>

Re: weird request.user problem in view

2010-02-13 Thread Anders Eide
did a stupid PEBCAK i the urls.py file. Works fine now On Feb 13, 1:33 pm, Anders Eide wrote: > Why on earth doesn't this user_page view work? Getting "404, No User > matches the given query." > > from django.contrib.auth.models import User > from django.template import

weird request.user problem in view

2010-02-13 Thread Anders Eide
Why on earth doesn't this user_page view work? Getting "404, No User matches the given query." from django.contrib.auth.models import User from django.template import RequestContext from django.shortcuts import render_to_response, get_object_or_404 def user_page(request): user =

Re: choose database manually per-request

2010-02-13 Thread PDani
Dear Graham, Thanks for the quick answer! Basicly, I would like to handle this problem from the app, so I can't modify the underlying architecture. Your suggestion needs some changes in the apache configuration, I guess. The only thing I have access to is the source of the webapp. Thanks, anyway,

Re: choose database manually per-request

2010-02-13 Thread Graham Dumpleton
On Feb 13, 7:43 am, PDani wrote: > Hi! > > I would like to set up some database servers in Django 1.2, and then > use them in this way: when a new request comes, i choose a server > manually, and then use this ONLY ONE server in that request. I don't > want to pass around

Check if django is getting a page from memcache

2010-02-13 Thread Alessandro Ronchi
I am not sure django is getting a page from memcached. Is there a way to check it? Thanks in advance, -- Alessandro Ronchi http://www.soasi.com SOASI - Sviluppo Software e Sistemi Open Source http://hobbygiochi.com Hobby & Giochi, l'e-commerce del divertimento -- You received this message

Re: Getting uploaded images to show

2010-02-13 Thread Antoni Aloy
Do you have this code in urls.py? if settings.DEBUG: urlpatterns += patterns('', (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root':'./media/'}), ) In DEBUG mode you need such a code to serve static media. 2010/2/13 holger

Django-CMS: Project name prefix in the URL

2010-02-13 Thread Jordan
The problem is that the project name is beeing appended in the URL when using the URL filter. For example, when I use the filter to get the URL of the news page, the filter returns "/project_name/news/", but it should return just "/news/". I have no idea what should I fix that and hope someone

Getting uploaded images to show

2010-02-13 Thread holger
I am new to django and I am trying to get an image upload to work. I am using the admin interface with a ImageField in the model. imagefilename = models.ImageField(upload_to = 'uploads/') My media url is MEDIA_URL = 'http://127.0.0.1:8000/media/' and my media_root is MEDIA_ROOT =

Re: Middleware for models

2010-02-13 Thread pbzRPA
Ok, I think I have sorted out my queryset problem, I wrote a custom manager: class UserBranchModelManager(models.Manager): def for_request(self, request): if settings.DO_BRANCH_FILTER: return super(UserBranchModelManager, self).get_query_set().filter(branch__pk =

Re: can't authenticate in template

2010-02-13 Thread pbzRPA
Just as a suggestion, if you don't need to customize the get_user() method then simply don't have a get_user() method in your custom authentication class. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

validate_generic from PYCON 2007

2010-02-13 Thread stereoit
Hi, while reading http://toys.jacobian.org/presentations/2007/oscon/tutorial/#s67 I see this nice validate_generic(request, formclass), but I am curious how to select proper formclass from the URL request? At the moment I thing of maintaining dictionary of avaliable forms and its corresponding

Re: Middleware for models

2010-02-13 Thread pbzRPA
Sorry one more thing, the above filters my querysets but then comes the get() method on each model. I use urls with pk's so a user could just try to change the url to a pk that does not belong to them and view it. To filter this out I run yet another function: def

Re: Middleware for models

2010-02-13 Thread pbzRPA
Just so you have an idea what I am trying to do. :) I have a custom middleware that adds a userBranchID variable to each request according to the users branch in the User model. Now in each view when I use any queryset I have to do the following: def filter_branch(request, queryset): if

Re: Inline Admin and ForeignKey

2010-02-13 Thread derek
class EventInline(admin.TabularInline): model = Event extra = 1 will only show one extra event (the next "empty" one, if you like). On Jan 11, 4:11 pm, Igor wrote: > Thanks, you're right... was posting this late at night while > experimenting and copied the

Re: Middleware for models

2010-02-13 Thread pbzRPA
Hi Shawn, I use Managers often to limit my querysets and add additional fields that I want dynamically calculated using sql. I just don't see how I can get the request object to the models.Manager so it knows what to filter by (user.uid). :( I know I could do a filter in each view

Re: admin url name

2010-02-13 Thread Umapathy S
On Sat, Feb 13, 2010 at 4:43 AM, Karen Tracey wrote: > On Fri, Feb 12, 2010 at 4:34 PM, Umapathy S wrote: > I don't know how to get this working on the level of code you have. To do > it with 1.1 or higher, you'd want to reverse admin:index, as documented

Re: can't authenticate in template

2010-02-13 Thread pbzRPA
On Feb 13, 2:23 am, paul wrote: > On Feb 12, 5:03 pm, pbzRPA wrote: > > > The middleware looks good. Is your browser maybe not blocking cookies? > > I have really though hard about it, but without code it's really > > difficult to get a picture of where