Re: modwsgi on suburl
my bad :). didn't really get his gist. just switched to wsgi myself. On Nov 25, 11:00 pm, Graham Dumpleton <graham.dumple...@gmail.com> wrote: > On Nov 26, 5:04 pm, Some Guy <djul...@gmail.com> wrote: > > > WSGIScriptAlias /test > > > should be > > > WSGIScriptAlias / > > > not really sure what you mean by suburl... > > No it shouldn't. What he was doing with the directive is correct. > > Provided they are using 1.0 or later, urls.py should be setup the same > as if site mounted at root URL. That is, do not put the suburl in > urls.py. > > So, can't see anything wrong with what OP was doing. > > Graham > > > > > On Nov 25, 9:47 pm, Amit Sethi <amit.pureene...@gmail.com> wrote: > > > > Hi , can somebody tell me how i should configure mod_wsgi on a suburl I > > > want > > > to set a django project on > > > > domain.com/test/ > > > > so my urls.py at present looks like : > > > > urlpatterns = patterns('', > > > (r'^(.*)', 'sttp.views.serve'),) > > > > and the wgi scrip alias is WSGIScriptAlias /test > > > /home/amit/sttp-project/django.wsgi > > > > -- > > > A-M-I-T S|S -- 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: modelformset and pagination?
well, I've looked into it more, and it seems that the max_num argument to the modelformset_factory constructor is the best way to go. If it works i'll post it here for those who might find this thread from google. On Nov 25, 8:46 pm, Some Guy <djul...@gmail.com> wrote: > I'm having an issue trying to create pagination with a modelformset. > so far I have... > > SubFormSet = modelformset_factory(Submission, can_delete=True, > extra=0, form=PricingForm) > ... > objs = Submission.objects.all() > formset = SubFormSet(queryset=objs) <-overriding the basic > queryset > groups = map(None, objs, formset.forms) <- I need both the objects > and the forms, iterating over them together in the view > paginator = Paginator(groups, 10) <-- standard paginator > this_page = paginator.page(ppage) > ...then render > > so, basically, this works for viewing, but submitting doesn't work > because the management form values (INITIAL_FORMS, FORM_COUNT, etc) > are wrong, they still hold the values of the whole queryset. I tried > feeding the formset constructor the object_list from the paginiator, > but that fails, complaining about "is_ordered" not being there.So my > considerations are to... > > 1.Change the management form values with js (scary at best) > 2.Slice the queryset (seems like i'd have to duplicate all the > pagination in my code) > 3.Try to overwrite the management_form values directly. > 4.Set the max_num attribute of the model_formset > 5.beg for help on the mailing list. :) > > Anyone have any guidance as to which might be best option? Anyone ever > done this? > TIA -- 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: modwsgi on suburl
WSGIScriptAlias /test should be WSGIScriptAlias / not really sure what you mean by suburl... On Nov 25, 9:47 pm, Amit Sethiwrote: > Hi , can somebody tell me how i should configure mod_wsgi on a suburl I want > to set a django project on > > domain.com/test/ > > so my urls.py at present looks like : > > urlpatterns = patterns('', > (r'^(.*)', 'sttp.views.serve'),) > > and the wgi scrip alias is WSGIScriptAlias /test > /home/amit/sttp-project/django.wsgi > > -- > A-M-I-T S|S -- 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.
modelformset and pagination?
I'm having an issue trying to create pagination with a modelformset. so far I have... SubFormSet = modelformset_factory(Submission, can_delete=True, extra=0, form=PricingForm) ... objs = Submission.objects.all() formset = SubFormSet(queryset=objs) <-overriding the basic queryset groups = map(None, objs, formset.forms) <- I need both the objects and the forms, iterating over them together in the view paginator = Paginator(groups, 10) <-- standard paginator this_page = paginator.page(ppage) ...then render so, basically, this works for viewing, but submitting doesn't work because the management form values (INITIAL_FORMS, FORM_COUNT, etc) are wrong, they still hold the values of the whole queryset. I tried feeding the formset constructor the object_list from the paginiator, but that fails, complaining about "is_ordered" not being there.So my considerations are to... 1.Change the management form values with js (scary at best) 2.Slice the queryset (seems like i'd have to duplicate all the pagination in my code) 3.Try to overwrite the management_form values directly. 4.Set the max_num attribute of the model_formset 5.beg for help on the mailing list. :) Anyone have any guidance as to which might be best option? Anyone ever done this? TIA -- 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: postgresql errors (works in sqlite)
gah, after a few hours of fighting with postgres, I missed that somehow, duh. I thought I had made it an int, sqlite3 was fixing it for me. thanks for the reply. On Nov 23, 10:35 am, Bill Freeman <ke1g...@gmail.com> wrote: > counts[i] = Submission.objects.all().filter(status__exact=str(i)).count() > > If you really intended status to be an integer, you might prefer to alter > your table to make the column the right type. The alter table command > required is beyond my sql confidence. > > Older postgresql and lots of other databases will automatically cast > things that look like integers to integers if needed for comparison, > but newer postgresql, and probably others, in time, require you to > say what you mean, and this is probably a (tm) good thing, in that > the automatic casting hides subtle bugs that are hard to find. > > Or you could downgrade postgresql if you like. But eventually you're > likely to want some new feature, so fixing your column seems to me > the right thing. > > Bill > > > > On Mon, Nov 23, 2009 at 1:17 PM, Some Guy <djul...@gmail.com> wrote: > > Hi, > > I was switching from sqlite3 to postgres, the data was imported ok. > > But now certain view queries are failing. i.e. > > > counts[i] = Submission.objects.all().filter(status__exact=i).count() > > > fails with ... > > > File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py", > > line 2369, in execute_sql > > cursor.execute(sql, params) > > > ProgrammingError: operator does not exist: character varying = integer > > LINE 1: ...ons_submission" WHERE "submissions_submission"."status" = > > 0 > > ^ > > HINT: No operator matches the given name and argument type(s). You > > might need to add explicit type casts. > > > using postgres 8.3. any advise would help. including up/downgrading > > postgres (seems to be a lot of issues on the trac, is 8.3 even > > supported?) > > > -- > > > 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 > > athttp://groups.google.com/group/django-users?hl=. -- 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=.
postgresql errors (works in sqlite)
Hi, I was switching from sqlite3 to postgres, the data was imported ok. But now certain view queries are failing. i.e. counts[i] = Submission.objects.all().filter(status__exact=i).count() fails with ... File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py", line 2369, in execute_sql cursor.execute(sql, params) ProgrammingError: operator does not exist: character varying = integer LINE 1: ...ons_submission" WHERE "submissions_submission"."status" = 0 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. using postgres 8.3. any advise would help. including up/downgrading postgres (seems to be a lot of issues on the trac, is 8.3 even supported?) -- 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=.
generator function for repetitive model fields?
Hi, Is there any functionality, or possibility, to generate many fields in a model file that are all identical and follow an easy (repetitive) naming convention? i.e. locations = (loc1, loc2, lo3) places = (place2, place2) for l in locations: for p in places: l + p + _has_been_checked = models.BooleanField(...) right now I"m just running this kind of thing in a shell and copy/ pasting. Any ideas how this could work? Manager methods maybe? TIA -- 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=.
where to place import statements
Hi group, I was wondering about how to structure my import statements and it's impact, if any, on the memory footprint of mod_python. I'm importing some modules that i'm sure are huge in memory for certain views. My question is: does it make any difference whether I put the import statement at the top of views.py or inside the view that needs the module. I.e. def foo: import huge module -or- import huge module #<-- at the top of views.py My mod_python instances are using a lot of memory (it seems to me), does the placement of imports make a difference? the view that needs the huge module doesn't get called very often, btw. TIA for any clarification. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
project with 2 apps. mod_python cannot find view functions in one app
Hi, I have a project that's working fine (apache2/mod_python) I wrote a new app to add to it, which works fine with dev server. In my root urls.py I added the urls.py from the new app with an include ( (r'^inventory/', include('stuff.retail.urls') ), ('retail' being the new app) I also added stuff.retail to INSTALLED_APPS. Works fine on dev server, but on deployment with apache2, the URI gives an error Exception Type: ViewDoesNotExist Exception Value: Could not import retail.views. Error was: No module named retail.views I haven't changed apache config at all, but the new app is in the same dir as existing project, so I didn't think I'd need to. I'm confused because it is reading retail/urls.py (in the same dir as views.py) to get the right view. But when calling the view (retail/ views.py) it can't find it Any thoughts? Too vague on info? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: problem: TemplateDoesNotExist at /admin/ (linux)
If you're not using the development server (python manage.py runserver), make sure that you have set a template_dir in settings.py and make sure the webserver can read it... On Jul 26, 3:15 pm, LuXo Jarufewrote: > Hi, I want to use the admin but I have this problem, I was following > the tutorial in djangoproject but when I execute the admin this > appears: > > TemplateDoesNotExist at /admin/ > > admin/login.html > > Request Method: GET > Request URL: http://127.0.0.1:8000/admin/ > Exception Type: TemplateDoesNotExist > Exception Value: > > admin/login.html > > Exception Location: unknown in ?, line ? > Python Executable: /usr/bin/python > Python Version: 2.5.2 > Python Path: ['/home/luxo/Django/mysite', '/usr/lib/python2.5', '/usr/ > lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/ > python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/ > usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/ > Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/ > site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/usr/ > lib/python2.5/site-packages/gtk-2.0', '/var/lib/python-support/ > python2.5/gtk-2.0'] > > Template-loader postmortem > > Django tried loading these templates, in this order: > > * Using loader > django.template.loaders.filesystem.load_template_source: > * Using loader > django.template.loaders.app_directories.load_template_source: > o /usr/lib/python2.5/site-packages/django/contrib/admin/ > templates/admin/login.html (File exists) > > Environment: > > Request Method: GET > Request URL:http://127.0.0.1:8000/admin/ > Django Version: 1.0.2 final > Python Version: 2.5.2 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'django.contrib.admin', > 'mysite.polls'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware') > > Template Loader Error: > Django tried loading these templates, in this order: > Using loader django.template.loaders.filesystem.load_template_source: > Using loader > django.template.loaders.app_directories.load_template_source: > /usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/ > login.html (File exists) > > Traceback: > File "unknown" in ? > ?. ??? > > Exception Type: TemplateDoesNotExist at /admin/ > Exception Value: admin/login.html > > Help me! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: run django on multicore machine
Not sure about my answer but I think it matters more that the webserver you are using can take advantage of multicore (i.e. mod_python instances running in their own thread.) On Jul 23, 10:26 am, ihomewrote: > Has django been designed to take advantage of multicore machine? Is > there a way to boost the performance of a django server on multicore > machine? Any thoughts? 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-users@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: Sqlite3 ok from deployment?
Thanks, it's an in-house thing so I don't anticipate growth. I guess i'll stick with sqlite for now. Your reassurance is appreciated! On Jul 22, 5:24 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote: > I don't think it really matters if one or more processes/threads try > to access it, when it get's locked EXCLUSIVE for writing only one will > have access to it until the lock gets released. For a very low volume > site with very few INSERT/UPDATE/DELETE queries you may not experience > any difference but if your site grows in the future you'll have to go > through migrating your data when you have to switch the db, which can > also be made pretty simple with django. > If there's a really small ammount of memory on your deployment server > sqlite might be a better option than something bigger (in that case > apache is not the best option either, try cherrypy wsgi server). But > if you have enough resources and the only real reason for using sqlite > is not wanting to go through db server installation you might want to > reconsider. > > > > On Thu, Jul 23, 2009 at 2:02 AM, Some Guy<djul...@gmail.com> wrote: > > > Having finished a small app, i'm wondering if it's ok to use sqlite3 > > in a deployment with mod_python and apache. > > > I've read that sqlite is not meant for multi-user access where the > > actual db file is shared, but with several mod_pythons running will it > > be an issue if they are all having access to it? The site is low > > volume... should I run 1 max instances of mod_python? > > > Is sqlite only meant for development? Django makes it pretty easy to > > change DBs so don't spare me the harsh truth ! :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Sqlite3 ok from deployment?
Having finished a small app, i'm wondering if it's ok to use sqlite3 in a deployment with mod_python and apache. I've read that sqlite is not meant for multi-user access where the actual db file is shared, but with several mod_pythons running will it be an issue if they are all having access to it? The site is low volume... should I run 1 max instances of mod_python? Is sqlite only meant for development? Django makes it pretty easy to change DBs so don't spare me the harsh truth ! :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: OneToOneFields: How do you use them?
Just a guess, but maybe... >>> p = mymodels.Person() >>> p.name="John Smith" >>> f = mymodels.Friend() >>> f.name = "John Q. Smith" add this here so it gets an id?? f.save() >>> p.friend = f >>> p.save() On Jul 22, 12:15 pm, Dudley Foxwrote: > I have a simple test model defined: > > class Friend(models.Model): > name = models.CharField(max_length=120) > > class Person(models.Model): > name = models.CharField(max_length=120) > friend = models.OneToOneField(Friend) > > Here is a sample of usage, and obviously I am doing something wrong...>>> p = > mymodels.Person() > >>> p.name="John Smith" > >>> f = mymodels.Friend() > >>> f.name = "John Q. Smith" > >>> p.friend = f > >>> p.save() > > Traceback (most recent call last): > File "", line 1, in > File "C:\python26\lib\site-packages\django\db\models\base.py", line > 311, in save > self.save_base(force_insert=force_insert, force_update=force_update) > File "C:\python26\lib\site-packages\django\db\models\base.py", line > 383, in save_base > result = manager._insert(values, return_id=update_pk) > File "C:\python26\lib\site-packages\django\db\models\manager.py", > line 138, in _insert > return insert_query(self.model, values, **kwargs) > File "C:\python26\lib\site-packages\django\db\models\query.py", line > 894, in insert_query > return query.execute_sql(return_id) > File "C:\python26\lib\site-packages\django\db\models\sql\subqueries.py", > line 309, in execute_sql > cursor = super(InsertQuery, self).execute_sql(None) > File "C:\python26\lib\site-packages\django\db\models\sql\query.py", > line 1734, in execute_sql > cursor.execute(sql, params) > File "C:\python26\lib\site-packages\django\db\backends\util.py", > line 19, in execute > return self.cursor.execute(sql, params) > File "C:\python26\lib\site-packages\django\db\backends\sqlite3\base.py", > line > 168, in execute > return Database.Cursor.execute(self, query, params) > IntegrityError: polls_person.friend_id may not be NULL > > So then I try the following: > > >>> p.friend.save() > >>> p.save() > > And get the same error? > > Any help would be appreciated. > > Sincerely, > Dudley --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Use an arbitrary changelist
You want this... http://blog.dougalmatthews.com/2008/10/filter-the-django-modeladmin-set/ Be aware though, of a bug* in manage.py that, if you dumpdata with only your app specified, you will get entries for the proxy model as well. The proxy model entries will screw up your next loaddata, so I recommend specifying each model to dump in your dumpdata command. *the bug may have been fixed, but the report in trac does not show any resolution On Jul 22, 5:08 am, TiNowrote: > Hi, > I would like a second changelist for an app. Besides the changelist that > shows all members, I would like to show a changlist that show all members > interested in some category. I now I can apply a list filter in the main > list, but I rather have a separate list where the admin returns to after > editing someone from the list, and provide some actions in the object-tools > like sending an email to all members interested in that category. > > How do I create a view with a changelist? I know I can override the > Changelist's get_query_set method, but with what parameters do I instantiate > it? > > thanks, > > TiNo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Might have found a bug with manage.py
Nevermind, I should have checked trac first instead of searching this group found http://code.djangoproject.com/ticket/11429 and http://code.djangoproject.com/ticket/11428 I guess I'll have to be explicit with which models to dump On Jul 21, 1:23 pm, Some Guy <djul...@gmail.com> wrote: > also... > > Django version 1.1 beta 1 SVN-11082 > > On Jul 21, 1:22 pm, Some Guy <djul...@gmail.com> wrote: > > > > > I have a model with a proxy subclass. dumpdata saves an entry for > > each of the superclass' and an additional entry for the proxy class > > (with no fields) as well. > > > loaddata then chokes on the superclasses constraints. Or is it > > supposed to do this? > > > i.e. (psuedocode..) > > > assume app = 'bar' > > > class a(Models.model): > > foo = models..DateTimeField(auto_now_add=True) > > > class b(a): > > class Meta: > > proxy = True > > > dumpdata gives me something like this... > > > [ > > {"pk":1, > > "model": "bar.a" > > "fields":{ > > "foo": "2009-07-02 12:48:13" > > } > > }, > > {"pk":1, > > "model": "bar.b" > > "fields":{} > > }, > > ] > > > Loaddata then chokes on import with an integrity error saying "foo can > > not be null" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Might have found a bug with manage.py
also... Django version 1.1 beta 1 SVN-11082 On Jul 21, 1:22 pm, Some Guy <djul...@gmail.com> wrote: > I have a model with a proxy subclass. dumpdata saves an entry for > each of the superclass' and an additional entry for the proxy class > (with no fields) as well. > > loaddata then chokes on the superclasses constraints. Or is it > supposed to do this? > > i.e. (psuedocode..) > > assume app = 'bar' > > class a(Models.model): > foo = models..DateTimeField(auto_now_add=True) > > class b(a): > class Meta: > proxy = True > > dumpdata gives me something like this... > > [ > {"pk":1, > "model": "bar.a" > "fields":{ > "foo": "2009-07-02 12:48:13" > } > }, > {"pk":1, > "model": "bar.b" > "fields":{} > }, > ] > > Loaddata then chokes on import with an integrity error saying "foo can > not be null" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Might have found a bug with manage.py
I have a model with a proxy subclass. dumpdata saves an entry for each of the superclass' and an additional entry for the proxy class (with no fields) as well. loaddata then chokes on the superclasses constraints. Or is it supposed to do this? i.e. (psuedocode..) assume app = 'bar' class a(Models.model): foo = models..DateTimeField(auto_now_add=True) class b(a): class Meta: proxy = True dumpdata gives me something like this... [ {"pk":1, "model": "bar.a" "fields":{ "foo": "2009-07-02 12:48:13" } }, {"pk":1, "model": "bar.b" "fields":{} }, ] Loaddata then chokes on import with an integrity error saying "foo can not be null" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Change default queryset in admin for a model
Thanks, I am using 1.1 beta and proxy looks like it was meant to do what I want, without a kludge. will give it a shoot On Jul 19, 3:36 pm, Alex Gaynor <alex.gay...@gmail.com> wrote: > On Sun, Jul 19, 2009 at 5:07 PM, Some Guy<djul...@gmail.com> wrote: > > > Thanks for the help :-) > > > overriding queryset in modeladmin worked for the filtering. > > > as for the subclassing of the model.. > > > I've basically got a table with lots of columns ex.[a,b,c,d,e,f,g...] > > I would like to have one admin page show a,b,c,d and another that > > shows a,b,c,f,g based (ideally) on a boolean column in the table. > > > If anyone has a quick idea on how to accomplish that one i would be > > most appreciative. > > > On Jul 19, 12:53 pm, jeff <jmsche...@gmail.com> wrote: > >> I'm not entirely clear what you're trying to accomplish, but in > >> general when I hear "dummy" anything, I have to think there's a better > >> solution. Perhaps what you're looking for is an abstract model class, > >> from which you can subclass your two concrete ones? > >> Seehttp://docs.djangoproject.com/en/dev/topics/db/models/#id6. > > >> If you really need to restrict the queryset for the model admin's list > >> page, then yes, you can override the default queryset method defined > >> in ModelAdmin just as the link describes. > > >> jeff > > >> On Jul 19, 12:40 pm, Some Guy <djul...@gmail.com> wrote: > > >> > hrmm, I found this > >> > too..http://blog.dougalmatthews.com/2008/10/filter-the-django-modeladmin-set/ > > >> > the method used is def queryset(self, request): in the model admin > >> > class... > >> > This method is not in the docs, though. > > >> > Should any of these methods be preferred over the others? > >> > any advice is appreciated :-) > > >> > On Jul 19, 12:17 pm, Some Guy <djul...@gmail.com> wrote: > > >> > > I was wondering if it's possible to have an admin page always show a > >> > > filtered (or other non-default) queryset? > > >> > > i.e. I would like the default admin page to show a queryset without > >> > > any rows that have a particular boolean field set to false. > > >> > > I've looked in the admin views.py, but haven't found anything that > >> > > looks possible. > > >> > > I just need to know if it's possible, and where to look... > > >> > > TIA > > >> > > (longer version follows) > >> > > I have a Model that I would like to display with two different > >> > > list_displays, based on whether a boolean is true or false. > > >> > > I've noticed that any model inherited with no additional fields > >> > > specified shows up in the parent model's admin page listing. I was > >> > > going to exploit this to make a dummy subclass of the model superclass > >> > > with a different list_display and register that with the adminsite. > >> > > Not sure if there is an easy way to do this, but who knows :-> there's > >> > > lots of django tricks. > > If you're on the latest development version of Django 1.1 beta I'd > make proxy subclasses on the model and register separate model admins > for each of them. > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your > right to say it." -- Voltaire > "The people's good is the highest law." -- Cicero > "Code can always be simpler than you think, but never as simple as you > want" -- Me --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Change default queryset in admin for a model
Thanks for the help :-) overriding queryset in modeladmin worked for the filtering. as for the subclassing of the model.. I've basically got a table with lots of columns ex.[a,b,c,d,e,f,g...] I would like to have one admin page show a,b,c,d and another that shows a,b,c,f,g based (ideally) on a boolean column in the table. If anyone has a quick idea on how to accomplish that one i would be most appreciative. On Jul 19, 12:53 pm, jeff <jmsche...@gmail.com> wrote: > I'm not entirely clear what you're trying to accomplish, but in > general when I hear "dummy" anything, I have to think there's a better > solution. Perhaps what you're looking for is an abstract model class, > from which you can subclass your two concrete ones? > Seehttp://docs.djangoproject.com/en/dev/topics/db/models/#id6. > > If you really need to restrict the queryset for the model admin's list > page, then yes, you can override the default queryset method defined > in ModelAdmin just as the link describes. > > jeff > > On Jul 19, 12:40 pm, Some Guy <djul...@gmail.com> wrote: > > > > > hrmm, I found this > > too..http://blog.dougalmatthews.com/2008/10/filter-the-django-modeladmin-set/ > > > the method used is def queryset(self, request): in the model admin > > class... > > This method is not in the docs, though. > > > Should any of these methods be preferred over the others? > > any advice is appreciated :-) > > > On Jul 19, 12:17 pm, Some Guy <djul...@gmail.com> wrote: > > > > I was wondering if it's possible to have an admin page always show a > > > filtered (or other non-default) queryset? > > > > i.e. I would like the default admin page to show a queryset without > > > any rows that have a particular boolean field set to false. > > > > I've looked in the admin views.py, but haven't found anything that > > > looks possible. > > > > I just need to know if it's possible, and where to look... > > > > TIA > > > > (longer version follows) > > > I have a Model that I would like to display with two different > > > list_displays, based on whether a boolean is true or false. > > > > I've noticed that any model inherited with no additional fields > > > specified shows up in the parent model's admin page listing. I was > > > going to exploit this to make a dummy subclass of the model superclass > > > with a different list_display and register that with the adminsite. > > > Not sure if there is an easy way to do this, but who knows :-> there's > > > lots of django tricks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Change default queryset in admin for a model
hrmm, I found this too.. http://blog.dougalmatthews.com/2008/10/filter-the-django-modeladmin-set/ the method used is def queryset(self, request): in the model admin class... This method is not in the docs, though. Should any of these methods be preferred over the others? any advice is appreciated :-) On Jul 19, 12:17 pm, Some Guy <djul...@gmail.com> wrote: > I was wondering if it's possible to have an admin page always show a > filtered (or other non-default) queryset? > > i.e. I would like the default admin page to show a queryset without > any rows that have a particular boolean field set to false. > > I've looked in the admin views.py, but haven't found anything that > looks possible. > > I just need to know if it's possible, and where to look... > > TIA > > (longer version follows) > I have a Model that I would like to display with two different > list_displays, based on whether a boolean is true or false. > > I've noticed that any model inherited with no additional fields > specified shows up in the parent model's admin page listing. I was > going to exploit this to make a dummy subclass of the model superclass > with a different list_display and register that with the adminsite. > Not sure if there is an easy way to do this, but who knows :-> there's > lots of django tricks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Change default queryset in admin for a model
In an attempt to answer my own question... Would a custom manager be able to do this? I've never done one, but could one override the all() method to filter the results that the admin receives? On Jul 19, 12:17 pm, Some Guy <djul...@gmail.com> wrote: > I was wondering if it's possible to have an admin page always show a > filtered (or other non-default) queryset? > > i.e. I would like the default admin page to show a queryset without > any rows that have a particular boolean field set to false. > > I've looked in the admin views.py, but haven't found anything that > looks possible. > > I just need to know if it's possible, and where to look... > > TIA > > (longer version follows) > I have a Model that I would like to display with two different > list_displays, based on whether a boolean is true or false. > > I've noticed that any model inherited with no additional fields > specified shows up in the parent model's admin page listing. I was > going to exploit this to make a dummy subclass of the model superclass > with a different list_display and register that with the adminsite. > Not sure if there is an easy way to do this, but who knows :-> there's > lots of django tricks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Change default queryset in admin for a model
I was wondering if it's possible to have an admin page always show a filtered (or other non-default) queryset? i.e. I would like the default admin page to show a queryset without any rows that have a particular boolean field set to false. I've looked in the admin views.py, but haven't found anything that looks possible. I just need to know if it's possible, and where to look... TIA (longer version follows) I have a Model that I would like to display with two different list_displays, based on whether a boolean is true or false. I've noticed that any model inherited with no additional fields specified shows up in the parent model's admin page listing. I was going to exploit this to make a dummy subclass of the model superclass with a different list_display and register that with the adminsite. Not sure if there is an easy way to do this, but who knows :-> there's lots of django tricks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Dict objects are unhashable errors
good question! I was basing it off the docs (or so I thought) on generic views. django urls.py has never been very intuitive for me, so I rely on copying from the docs pretty heavily. I guess it got mangled at some stage... thanks for the link tho. :) On Jul 16, 2:15 pm, Alex Koshelev <daeva...@gmail.com> wrote: > On Fri, Jul 17, 2009 at 1:07 AM, Some Guy <djul...@gmail.com> wrote: > > > Found out what was causing this error behavior. > > > this line was in my urls.py.. commenting it out fixed everything. I > > just can't see what's wrong with it :-) > > > # (r'^diamond/(?P\d+)/$', 'object_detail', info_dict, > > {'template': 'diamond_detail.html'}), > > Please read url patterns docs [1] and answer to yourself - why you have 2 > dicts in one pattern? > > [1]:http://docs.djangoproject.com/en/dev/topics/http/urls/#patterns > > --- > Alex Koshelev --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Dict objects are unhashable errors
Found out what was causing this error behavior. this line was in my urls.py.. commenting it out fixed everything. I just can't see what's wrong with it :-) #(r'^diamond/(?P\d+)/$', 'object_detail', info_dict, {'template': 'diamond_detail.html'}), On Jul 15, 12:14 pm, Some Guy <djul...@gmail.com> wrote: > I should add my django versions too > > dev: 1.1 beta 1 SVN-11082 > > Deploy: 1.1 beta 1 > > On Jul 15, 12:12 pm, Some Guy <djul...@gmail.com> wrote: > > > > > Hi, > > I seem to have a problem where various contrib elements are throwing a > > template error "dict objects are unhashable" > > I'm seeing it in admin, comments, etc. Both on my dev setup and > > deployed. > > > The line of code always seems to be File "/Library/Python/2.5/site- > > packages/django/utils/datastructures.py", line 269, in setlistdefault > > if key not in self: > > > How am I the only one experiencing this? :-) > > > Dev: devserver, Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12), > > sqlite3 > > > Deployed: apache2/modpython, Python 2.5.2 (r252:60911, Jul 31 2008, > > 17:31:22), sqlite3 > > > any Ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Dict objects are unhashable errors (FOUND THE BUG anyone know why?)
Hi Group, I found a bug that was causing my issue (ref: http://groups.google.com/group/django-users/browse_thread/thread/130f36db5e95bd81) In my urls.py I have a line ... (r'^diamond/(?P\d+)/$', 'object_detail', info_dict, {'template': 'diamond_detail.html'}), If I comment it out it, everything works. Anyone know what's wrong with it? It's supposed to be a generic object detail. TIA --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: Dict objects are unhashable errors
I should add my django versions too dev: 1.1 beta 1 SVN-11082 Deploy: 1.1 beta 1 On Jul 15, 12:12 pm, Some Guy <djul...@gmail.com> wrote: > Hi, > I seem to have a problem where various contrib elements are throwing a > template error "dict objects are unhashable" > I'm seeing it in admin, comments, etc. Both on my dev setup and > deployed. > > The line of code always seems to be File "/Library/Python/2.5/site- > packages/django/utils/datastructures.py", line 269, in setlistdefault > if key not in self: > > How am I the only one experiencing this? :-) > > Dev: devserver, Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12), > sqlite3 > > Deployed: apache2/modpython, Python 2.5.2 (r252:60911, Jul 31 2008, > 17:31:22), sqlite3 > > any Ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Dict objects are unhashable errors
Hi, I seem to have a problem where various contrib elements are throwing a template error "dict objects are unhashable" I'm seeing it in admin, comments, etc. Both on my dev setup and deployed. The line of code always seems to be File "/Library/Python/2.5/site- packages/django/utils/datastructures.py", line 269, in setlistdefault if key not in self: How am I the only one experiencing this? :-) Dev: devserver, Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12), sqlite3 Deployed: apache2/modpython, Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22), sqlite3 any Ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: dict objects are unhashable in admin... in this a bug?
admin.py is here --> http://pastebin.com/m23760293 ... stack trace is here -> http://pastebin.com/m971fc89 It's fairly vanilla. I also had a similar error from the {%doctools%} tag on change_list page. SInce it was not essential I changed it to a comment tag. Things work ok after that, but I need the ability to edit users :-) Right now I'm using 1.1 beta 1 django, apache2, and sqlite3 I saw something similar in trac but it was closed with "works for me" On Jul 14, 12:41 pm, Alex Gaynor <alex.gay...@gmail.com> wrote: > On Tue, Jul 14, 2009 at 2:28 PM, Some Guy <djul...@gmail.com> wrote: > > > Hi Group, > > I'm using svn version of django and SQLite3 on linux. I set up a basic > > admin user and when I try to access the edit page I get the > > "TemplateSyntaxError at /admin/auth/user/1/ > > Caught an exception while rendering: dict objects are unhashable" > > > Is this a bug? how far back should I downgrade to get around it? > > > error screen paste below... > > > <div{% if not line.fields|length_is:"1" %} class="field-box"{% endif %} > > > 9 {% if field.is_checkbox %} > > 10 {{ field.field }}{{ field.label_tag }} > > 11 {% else %} > > 12 {{ field.label_tag }}{{ field.field }} <<--- This > > {{field.field}} is highlighted red in the debug screen! > > 13 {% endif %} > > 14 {% if field.field.field.help_text %} > > {{ field.field.field.help_text|safe }}{% endif %} > > 15 > > Can you paste the admin.py file or other code for the app that's giving you > this error? > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." -- Voltaire > "The people's good is the highest law." -- Cicero > "Code can always be simpler than you think, but never as simple as you want" > -- Me --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
dict objects are unhashable in admin... in this a bug?
Hi Group, I'm using svn version of django and SQLite3 on linux. I set up a basic admin user and when I try to access the edit page I get the "TemplateSyntaxError at /admin/auth/user/1/ Caught an exception while rendering: dict objects are unhashable" Is this a bug? how far back should I downgrade to get around it? error screen paste below...9 {% if field.is_checkbox %} 10{{ field.field }}{{ field.label_tag }} 11{% else %} 12{{ field.label_tag }}{{ field.field }} <<--- This {{field.field}} is highlighted red in the debug screen! 13{% endif %} 14{% if field.field.field.help_text %} {{ field.field.field.help_text|safe }}{% endif %} 15 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: where does admin add ... tags to data?
thanks, indeed you are right. Now to find out how bad I can break things by moving that behavior to the other template. On Jul 9, 5:34 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Thu, Jul 9, 2009 at 6:22 PM, Some Guy <djul...@gmail.com> wrote: > > > I've found the following in the template ... > > > {% for result in results %} > > {% for item in result %} > > {{ item }}{% endfor %} > > {% endfor %} > > > I would like to apply an additional template tag to {{item}}, i.e. > > {{item|default_if_none:"" }} > > > I have discovered that in this template {{ item }} is already wrapped > > with tags i.e. {{ item }} > > > Anyone know where these tags are applied in the admin site? I haven't > > been able to find them... TIA > > I think here: > > http://code.djangoproject.com/browser/django/tags/releases/1.0.2/djan... > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
where does admin add ... tags to data?
I've found the following in the template ... {% for result in results %} {% for item in result %} {{ item }}{% endfor %} {% endfor %} I would like to apply an additional template tag to {{item}}, i.e. {{item|default_if_none:"" }} I have discovered that in this template {{ item }} is already wrapped with tags i.e. {{ item }} Anyone know where these tags are applied in the admin site? I haven't been able to find them... TIA --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: apply default_if_none filter type behavior in admin fields?
Of course it should be default_if_none template tag, but it mangled my link On Jul 3, 3:43 pm, Some Guy <djul...@gmail.com> wrote: > Hi, > I wonder if anyone has ideas about the best way to do this. > > My field shows up as (None) in the change_list view on admin. I would > love to have a behavior similar to default_if_none template tag. > > My Ideas > > 1. making a new template just for this seems difficult. > > 2.I could make a function in the model that returns '' if the actual > field is None... > like > > cost = models.DecimalField > def display_cost(self): > if self.cost: > return self.cost > else: > return ' ' > > But if I wanted to do this for many fields it could get pretty ugly > > > What would be the best way of these two? Or is there some way I > haven't thought of? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
apply default_if_none filter type behavior in admin fields?
Hi, I wonder if anyone has ideas about the best way to do this. My field shows up as (None) in the change_list view on admin. I would love to have a behavior similar to default_if_none template tag. My Ideas 1. making a new template just for this seems difficult. 2.I could make a function in the model that returns '' if the actual field is None... like cost = models.DecimalField def display_cost(self): if self.cost: return self.cost else: return ' ' But if I wanted to do this for many fields it could get pretty ugly What would be the best way of these two? Or is there some way I haven't thought of? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: No css in Admin
Found the problem. I was overriding change_list.html and somehow base.css is not being included. I manually linked it into my base.html and it works now. I was seeing change_list.css, or whatever, and thought that was all that was needed. On Jul 1, 1:46 pm, Xavier Ordoquy <xordo...@linovia.com> wrote: > On Wed, 2009-07-01 at 13:01 -0700, Some Guy wrote: > > Hi Group, > > I've look all over to find the answer but am now posting out of > > desperation :) > > > I have a dev and prod server (apache2, mod_python) > > > on the production server the css and js for the admin site does not > > work. (except for the login page) > > > The images show up but no css styles are applied. Also, the save > > function doesn't work (due to no Js?) > > > If I put the css file url in the browser, it shows up fine... Also, > > firebug lists the css styles, but they are not applied. > > > Another weird thing is that firebug's "NET" tab shows only downloading > > the html, and no css or js files. > > > Any ideas? > > TIA > > Hi, > > Are you sure you configured correctly ADMIN_MEDIA_PREFIX ? > What's your website url ? > > Regards, > Xavier Ordoquy. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
No css in Admin
Hi Group, I've look all over to find the answer but am now posting out of desperation :) I have a dev and prod server (apache2, mod_python) on the production server the css and js for the admin site does not work. (except for the login page) The images show up but no css styles are applied. Also, the save function doesn't work (due to no Js?) If I put the css file url in the browser, it shows up fine... Also, firebug lists the css styles, but they are not applied. Another weird thing is that firebug's "NET" tab shows only downloading the html, and no css or js files. Any ideas? TIA --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---