Filter on multiple fields and/or multiple values...
Hello, I want to do something like the following: my_query_set = my_table.objects.filter(field1 = some_val and field2 = another_val) or my_query_set = my_model.objects.filter(field1 = some_val or field1 = another_val) I couldn't find anything in the docs that describes how to go about doing this. Thanks for any help. Ken --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: database API from external tools?
I'm trying to accomplish the same thing: use django standalone. After getting DJANGO_SETTINGS_MODULE set correctly so that it finds my settings.py, I get: File "C:\Python25\Lib\site-packages\django\db\models\base.py", line 51, in __new__ kwargs = {"app_label": model_module.__name__.split('.')[-2]} IndexError: list index out of range Any ideas? Ken On Oct 26, 10:19 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Russell Keith-Magee wrote: > > On Mon, Oct 27, 2008 at 6:05 AM, Andrew Chapman <[EMAIL PROTECTED]> wrote: > > >> Russell Keith-Magee wrote: > > >>> On Sat, Oct 25, 2008 at 3:55 AM, Andrew Chapman <[EMAIL PROTECTED]> wrote: > > My question is how to package up and deploy the Django python code for > externaltools to access the database? I'm hoping to have the Django app > sitting on the web server, with the source tree inaccessible to a bunch > of workstations. ... > > >>> If you just want the Django database API, then put the Django code > >>> (i.e., django.*) on the workstations, and just write your tools to > >>> import that code, setting up DJANGO_SETTINGS_MODULE as required. > > >>> If you also want your model definitions, then you're going to have to > >>> deploy those too... > >>> ...the model layer will work fine if the views are missing - > >>> strictly, the only part of your code that should need to exist on the > >>> workstation are the model definitions. Managing an extraction of a > >>> partial checkout of your project code is left as an exercise for the > >>> reader... > >>> *Obviously, the easiest way to get all the required code is to do a > >>> full checkout of your web application on the workstation...* > > >> Ok, thanks. > >> I just wanted to confirm that duplicating the web app out to the > >> workstations just so they can access the database API was the expected > >> course of action in this scenario. > >> It feels dirty to me! > > > No - that isn't what I said at all. > > > What I said is that you will need _pieces_ of the web app - > > specifically the model definitions, plus the main configuration > > file. I expect that the model definitions will also have some > > dependencies, but I can't tell what those are without seeing your > > code. > > > The _easiest_ way to know you have satisfied all internal dependencies > > is to copy the full web app. However, this is not the _only_ way, and > > if you're willing to handle the configuration management issues, you > > could provide a partial checkout and achieve the same outcome. > > Here's a specific example of a piece of code that uses a web app's > models. It should get you started - just dive in and write some code! > The tricky bit is providing the settings without using a "settings" > module. I can't remember who I got this code from, but the kudos belongs > to them, not me. Enjoy. > > regards > Steve > > from django.conf import settings > settings.configure( DATABASE_ENGINE="postgresql_psycopg2", > DATABASE_NAME ="PyTeach", > DATABASE_USER='django', > DATABASE_PASSWORD='djangopw', > DATABASE_HOST='localhost', > DATABASE_PORT='', > INSTALLED_APPS=('info', 'invoicing', 'training')) > from invoicing.models import (Address, Organization, Person, Project, Task) > # I've chopped a lot of code that created and saves instances of other > models > hweb = Organization( > name="Holden Web, LLC", > notes="""A tidy little company that works with Django""") > hweb.save() --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Integrating into PHP-based site...
Hello, I'm currently prototyping a web application using Django which must be integrated into an existing PHP-based site. Can anyone comment on, or provider a pointer to documentation for, the issues involved. In particularly, how to go about inheriting the existing look-and- feel. Thanks. Ken --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Integrating into PHP-based site...
Thanks for the response. Regarding "repurposing" the PHP-generated HTML, do you mean statically, eg. copying the page source into a template? If not, how can this be accomplished dynamically? Is there a way to get the raw HTML output of a PHP-based URL programatically and then plug that into a template, so as to avoid having duplicated HTML? Ken On Sep 28, 10:27 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote: > megrez80 wrote: > > Hello, > > I'm currently prototyping a web application using Django which > > must be integrated into an existing PHP-based site. Can anyone comment > > on, or provider a pointer to documentation for, the issues involved. > > In particularly, how to go about inheriting the existing look-and- > > feel. > > The look and feel will be the easiest part-- you just need to take the > HTML generated by your PHP app, and repurpose it as a Django template. > This shouldn't take long. > > Things like changing a menu bar that need to be common between the PHP > and the Django side would probably need to be maintained and updated in > tandem. > > You'll probably run into issues other than the look and feel, but there > is no reason that you can't have both Django and PHP running on one server. > > If you need to have both Django and PHP access the same database, you > can do that. Look in the Django documentation for "legacy db" stuff to > get Django working with your existing tables. > > Jeff Anderson > > signature.asc > < 1KViewDownload --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Integrating into PHP-based site...
Ok, so I can probably live with duplicating some HTML. Then my next question is how to access .css and image files (which reside under the server's document root) from within my template? Do I need to duplicate those under my app path somewhere? Ken On Sep 29, 12:25 pm, jonknee <[EMAIL PROTECTED]> wrote: > On Sep 29, 12:06 pm, megrez80 <[EMAIL PROTECTED]> wrote: > > > Regarding "repurposing" the PHP-generated HTML, do you mean > > statically, eg. copying the page source into a template? > > > If not, how can this be accomplished dynamically? Is there a way to > > get the raw HTML output of a PHP-based URL programatically and then > > plug that into a template, so as to avoid having duplicated HTML? > > It really depends on how your PHP site is constructed, most notably if > it's nicely templated or not. I was tasked with integrating Django on > a PHP site and for that project it was easier to copy the base > template into a Django template and then pull in a few of the > same .html includes (ad code and what not). We'll only have to mess > with the Django template if the site's core design changes and that > doesn't happen often enough to make it even a minor problem. You could > probably use PHP-CLI to fetch PHP output, but that wasn't necessary on > the project I worked on. > > The only tricky part of our integration is sharing the session. We > were using Django for the registration/management/sign on processes > and the PHP site needed to know if the user was signed in and had an > active subscription. A minor bit of trickery, but it was a pretty > seamless transition (the subscribers never noticed). --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Rendering just child template...
Is there a way to render just a child template (without it's parent(s)) and pass the results back in response to an Ajax.Updater request? I want to do this to dynamically update a container in an already-rendered page. Ken --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Rendering just child template...
Yes this helps, and it works, sort of. The resulting updated container is the entire page, minus the actual data. So I'm wondering, should I use render_to_response (really HttpResponse) to return the rendered HTML, or should I use something else in response to the Ajax.Updater request? Thanks again. Ken On Oct 2, 5:15 pm, Rock <[EMAIL PROTECTED]> wrote: > No. Typically you would make a stand-alone template that does not > extend anything else. This template only renders the contents of the > container in question. It can be used by your AJAX view to create an > updated container which can be passed back to the browser. But the > same template can also be included by a child template (or templates) > at the appropriate place to perform the original rendering of that > container on full pages as required. So your child template now > "includes" this same template: > > {% include "my_dynamic_container.html" %} > > Hope that helps... --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to send emails when after an event happened?
Start here: http://www.python.org/doc/2.5.2/lib/module-smtplib.html . Ken On Oct 19, 2:04 am, Net_Boy <[EMAIL PROTECTED]> wrote: > Hi, > > I am doing a new project and (doing a function that checks for a > specific event, if it happened then the system should send email to > the user? so how can I do that? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---