Extracting the database name from an object
Hello, Suppose I get an object from a non-default database: ob = MyModel.objects.using('somedb').get(pk=1) Is it possible later to retrieve the database name just from the object? ob.db?? Regards, Juan Pablo -- 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: template list empty in with django test client
My fault. I was testing from the console. Within an actual test the request does have the templates. Juan Pablo El día 28 de agosto de 2011 17:50, Juan Pablo Romero Méndez <jpablo.rom...@gmail.com> escribió: > Hello, > > I'm using the django test client, like this: > >>>> c = Client() >>>> r = c.get("/content/new/") >>>> r.status_code > 200 >>>> r.templates > [] > > Is this normal? > > Regards, > > Juan Pablo > -- 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.
template list empty in with django test client
Hello, I'm using the django test client, like this: >>> c = Client() >>> r = c.get("/content/new/") >>> r.status_code 200 >>> r.templates [] Is this normal? Regards, Juan Pablo -- 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: Tutorial: New class based generic views
Thanks for the feedback Gelonida! 2011/8/9 Gelonida N <gelon...@gmail.com>: > On 08/09/2011 03:33 PM, Juan Pablo Romero Méndez wrote: >> Hey guys, >> >> This is the first part of a series of blog posts I'm writing about >> class based generic views: >> >> http://pseudocorta.blogspot.com/2011/08/django-generic-views.html >> >> Cheers! >> >> Juan Pablo >> > Hi Juan, > > This blog looks interesting. I am curious about the next ones :-) . > > For people with little experience it might help a lot if you also add > the import statements. > > I personally don't know for example by heart, where generic.CreateView > is coming from. > > With many tutorials, blogs, code snippets I spent more time searching > for the correct import than understanding the rest of the code. > Experienced programmes wil know of course the which import to use, but > the few addtional lines shouldn't really hurt them. > > > > > > -- > 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. > > -- 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.
Tutorial: New class based generic views
Hey guys, This is the first part of a series of blog posts I'm writing about class based generic views: http://pseudocorta.blogspot.com/2011/08/django-generic-views.html Cheers! Juan Pablo -- 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.
Prototype: LINQ-esque Manager for Django models
Hello, I've just put a very rough prototype of a db.models.Manager that allows queries to be specified with lambdas: Choice.objects.where(lambda c: c.votes >= 1) Choice.objects.where(lambda c: c.votes != 1) Choice.objects.where(lambda c: c.poll.question.exact('aaa')) Choice.objects.where(lambda c: c.poll.question.contains('aa')) Choice.objects.where(lambda c: c.votes == c.anumber) Choice.objects.where(lambda c: c.votes > c.anumber) https://github.com/jpablo/django-orm-lambdas Regards, Juan Pablo -- 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.
django admin and static files
Hello, I'm trying to use a custom javascript file in the admin app with Media: class MyAdmin(admin.ModelAdmin): class Media: js = ('js/my.js',) the problem is that after installing the staticfiles app (in INSTALLED_APPS) and after setting STATIC_URL = '/media/', the admin app is unable to find their own admin files. What could I do? Regards, Juan Pablo -- 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: Question about ModelAdmin.formfield_for_foreignkey
I think i solved it. This is the chain of method calls of admin.ModelAdmin: ... change_view get_form formfield_for_foreignkey ... get_form receives the current object as parameter, so all I had to do was to inject obj in the request: def get_form(self, request, obj=None, **kwargs): request.obj = obj return super(AuthorContenidoAdmin, self).get_form(request, obj, **kwargs) and retrieve it later in formfield_for_foreignkey: def formfield_for_foreignkey(self, db_field, request=None, **kwargs): obj = request.obj if db_field.name == 'status' and obj is not None: allowed_states = [t.destination for t in get_allowed_transitions(obj,request.user)] kwargs['queryset'] = FakeQueryset([get_state(obj)] + allowed_states) return super(AuthorContenidoAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) Regards, Juan Pablo 2011/5/5 Daniel Roseman> On Thursday, May 5, 2011 10:32:47 PM UTC+1, juanpa wrote: >> >> Hello, >> >> Is it possible to obtain a reference to the modified object >> in ModelAdmin.formfield_for_foreignkey? >> >> Thanks! >> >>Juan Pablo >> > > What do you mean, modified? formfield_for_foreignkey is used for defining > the form, long before any modifications take place. > -- > 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-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. > -- 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.
Question about ModelAdmin.formfield_for_foreignkey
Hello, Is it possible to obtain a reference to the modified object in ModelAdmin.formfield_for_foreignkey? Thanks! Juan Pablo -- 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: Select list populated from an object method (admin app)
Ok, I learned about ModelAdmin.formfield_for_foreignkey, which let's me access the current user. What I can't find now is the instance asociated the db_field parameter. El 3 de mayo de 2011 14:19, Juan Pablo Romero Méndez < jpablo.rom...@gmail.com> escribió: > Hello, > > I wonder if there's an easy way to do the following (besides modifying > "contrib.admin.templates.admin.includes.fieldset.html"): > > I have a model which uses django-workflows, so for each instance and every > user I can do: get_allowed_transitions(obj,user), and > obtain a list of Transition objects. > > What I'd like is to do is to populate a select list in the change_form > with the list of transitions allowed for the object. > > The tricky thing is that for this list to be calculated, the code needs > access to the current user. > > Regards, > > Juan Pablo > -- 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.
Select list populated from an object method (admin app)
Hello, I wonder if there's an easy way to do the following (besides modifying "contrib.admin.templates.admin.includes.fieldset.html"): I have a model which uses django-workflows, so for each instance and every user I can do: get_allowed_transitions(obj,user), and obtain a list of Transition objects. What I'd like is to do is to populate a select list in the change_form with the list of transitions allowed for the object. The tricky thing is that for this list to be calculated, the code needs access to the current user. Regards, Juan Pablo -- 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: Django Admin template
For this, django-google-toolbar is invaluable. It tells you exactly which templates were used in rendering some url. Coupled with pycharm's "find file by name" feature (Ctrl+Shift+N) it names really easy to jump to any name file. Regards, Juan Pablo 2011/5/3 Rich> I know it's possible to overwrite the Django admin templates by > copying the templates to your local project. I want to modify the > "add user" template but cannot seem to figure out which template it > is. I want to create a button which will use APG to generate a random > password rather than typing in the password. Anyone, have any idea > how this can be accomplished. > > Thanks, > Richard > > -- > 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. > > -- 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.
Using different choices in different ModelAdmins
Hello, I'm developing several personalized admin sites (by subclassing admin.ModelAdmin). Is it possible to use different Field.choices in a particular field for each admin site? The problem is that the choices option is set within the model definition, not in the ModelAdmin. Regards, Juan Pablo -- 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.
Unidirectional relations
Hello, Is it possible to create unidirectional relations within django's orm? What I mean is a situation where a parent has a children_set of references to children, but the children don't have any reference to the father. Regards, Juan Pablo -- 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.
Sitio que estamos lanzando
Chequen este sitio web que estamos lanzando, a ver que les parece: http://www.quetanprincipeeres.com.mx/ Saludos, Juan Pablo --~--~-~--~~~---~--~~ 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: I need to get psycopg2 installed on Mac OS X 10.5
I remember that there were some issues, but unfortunately I didn't document how I resolved them :( Juan Pablo 2009/7/14 Kevin <hekevint...@gmail.com>: > > Thanks a lot Juan! It works fine on my machine. Would you be able to > share your compilation steps? > > On Jul 14, 7:32 am, Juan Pablo Romero Méndez <jpablo.rom...@gmail.com> > wrote: >> I don't know if it will run in your machine, but here is one compiled >> for Python2.5, MacOS X 10.5.7, and PostgreSQL 8.3. >> >> Regards, >> >> Juan Pablo >> >> 2009/7/14 Kevin <hekevint...@gmail.com>: >> >> >> >> >> >> > I need to get psycopg2 installed on Mac OS X 10.5 >> >> > I have read every install guide I could find and I still do not have >> > it working. I have developer tools installed. I am running MacPython >> > 2.6.2 and PostgreSQL 8.4 downloaded >> > fromhttp://www.enterprisedb.com/products/pgdownload.do >> >> > On my production machine (Debian) I did a simple atp-get and it >> > worked. Why is it so much harder on Mac OS X? I am very near ripping >> > my hair out because I have wasted too much time and I do not >> > understand why psycopg2 does not work on my machine. >> >> > Below are my notes from three attempts to install psycopg2. I have >> > read other threads that suggest installing Python, PostgreSQL, and >> > psycopg2 from MacPorts. I do not want to use MacPorts. I do not see >> > why I need to use a completely different installation of Python to use >> > a simple database driver. >> >> > For my first attempt I followed the instructions listed here: >> >http://jasonism.org/weblog/2008/nov/06/getting-psycopg2-work-mac-os-x... >> > It told me to add these lines to setup.cfg: >> >> > include_dirs=/Library/PostgreSQL/8.3/include >> > library_dirs=/Library/PostgreSQL/8.3/lib >> >> > I then ran python setup.py build and got this error: >> >> > $ python setup.py build >> > running build >> > running build_py >> > creating build >> > creating build/lib.macosx-10.3-fat-2.6 >> > creating build/lib.macosx-10.3-fat-2.6/psycopg2 >> > copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 >> > copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 >> > copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 >> > copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 >> > copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 >> > copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 >> > copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 >> > running build_ext >> > error: No such file or directory >> >> > === >> >> > For my next attempt I followed the instructions listed here: >> >http://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/ >> > It told me to run this: >> >> > PATH=$PATH:/Library/PostgresPlus/8.3/bin/ sudo easy_install psycopg2 >> >> > This resulted in this error: (I substituted "8.4" for "8.3" because my >> > version of PostgreSQL is newer) >> >> > $ PATH=$PATH:/Library/PostgreSQL/8.4/bin/ sudo easy_install psycopg2 >> > Password: >> > Searching for psycopg2 >> > Readinghttp://pypi.python.org/simple/psycopg2/ >> > Readinghttp://initd.org/projects/psycopg2 >> > Readinghttp://initd.org/pub/software/psycopg/ >> > Best match: psycopg2 2.0.11 >> > Downloadinghttp://initd.org/pub/software/psycopg/psycopg2-2.0.11.tar.gz >> > Processing psycopg2-2.0.11.tar.gz >> > Running psycopg2-2.0.11/setup.py -q bdist_egg --dist-dir /tmp/ >> > easy_install-dUXtsI/psycopg2-2.0.11/egg-dist-tmp-1008XV >> > warning: no files found matching '*.html' under directory 'doc' >> > warning: no files found matching 'MANIFEST' >> > /usr/libexec/gcc/i686-apple-darwin9/4.0.1/as: assembler (/usr/bin/../ >> > libexec/gcc/darwin/i386/as or /usr/bin/../local/libexec/gcc/darwin/ >> > i386/as) for architecture i386 not installed >> > /usr/libexec/gcc/powerpc-apple-darwin9/4.0.1/as: assembler (/usr/ >> > bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/ >> > darwin/ppc/as) for architecture ppc not installed >> > Installed assemblers are: >> > /usr/bin/../libexec/gcc/darwin/ppc64/as for architecture ppc64 >> > /usr/bin/../libexec/gcc/dar
Re: Django way to design this model
Mhh... I don't fully understand your question. Regarding the radio buttons I think it is in the tutorial. What search fields are you talking about? Juan Pablo 2009/7/8 Divesh Gidwani: > > Hey, > > Newbie to Django, and have just finished part 2 of the tutorial on the > website, and need to speed up with work in the office. > > I have this model that I want to design on Django. I have already > created the mysql side of it, and the mysql database is ready. Also, i > have loaded mysqldb and i think it works. > > This is the model I have to follow: > > http://gomezlab.bme.unc.edu:8080/~kdauria/search.php > > How can I get those radio button like search fields? How to bring up > the search? > > Any suggestions, or resources would be helpful. > > Thanks in advance! > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---