Re: Multiple primary keys
Malcolm Tredinnick wrote: > On Tue, 2007-08-14 at 06:51 +0200, Lars Stavholm wrote: >> Malcolm Tredinnick wrote: >>> On Tue, 2007-08-14 at 08:47 +0800, Russell Keith-Magee wrote: >>> [...] You will have more difficulty with the Admin application and generic views. Both of these features rely upon the ability to install URLs like: /path/to/object/42/ -> edit object 42 This works fine if you have a single column primary key; however, if you have multiple column primary keys, this isn't so easy to do. To date, every proposed syntax for URL spaces supporting multiple primary keys has either been syntactically ambiguous (e.g., /path/to/object/42,37 - which works unless the primary key has a comma in it), or very inelegant (/path/to/object/42/37/ - which implies a heirarchy where there isn't one). Any proposal for adding multiple primary keys would need to address this very large issue. >>> Remembering that primary keys are not just integers, so *any* string >>> construct you come up with could also be the value of a single primary >>> key. (e.g. "42/37/", in Russell's second example, could be a primary key >>> value, too). >> I see, not that simple. >> >> I guess the following idea has been discussed already then: >> >> Something like... >> >> /path/to/object/42,37 >> >> ...where we use a setting like... >> >> PRIMARY_KEY_SEPARATOR = ',' >> >> So, if the application needs to use another character to >> separate the primary key fields, we could use, for example... >> >> /path/to/object/[EMAIL PROTECTED] >> >> PRIMARY_KEY_SEPARATOR = '@' >> >> ...maybe with a built in restriction of the allowed values >> for PRIMARY_KEY_SEPARATOR. > > How will you know what your users will enter in the primary key? If it's Well, all of the databases I've been looking at are sort of professionally built, and don't really use arbitrary strings for any primary key field. The usual case is a combinations of integers, and in some cases a combination of integers and simple/short strings, like unix usernames, invoice number characters and integers mixed in a single string field, and such. One could even assume that there's no strange characters within the primary key field. I've been working with RDBMSs for a good while, and I've never seen any arbitrary-string-in-primary-key-field requirement, no commas, no dots, no semicolons, nothing like that. It's simply bad practice to have primary keys like that. > something like a title or any other arbitrary field, aren't you out of > luck? So then you end up looking at escaping mechanisms and it rapidly > leads to ugly looking URLs. I'm not really looking for the arbitrary string case, and definitely not putting stuff like a title in the primary key. It's a question of a primary key for an RDBMS, a couple of best practice limitations fits in nicely, e.g. integers (mostly) and short strings, like order number as a string, invoice number as a string, stuff like that. > Periodically, I wonder if it's worth implementing this anyway, just for > fun, and then saying if you have multiple primary keys, you can't use > those models in the admin. The mechanics are not that hard in most > places (it's not entirely trivial, since we can't break existing code > that uses the 'pk' attribute on models, etc). Current users would be no > worse of. People using the new feature will do it with their eyes open > and accepting the consequences of their decision (except therein lies > the problem). I haven't gotten as far as pulling the trigger yet, > though, since I always have other stuff to do. Yes, well, I think it might be worth the effort. Imagine how many legacy databases would benefit from a user interface built with django, web or native. However, I do believe that the admin interface should be an integral part of this, it's essential in getting your application up and running quickly. Just my 2c worth /Lars --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Design plus admin question
Hi This is more of a design question then anything. We are using Apache and mod_python in our development server. The whole Django project is kept as subfolder in the Apache data directory. So everybody out here can access it over: http://192.168.1.10/project The project is actually checked out from a subversion code repository. Now every developer checks out the project on his individual machine and works on it. A part of the urls.py: urlpatterns = patterns('', (r'^project/$', 'project.views.index'), (r'^project/login/$', 'django.contrib.auth.views.login', {'template_name': 'accounts/login.html'}), ) Now each development server while running their local copy, need to access the project at: http://127.0.0.1:8000/project and it works. Ideally, we would have wanted only http://127.0.0.1:8000 but we can live with that. Now later on when we go live with, the website would be accessed from: http://www.domain.com. Now, during our testing it fails as the regular expression will not match for top level. How do you manage such settings? In the end we will just checkout the project in the data directory of Apache and it will go live. We dont want to change any settings between test and production so that we dont miss anything or do any unrequired changes. Also, it may happen that the DB settings might be different too so what would be the best way to manage such a setting? I am sure this is a very common setup. Ritesh --~--~-~--~~~---~--~~ 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: Multiple primary keys
On Tue, 2007-08-14 at 06:51 +0200, Lars Stavholm wrote: > Malcolm Tredinnick wrote: > > On Tue, 2007-08-14 at 08:47 +0800, Russell Keith-Magee wrote: > > [...] > >> You will have more difficulty with the Admin application and generic > >> views. Both of these features rely upon the ability to install URLs > >> like: > >> > >> /path/to/object/42/ -> edit object 42 > >> > >> This works fine if you have a single column primary key; however, if > >> you have multiple column primary keys, this isn't so easy to do. To > >> date, every proposed syntax for URL spaces supporting multiple primary > >> keys has either been syntactically ambiguous (e.g., > >> /path/to/object/42,37 - which works unless the primary key has a comma > >> in it), or very inelegant (/path/to/object/42/37/ - which implies a > >> heirarchy where there isn't one). Any proposal for adding multiple > >> primary keys would need to address this very large issue. > > > > Remembering that primary keys are not just integers, so *any* string > > construct you come up with could also be the value of a single primary > > key. (e.g. "42/37/", in Russell's second example, could be a primary key > > value, too). > > I see, not that simple. > > I guess the following idea has been discussed already then: > > Something like... > > /path/to/object/42,37 > > ...where we use a setting like... > > PRIMARY_KEY_SEPARATOR = ',' > > So, if the application needs to use another character to > separate the primary key fields, we could use, for example... > > /path/to/object/[EMAIL PROTECTED] > > PRIMARY_KEY_SEPARATOR = '@' > > ...maybe with a built in restriction of the allowed values > for PRIMARY_KEY_SEPARATOR. How will you know what your users will enter in the primary key? If it's something like a title or any other arbitrary field, aren't you out of luck? So then you end up looking at escaping mechanisms and it rapidly leads to ugly looking URLs. Periodically, I wonder if it's worth implementing this anyway, just for fun, and then saying if you have multiple primary keys, you can't use those models in the admin. The mechanics are not that hard in most places (it's not entirely trivial, since we can't break existing code that uses the 'pk' attribute on models, etc). Current users would be no worse of. People using the new feature will do it with their eyes open and accepting the consequences of their decision (except therein lies the problem). I haven't gotten as far as pulling the trigger yet, though, since I always have other stuff to do. Regards, Malcolm -- The cost of feathers has risen; even down is up! http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: Accessing the content-attribute in request.FILES without loading it into memory
Hi, You'll want to take a look at ticket #2070 [1] for streaming uploads. It has a working patch that will make it to trunk pretty soon I think. I'm not sure how you would handle streaming uploads directly to a S3 bucket, but it shouldn't be too hard to hack the patch from the ticket. [1] http://code.djangoproject.com/ticket/2070 regards, Simon On Aug 14, 3:10 am, Henrik Lied <[EMAIL PROTECTED]> wrote: > Hi there! > > I'm using Amazon S3 for file storage, and I have to send the file > directly from request.FILES. > (I could always save the file locally first, send it to Amazon and > then delete it from my local server, but this would double the wait > for the user.) > > Is there a way to only load chunks of the uploaded file into memory, > instead of loading the whole thing at once? And here comes an even > better question: Would it be useful? > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple primary keys
Malcolm Tredinnick wrote: > On Tue, 2007-08-14 at 08:47 +0800, Russell Keith-Magee wrote: > [...] >> You will have more difficulty with the Admin application and generic >> views. Both of these features rely upon the ability to install URLs >> like: >> >> /path/to/object/42/ -> edit object 42 >> >> This works fine if you have a single column primary key; however, if >> you have multiple column primary keys, this isn't so easy to do. To >> date, every proposed syntax for URL spaces supporting multiple primary >> keys has either been syntactically ambiguous (e.g., >> /path/to/object/42,37 - which works unless the primary key has a comma >> in it), or very inelegant (/path/to/object/42/37/ - which implies a >> heirarchy where there isn't one). Any proposal for adding multiple >> primary keys would need to address this very large issue. > > Remembering that primary keys are not just integers, so *any* string > construct you come up with could also be the value of a single primary > key. (e.g. "42/37/", in Russell's second example, could be a primary key > value, too). I see, not that simple. I guess the following idea has been discussed already then: Something like... /path/to/object/42,37 ...where we use a setting like... PRIMARY_KEY_SEPARATOR = ',' So, if the application needs to use another character to separate the primary key fields, we could use, for example... /path/to/object/[EMAIL PROTECTED] PRIMARY_KEY_SEPARATOR = '@' ...maybe with a built in restriction of the allowed values for PRIMARY_KEY_SEPARATOR. > Our other big goal is not to break the existing single primary key case. Well, if that's a goal, I'm afraid I'm out of luck:| > Preferably no change to existing URLs. I see. My conclusion is that the multiple primary key fields is not going to happen, which is a pity, since introspection then is of limited use. Thanks for your input /Lars --~--~-~--~~~---~--~~ 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: Filter on related model problem...
Regroup generates a list of dicts with two keys - grouper (the value of the field you're grouping by) and list (the list of objects that match that) So in this case, you get entries like {'grouper': , 'list': [, , ...]} :) --~--~-~--~~~---~--~~ 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: cmemcached etc
On 8/13/07, TheMaTrIx <[EMAIL PROTECTED]> wrote: > > No, its not reasonable to assume people know everything about python > from day 1. I really don't think this is an issue of knowing "everything about python". Rather - it's about knowing how to use Google: http://www.google.com/search?hl=en=installing%2Bpython%2Bmodules The first link is called "Installing Python Modules" and it includes instructions for the trivial case. Ned's Mom: You gotta help us, Doc. We've tried nothing and we're fresh out of 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
next page in this category
Imagine you have a Page model with a creation_time field and a many- to-many field of Categories. Clearly you can navigate through each page in creation order one by one with get_next_by_creation_time (which is quite awesome, really). But how might one do the same per category? i.e. for each category a given page is in, provide the next page in that category (ordered by creation time)? James -- James Tauber http://jtauber.com/ journeyman of some http://jtauber.com/blog/ --~--~-~--~~~---~--~~ 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: Filter on related model problem...
Nice--I was thinking about using regroup, but I didn't think this was a "proper" use of it. Thanks! On Aug 13, 8:22 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > view: > > poems = > Poem.objects.filter(approved=True).select_related().order_by('auth_user.use > rname') > > template: > > {% regroup poems by user as grouped %} > {% for group in grouped %} > {{ group.grouper }} > {% for poem in group.list %} > {{ poem.title }} > {% endfor %} > {% endfor %} > > Perhaps something like 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 -~--~~~~--~~--~--~---
Custom primary key using Oracle 10g
Hello I am a beginning Django user and would appreciate help on the following issue. How do I specify a custom primary key in my model when using Oracle 10g I am using the lastest Django version from svn. Thanks for your help Catriona --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Chak de india Video songs / Audio Songs and wallpapers
Chak de india Video songs / Audio Songs and wallpapers www.FunAtoZ.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Chak de india Video songs / Audio Songs and wallpapers
Chak de india Video songs / Audio Songs and wallpapers www.FunAtoZ.com --~--~-~--~~~---~--~~ 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: Filter on related model problem...
Collin Grady wrote: > view: > > poems = > Poem.objects.filter(approved=True).select_related().order_by('auth_user.username') > > template: > > {% regroup poems by user as grouped %} > {% for group in grouped %} > {{ group.grouper }} > {% for poem in group.list %} > {{ poem.title }} > {% endfor %} > {% endfor %} > Can you explain how regroup works? This is probably the solution to my problem i posted a few days ago: subject: grouping, replies: 0. Carl K --~--~-~--~~~---~--~~ 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: error with Admin
Your problem is completely unrelated to INSTALLED_APPS, if your django/ contrib/admin/templates dir is missing. --~--~-~--~~~---~--~~ 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: Filter on related model problem...
view: poems = Poem.objects.filter(approved=True).select_related().order_by('auth_user.username') template: {% regroup poems by user as grouped %} {% for group in grouped %} {{ group.grouper }} {% for poem in group.list %} {{ poem.title }} {% endfor %} {% endfor %} Perhaps something like 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 -~--~~~~--~~--~--~---
Re: Filter on related model problem...
> u = User.objects.filter(poem_set__approved=True) I think you meant: u = User.objects.filter(poem__approved=True) > and then in your template, you can have something like > > {% for user in users %} >User: {{ user }} >{% for poem in user.poems %} > {% if poem.approved %} > {{ poem.title }} > {% endif %} >{% endfor %} > {% endfor %} I would like to do something like that, but I don't want to filter the approved poems in the template. I want to filter them in the view. (Thank for your help though!) --~--~-~--~~~---~--~~ 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: Importing My Own Modules
On Tue, 2007-08-14 at 02:10 +, Brisingman wrote: > > > On Aug 13, 9:14 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > On Tue, 2007-08-14 at 00:26 +, Brisingman wrote: > > > Hi, > > > > > Have 2 problems that may be related but definitely need resolution. > > > > > 1) Want to use my central library ( /home/me/bin) with Django in > > > different projects. Tried to import a module from this library in an > > > app view and got an import error. > > > > *How* are you running the code that is trying to do this? Via manage.py? > > Via apache? Some other way? > > Apache. And that's the reason your .bashrc isn't being executed. Apached doesn't run as a sub-process of bash. Read the mod_python documentation (or the mod_python hints that come with Django) and you'll see how you can set the Python path. Regards, Malcolm -- If at first you don't succeed, destroy all evidence that you tried. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: Installing django on a vm using NAT - SVN 400 bad request
Hi, On Aug 14, 9:36 am, sanchothefat <[EMAIL PROTECTED]> wrote: > Hi, I'm trying to get django going on a debian etch vm I have which > uses NAT to access the web. I found some info that suggested using https:// > but that won't work. > Should I try ubuntu or is there something in the vm settings I need to > change? I'm still quite new to *nix but making progress so any advice > you can give me on what things to try is very welcome. > > Ta very much, > Rob looks like a firewall is avoiding you james --~--~-~--~~~---~--~~ 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: Importing My Own Modules
On Aug 13, 9:14 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2007-08-14 at 00:26 +, Brisingman wrote: > > Hi, > > > Have 2 problems that may be related but definitely need resolution. > > > 1) Want to use my central library ( /home/me/bin) with Django in > > different projects. Tried to import a module from this library in an > > app view and got an import error. > > *How* are you running the code that is trying to do this? Via manage.py? > Via apache? Some other way? Apache. > > > > > 2) sys.path shows /home/me/bin with the other stuff, ie I can import > > my modules from said library into python on the command line. > > However, the IDLE path browser does not show this library ( /home/me/ > > bin ). I need to be able to browse the code in this library in IDLE. > > > I have PYTHONPATH set to /home/me/bin in bash.bashrc. > > Depending upon how you're running the application, it might not be under > a bash process or it might be spawned via something that intentionally > doesn't inherit the whole environment, for security or other reasons. > So .bashrc might not be being executed. > > Regards, > Malcolm > > -- > Monday is an awful way to spend 1/7th of your > life.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: DRY? I have a field lists to manage in 4 places
On 8/14/07, sime <[EMAIL PROTECTED]> wrote: > > Warning, devils advocate post. It's meant to be constructive > criticism. > > I have my fields listed in HTML, in forms.py (newforms), in models.py, > and in my database (post-syncdb). Four places no less. What you have described is three different pieces of information that are similar in the trivial case, and one that you don't need to manage. - fields in HTML - where you want to put field X. Only required if you don't like the default rendering of {{ form.as_table }} - fields on a form. Doesn't necessarily correspond 1-1 with model fields (consider password entry - two form fields, one database field - fields in a model. For very simple forms, these three are identical. If you only need simple forms, form_for_model will let you define the model once, and get a default form without respecifying anything. If you have more complex requirements, then you will need to specify those requirements. The fourth 'duplicate' - the database - is autogenerated, so doesn't require manual interaction. > Before we shout too much about DRY, newforms _for_model needs a tonne > more flexibility, and syncdb needs migration. And I need a pony. :-) Instead of throwing around blanket statements about what is broken, how about making some concrete suggestions. Saying newforms "needs a tonne more flexibility" doesn't give any hint as to what you think isn't flexible. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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: error with Admin
On Aug 13, 8:28 pm, Empty <[EMAIL PROTECTED]> wrote: > On 8/13/07, john <[EMAIL PROTECTED]> wrote: > > > > Are the templates actually present in django/contrib/admin/ > > > templates/ ? > > > there is a directory /usr/lib/python2.5/site-packages/django/contrib/ > > admin/templatetags/... > > > "templatetags" but no "templates" - is this right ? > > You should have a templates directory in that location. Sounds like > something might be wacky with your install. > there is a template folder under /django/template as well as /django/ templatetags but under /django/contrib/admin there is only the template tags. If this is not right there must be a problem with the Ubuntu Feisty packaging since that is what I installed. I will remove the django package, clean out any django folders and reload. Something is wrong - shouldn't be this hard. Could it be some sort of tab problem with "Installed Apps" ? I think having to edit the "Installed Apps" setting is not only cumbersome but can lead to additional errors - is there a better way ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Installing django on a vm using NAT - SVN 400 bad request
Hi, I'm trying to get django going on a debian etch vm I have which uses NAT to access the web. I found some info that suggested using https:// but that won't work. Should I try ubuntu or is there something in the vm settings I need to change? I'm still quite new to *nix but making progress so any advice you can give me on what things to try is very welcome. Ta very much, Rob --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
DRY? I have a field lists to manage in 4 places
Warning, devils advocate post. It's meant to be constructive criticism. I have my fields listed in HTML, in forms.py (newforms), in models.py, and in my database (post-syncdb). Four places no less. Before we shout too much about DRY, newforms _for_model needs a tonne more flexibility, and syncdb needs migration. In my old PHP framework I only had my fields list in 2 places (HTML and database), everything else worked itself out on the fly via introspection. --~--~-~--~~~---~--~~ 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: Adding permissions in a fixture
On Tue, 2007-08-14 at 08:27 +0800, Russell Keith-Magee wrote: > On 8/14/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote: > > > > I asked this before and no one answered, but after having to do this > > manually in the shell for about the fifteenth time, I'm going to ask > > again. > > Can't say I remember seeing this question the first time round. > Apologies for missing it. > > > Let me outline what I'm doing and see if I'm doing something wrong: > ... > > This last step changes the id of the old permissions and my serialized > > test data no longer sets the permissions it's supposed to. Now I have to > > remake my test data. > > > > Is this a real problem, or am I just making it up? > > This could be a real problem. Permissions are all based on > ContentTypes, and the ID's assigned to contenttypes will depend on the > order in which applications are installed. The same problem will > potentially exist with GenericRelations, or anything else relying on > ContentType references. > > Changing the order of the INSTALLED_APPS shouldn't cause this problem > (if you can demonstrate that it does, there might be another issue at > work here). Adding a new application by itself shouldn't cause a > problem either - the new permission ID's should be added with > sequential IDs at the end of the existing IDs. > > However, the following sequence will cause problems: > - Add two applications, and sync > - Write a fixture that uses permissions for those apps > - Add a third application > - Write a fixture that uses permissions on the third app > - Destroy and recreate the database > > In this case, there is no guarantee that the permissions will be > recreated in the same order as they were in the first instance - > hence, serialization problems. > > Does this correspond with the use case you are seeing? Or are your > serialization problems more widespread than this example? > I'm only actually talking about test cases where you start from a fresh database each time. I assume that as you evolve your production database you're smart enough not to, say, serialize the data, rebuild the database willy-nilly, and then cross your fingers and hope the data goes back where it was supposed to. :-) > > If it's a real problem, is there a way around it? Since fixtures are > > such an easy way to create test data, it would seem a really good idea > > if they supported the ability to create data that wouldn't break > > unnecessarily as a result of a project just evolving. > > I agree that this is annoying. > > One possible way around the problem is to serialize your ContentTypes. > This will ensure that the content types in any new database correspond > to their original values. This will require your to rebuild your > contenttype fixture every time you add an new application, but this is > fairly easy to do with ./manage.py dumpdata contenttype > > The only permanent solution I can think of would be to introduce some > sort of query language into the fixtures, which is a road I'd rather > not travel down. Any other suggestions are welcome. That's something I hadn't thought of, but do you run into trouble because Django creates the content-types itself and then you try to load yours afterward? I was getting weird errors and discovered that the way to solve the problem was to *not* dumpdata auth or any other of Django's own apps. Here's something I considered. What if fixtures were a Python module instead of just a folder and you could include a function as part of a fixture. For example, in addition to test.json, I could include a function called test in fixtures/__init__.py that added stuff to the database using the ORM. Most things would still be done through serialization, because it's so handy, but generic relations and permissions and such could be set with a few lines of Python code. Does that seem like too big a hammer for such a small nail? Todd --~--~-~--~~~---~--~~ 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: Multiple primary keys
On Tue, 2007-08-14 at 08:47 +0800, Russell Keith-Magee wrote: [...] > You will have more difficulty with the Admin application and generic > views. Both of these features rely upon the ability to install URLs > like: > > /path/to/object/42/ -> edit object 42 > > This works fine if you have a single column primary key; however, if > you have multiple column primary keys, this isn't so easy to do. To > date, every proposed syntax for URL spaces supporting multiple primary > keys has either been syntactically ambiguous (e.g., > /path/to/object/42,37 - which works unless the primary key has a comma > in it), or very inelegant (/path/to/object/42/37/ - which implies a > heirarchy where there isn't one). Any proposal for adding multiple > primary keys would need to address this very large issue. Remembering that primary keys are not just integers, so *any* string construct you come up with could also be the value of a single primary key. (e.g. "42/37/", in Russell's second example, could be a primary key value, too). Our other big goal is not to break the existing single primary key case. Preferably no change to existing URLs. Regards, Malcolm -- Plan to be spontaneous - tomorrow. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: Importing My Own Modules
On Tue, 2007-08-14 at 00:26 +, Brisingman wrote: > Hi, > > Have 2 problems that may be related but definitely need resolution. > > 1) Want to use my central library ( /home/me/bin) with Django in > different projects. Tried to import a module from this library in an > app view and got an import error. *How* are you running the code that is trying to do this? Via manage.py? Via apache? Some other way? > > 2) sys.path shows /home/me/bin with the other stuff, ie I can import > my modules from said library into python on the command line. > However, the IDLE path browser does not show this library ( /home/me/ > bin ). I need to be able to browse the code in this library in IDLE. > > I have PYTHONPATH set to /home/me/bin in bash.bashrc. Depending upon how you're running the application, it might not be under a bash process or it might be spawned via something that intentionally doesn't inherit the whole environment, for security or other reasons. So .bashrc might not be being executed. Regards, Malcolm -- Monday is an awful way to spend 1/7th of your life. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Accessing the content-attribute in request.FILES without loading it into memory
Hi there! I'm using Amazon S3 for file storage, and I have to send the file directly from request.FILES. (I could always save the file locally first, send it to Amazon and then delete it from my local server, but this would double the wait for the user.) Is there a way to only load chunks of the uploaded file into memory, instead of loading the whole thing at once? And here comes an even better question: Would it be useful? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple primary keys
On 8/14/07, Lars Stavholm <[EMAIL PROTECTED]> wrote: > > Hi all, > > first of all: django rocks! I'm a database application developer Glad you like it! Welcome to the community. > I know that this has been discussed on this list, but what I would > like to know now is: is there any effort going into creating the > "multiple fields in the primary key" feature at all? If so, is there > anything I could do to help, short of trying to implement it myself, > which I doubt that I'll be able to? > > Any input appreciated. At present, there isn't any effort going on in this area. If you want to contribute, this would be a very big contribution. However, be warned - there is a reason we haven't addressed this issue. On a model level, it shouldn't be too difficult to implement - allow primary_key=True to be defined on multiple fields, and interpret those fields appropriately when the table is created. You would also need to modify the query syntax to ensure that queries over pk accept tuples rather than just being a simple alias for the primary key field. You will have more difficulty with the Admin application and generic views. Both of these features rely upon the ability to install URLs like: /path/to/object/42/ -> edit object 42 This works fine if you have a single column primary key; however, if you have multiple column primary keys, this isn't so easy to do. To date, every proposed syntax for URL spaces supporting multiple primary keys has either been syntactically ambiguous (e.g., /path/to/object/42,37 - which works unless the primary key has a comma in it), or very inelegant (/path/to/object/42/37/ - which implies a heirarchy where there isn't one). Any proposal for adding multiple primary keys would need to address this very large issue. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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: Filter on related model problem...
> I have a "poem" model that belongs to "user". The "poem" model an > "approved" attribute. I want to print a list of users and display only > their poems that are approved. > > What do I specify in the Queryset to make this work? > > I want to do something like this: > u = User.objects.filter(poem.approved=True) If you're interested in poems that have been approved, you want something like poems = Poems.objects.filter(approved=True, user=request.user) Or perhaps you *do* want users and their approved poems in which case you'd have something like u = User.objects.filter(...users of interest...) or perhaps u = User.objects.filter(poem_set__approved=True) and then in your template, you can have something like {% for user in users %} User: {{ user }} {% for poem in user.poems %} {% if poem.approved %} {{ poem.title }} {% endif %} {% endfor %} {% endfor %} -tim --~--~-~--~~~---~--~~ 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: error with Admin
On 8/13/07, john <[EMAIL PROTECTED]> wrote: > > On Aug 13, 6:58 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > > Do you have "django.contrib.admin" in INSTALLED_APPS? > > yes > > > > Are the templates actually present in django/contrib/admin/ > > templates/ ? > > there is a directory /usr/lib/python2.5/site-packages/django/contrib/ > admin/templatetags/... > > "templatetags" but no "templates" - is this right ? > You should have a templates directory in that location. Sounds like something might be wacky with your install. > > Are the permissions on that directory and every directory above it > > such that the webserver can read them? > > yes Empty --~--~-~--~~~---~--~~ 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: Adding permissions in a fixture
On 8/14/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote: > > I asked this before and no one answered, but after having to do this > manually in the shell for about the fifteenth time, I'm going to ask > again. Can't say I remember seeing this question the first time round. Apologies for missing it. > Let me outline what I'm doing and see if I'm doing something wrong: ... > This last step changes the id of the old permissions and my serialized > test data no longer sets the permissions it's supposed to. Now I have to > remake my test data. > > Is this a real problem, or am I just making it up? This could be a real problem. Permissions are all based on ContentTypes, and the ID's assigned to contenttypes will depend on the order in which applications are installed. The same problem will potentially exist with GenericRelations, or anything else relying on ContentType references. Changing the order of the INSTALLED_APPS shouldn't cause this problem (if you can demonstrate that it does, there might be another issue at work here). Adding a new application by itself shouldn't cause a problem either - the new permission ID's should be added with sequential IDs at the end of the existing IDs. However, the following sequence will cause problems: - Add two applications, and sync - Write a fixture that uses permissions for those apps - Add a third application - Write a fixture that uses permissions on the third app - Destroy and recreate the database In this case, there is no guarantee that the permissions will be recreated in the same order as they were in the first instance - hence, serialization problems. Does this correspond with the use case you are seeing? Or are your serialization problems more widespread than this example? > If it's a real problem, is there a way around it? Since fixtures are > such an easy way to create test data, it would seem a really good idea > if they supported the ability to create data that wouldn't break > unnecessarily as a result of a project just evolving. I agree that this is annoying. One possible way around the problem is to serialize your ContentTypes. This will ensure that the content types in any new database correspond to their original values. This will require your to rebuild your contenttype fixture every time you add an new application, but this is fairly easy to do with ./manage.py dumpdata contenttype The only permanent solution I can think of would be to introduce some sort of query language into the fixtures, which is a road I'd rather not travel down. Any other suggestions are welcome. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Importing My Own Modules
Hi, Have 2 problems that may be related but definitely need resolution. 1) Want to use my central library ( /home/me/bin) with Django in different projects. Tried to import a module from this library in an app view and got an import error. 2) sys.path shows /home/me/bin with the other stuff, ie I can import my modules from said library into python on the command line. However, the IDLE path browser does not show this library ( /home/me/ bin ). I need to be able to browse the code in this library in IDLE. I have PYTHONPATH set to /home/me/bin in bash.bashrc. I'm running Django .96 (on Ubuntu Dapper) Grateful for any input. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
a great new websit look here
http://www.pennergame.de/ref.php?uid=4762 --~--~-~--~~~---~--~~ 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: cmemcached etc
No, its not reasonable to assume people know everything about python from day 1. I only just started using Python and primarily started using it because of Django. I had no problem installing Python, hooking it into Apache, configuring Django, etc etc, sys administration is my main field of expertise. But I'm not a programmer(eventhough I know my way around PHP better then most devs I know), am brand new to python and brand new to djagno. Where is the problem in putting: -- To install type: python setup.py install -- in the INSTALL file anyway? Why have an INSTALL file in every archive you release if you can't even be bothered to type that tiny line in it? You don't even have to write it with every release you make, just the very first time. Anyway, thanks for the information on the tutorial and the info about how to install these modules. On Aug 14, 1:28 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 8/13/07, TheMaTrIx <[EMAIL PROTECTED]> wrote: > > > Neither of these apps has any kind of information on their sites or in > > the archives on how you can install those modules so you can enable > > memcached in the django config. They seem to think that everyone knows > > everything about Python or something ... > > To be fair, you're trying to use a python library; it's reasonable to > assume you know how to use python. Do you think every library should > explain the same stuff every time? > > You should go read the python tutorial:http://docs.python.org/tut/ > > But if you're impatient: > wgetftp://ftp.tummy.com/pub/python-memcached/python-memcached-1.38.tar.gz > tar xfz python-memcached-1.38.tar.gz > cd python-memcached-1.38 > sudo python setup.py install --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Filter on related model problem...
I have a "poem" model that belongs to "user". The "poem" model an "approved" attribute. I want to print a list of users and display only their poems that are approved. What do I specify in the Queryset to make this work? I want to do something like this: u = User.objects.filter(poem.approved=True) But that obviously is the incorrect syntax. model: class Poem(models.Model): title = models.CharField('Title', maxlength=127) body = models.TextField('Body Text') approved = models.NullBooleanField() user = models.ForeignKey(User) 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Over 50 million unclaimed accts. Is one yours?
Test Message --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Over 50 million unclaimed accts. Is one yours?
Test Message --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
look @ this nice sit it´s great
http://www.pennergame.de/ref.php?uid=4762 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Over 50 million unclaimed accts. Is one yours?
Test Message --~--~-~--~~~---~--~~ 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: cmemcached etc
On 8/13/07, TheMaTrIx <[EMAIL PROTECTED]> wrote: > Neither of these apps has any kind of information on their sites or in > the archives on how you can install those modules so you can enable > memcached in the django config. They seem to think that everyone knows > everything about Python or something ... To be fair, you're trying to use a python library; it's reasonable to assume you know how to use python. Do you think every library should explain the same stuff every time? You should go read the python tutorial: http://docs.python.org/tut/ But if you're impatient: wget ftp://ftp.tummy.com/pub/python-memcached/python-memcached-1.38.tar.gz tar xfz python-memcached-1.38.tar.gz cd python-memcached-1.38 sudo python setup.py install --~--~-~--~~~---~--~~ 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: cmemcached etc
What platform are you trying to install this onto? -joe On 8/13/07, TheMaTrIx <[EMAIL PROTECTED]> wrote: > > Ok, I've used memcached for quite some time with PHP sites and that > was rather easy. > > Now I see you can use it with Django, but to get memcached support you > need to either install cmemcached or python-memcached. > > Neither of these apps has any kind of information on their sites or in > the archives on how you can install those modules so you can enable > memcached in the django config. They seem to think that everyone knows > everything about Python or something ... > > Anyone know how to do this? > > > > > --~--~-~--~~~---~--~~ 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: error with Admin
On Aug 13, 6:58 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > Do you have "django.contrib.admin" in INSTALLED_APPS? yes > Are the templates actually present in django/contrib/admin/ > templates/ ? there is a directory /usr/lib/python2.5/site-packages/django/contrib/ admin/templatetags/... "templatetags" but no "templates" - is this right ? > > Are the permissions on that directory and every directory above it > such that the webserver can read them? yes --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Adding permissions in a fixture
I asked this before and no one answered, but after having to do this manually in the shell for about the fifteenth time, I'm going to ask again. Is there a way to add user permissions to a test fixture that isn't brittle? Let me outline what I'm doing and see if I'm doing something wrong: 1. I serialize the database with permission data and the permission is stored as a foreign key, which means the serialized data just includes its id. 2. I use the test data for a while, very happily. 3. I add a new app to my project, which has its own permissions (or even maybe just change the order my apps appear in INSTALLED_APPS). This last step changes the id of the old permissions and my serialized test data no longer sets the permissions it's supposed to. Now I have to remake my test data. Is this a real problem, or am I just making it up? If it's a real problem, is there a way around it? Since fixtures are such an easy way to create test data, it would seem a really good idea if they supported the ability to create data that wouldn't break unnecessarily as a result of a project just evolving. Hoping for some way to avoid "from django.contrib.auth.models import User, Permission" over and over again in the shell, Todd --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
cmemcached etc
Ok, I've used memcached for quite some time with PHP sites and that was rather easy. Now I see you can use it with Django, but to get memcached support you need to either install cmemcached or python-memcached. Neither of these apps has any kind of information on their sites or in the archives on how you can install those modules so you can enable memcached in the django config. They seem to think that everyone knows everything about Python or something ... Anyone know how to do this? --~--~-~--~~~---~--~~ 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: Django database API - What is it good for?
Also, if I'm not mistaken, when you use the database api, the input validation steps are taken care of by the framework, you don't just tell in the models what format fields should be in the database, but at the same time are telling the framework what input it should accept for that field. If a field is EmailField, it'll only accept an actual [EMAIL PROTECTED] type input. It'll also escape everything correctly for you. Why is this important you ask? Using the database api almost completely removes all the SQL injection whoes developers have so they can focus on the important stuff. The philosophy behind django is to automate the repetitive and boring stuff from developing highend websites. I for one am very happy with this because I spent most of my PHP development time fixing SQL injection bugs in peoples apps (writing loads and loads of validation code) and creating admin interfaces for websites that up to that point used nothing but phpMyAdmin to do the administration of their sites. If your going to use pure SQL instead, you don't just have to write all those query's (in the long run, when using the API you'll end up writing much less code), but will also have to write routines to clean up the input into your app, while they are already part of the framework On Aug 13, 11:20 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 8/13/07, Amirouche <[EMAIL PROTECTED]> wrote: > > > What do you mean, I can't understand. > > OK, suppose you are running an online store, so you have a database > table "orders", which lists orders customers have placed, and another > "addresses" which lists the addresses to ship the orders to. To > calculate the shipping cost for an order, you need the total amount of > the order and the address it ships to; calculating it with an > application which does pure raw SQL looks like this: > > query = "SELECT orders.amount, addresses.address FROM orders INNER > JOIN addresses ON addresses.id = orders.address_id WHERE orders.id = > %s" > cursor.execute(query, [23]) > row = cursor.fetchall()[0] > shipping_amount = calculate_shipping(amount=row[0], address=row[1]) > > Doing it with an ORM looks like this: > > order = Order.objects.get(id=23) > shipping_amount = order.calculate_shipping() > > The fact that the ORM automatically gives you instances of > domain-specific classes means that you immediately have access to your > customized business logic, and that you can encapsulate it in those > classes and rely on their availability, which improves the design of > your code. It also significantly cuts down the amount of code you need > to write, and makes it clearer what's going on: you're calculating the > shipping price of Order #23. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: Proper way to extend contrib.auth
Copying the code out will not work. Nothing in django will be looking in your new location, so your changes will be ignored. If you absolutely must change the User model itself, you are stuck with editing the django source directly. --~--~-~--~~~---~--~~ 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: error with Admin
Do you have "django.contrib.admin" in INSTALLED_APPS? Are the templates actually present in django/contrib/admin/ templates/ ? Are the permissions on that directory and every directory above it such that the webserver can read 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django database API - What is it good for?
> >>> users = User.objects.filter(groups__contains="Staff") ? This line doesn't work because "groups" is a ManyToManyField, not a CharField, so __contains="Staff" doesn't make any sense. Something like users = User.objects.filter(groups__name="Staff") should work a little better :) --~--~-~--~~~---~--~~ 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: Debugging production site.
On Aug 13, 2:11 pm, Merric Mercer <[EMAIL PROTECTED]> wrote: > Is there anyway to trap the debug information - so it is logged - but > not visible to users? A good starting point is to use the ADMINS setting, which will give you a way to receive error reports via e-mail when debugging is off: http://www.djangoproject.com/documentation/settings/#admins Matt --~--~-~--~~~---~--~~ 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: SlugField not prepopulating?
Thanks for such a quick reply Richard. Yep think it was a combination of not displaying and also not having an additional comma at the end of the prepopulate_from tuple. On Aug 13, 10:26 pm, RichardH <[EMAIL PROTECTED]> wrote: > Mike, welcome to Django. > The prepopulate_from relies on Javascript in the admin pages, so only > works in the site admin interface. However you have also set > editable=False, so it will not be seen in the admin pages anyway.>From the > Model Reference documentation: > > "SlugField ... Accepts an extra option, prepopulate_from, which is a > list of fields from which to auto-populate the slug, via JavaScript, > in the object's admin form" > What you need is the slugify function from > django.template.defaultfilters in your save function to set the slug. > or there is an alternative at:http://www.djangosnippets.org/snippets/168/ > > Richard > > On Aug 13, 9:25 pm, MikeHowarth <[EMAIL PROTECTED]> wrote: > > > Hi > > > I was wondering whether anyone could help me, I just starting out with > > Django and am attempting to write a simple web app. Ideally I'd like > > to use a slug field populated based on the name of my product. > > > However the slug field is not being populated, my model looks like > > this: > > > class Product(models.Model): > > > name = models.CharField(maxlength=255) > > category = models.ForeignKey(Category) > > slug = > > models.SlugField(prepopulate_from=("name",),unique=True,editable=False) > > description = models.TextField() > > size = models.CharField(maxlength=50) > > price = models.FloatField(max_digits=5, decimal_places=2) > > delivery = models.ForeignKey(Delivery) > > in_stock = models.BooleanField() > > display = models.BooleanField() > > pub_date = models.DateTimeField(editable=False) > > > def __str__(self): > > return self.name > > > def save(self): > > if not self.id: > > self.pub_date = datetime.datetime.now() > > super(Product, self).save() > > > Any help would be greatly appreciated --~--~-~--~~~---~--~~ 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: SlugField not prepopulating?
Mike, welcome to Django. The prepopulate_from relies on Javascript in the admin pages, so only works in the site admin interface. However you have also set editable=False, so it will not be seen in the admin pages anyway. >From the Model Reference documentation: "SlugField ... Accepts an extra option, prepopulate_from, which is a list of fields from which to auto-populate the slug, via JavaScript, in the object's admin form" What you need is the slugify function from django.template.defaultfilters in your save function to set the slug. or there is an alternative at: http://www.djangosnippets.org/snippets/168/ Richard On Aug 13, 9:25 pm, MikeHowarth <[EMAIL PROTECTED]> wrote: > Hi > > I was wondering whether anyone could help me, I just starting out with > Django and am attempting to write a simple web app. Ideally I'd like > to use a slug field populated based on the name of my product. > > However the slug field is not being populated, my model looks like > this: > > class Product(models.Model): > > name = models.CharField(maxlength=255) > category = models.ForeignKey(Category) > slug = > models.SlugField(prepopulate_from=("name",),unique=True,editable=False) > description = models.TextField() > size = models.CharField(maxlength=50) > price = models.FloatField(max_digits=5, decimal_places=2) > delivery = models.ForeignKey(Delivery) > in_stock = models.BooleanField() > display = models.BooleanField() > pub_date = models.DateTimeField(editable=False) > > def __str__(self): > return self.name > > def save(self): > if not self.id: > self.pub_date = datetime.datetime.now() > super(Product, self).save() > > Any help would be greatly appreciated --~--~-~--~~~---~--~~ 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: Django database API - What is it good for?
On 8/13/07, Amirouche <[EMAIL PROTECTED]> wrote: > What do you mean, I can't understand. OK, suppose you are running an online store, so you have a database table "orders", which lists orders customers have placed, and another "addresses" which lists the addresses to ship the orders to. To calculate the shipping cost for an order, you need the total amount of the order and the address it ships to; calculating it with an application which does pure raw SQL looks like this: query = "SELECT orders.amount, addresses.address FROM orders INNER JOIN addresses ON addresses.id = orders.address_id WHERE orders.id = %s" cursor.execute(query, [23]) row = cursor.fetchall()[0] shipping_amount = calculate_shipping(amount=row[0], address=row[1]) Doing it with an ORM looks like this: order = Order.objects.get(id=23) shipping_amount = order.calculate_shipping() The fact that the ORM automatically gives you instances of domain-specific classes means that you immediately have access to your customized business logic, and that you can encapsulate it in those classes and rely on their availability, which improves the design of your code. It also significantly cuts down the amount of code you need to write, and makes it clearer what's going on: you're calculating the shipping price of Order #23. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Debugging production site.
I'm very occasionally getting errors reported to me on our production site by our members. However, we cannot replicate the problem ourself and because debugging is turned off the members are not giving me any real clues. Is there anyway to trap the debug information - so it is logged - but not visible to users? Many thanks MerMer --~--~-~--~~~---~--~~ 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: Using Django to generate Flash/Flex content
On Aug 13, 8:59 pm, SamFeltus <[EMAIL PROTECTED]> wrote: > Or, am I missing something and it is a bad idea? I am curious what > more experienced coders think? > > Sam the Gardener I'm not experienced coder, but I don't think that it's a bad idea, but it looks like it's not the primary purpose of Django, you have already noticed that there isn't any ajax-love in the main source... but some people are already thinking about Django+Flex some google search may help you ;) --~--~-~--~~~---~--~~ 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: Django database API - What is it good for?
On Aug 13, 3:19 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 8/13/07, sagi s <[EMAIL PROTECTED]> wrote: > > > Surely not. It is... darn - Can I just use SQL and be done with it? > > Of course. > > But keep in mind that, when programming in an object-oriented > language, it's often more useful to get back a set of domain-specific > objects -- which requires using Django's ORM -- than to get back a > list of tuples, which is what a simple SQL query would give you. What do you mean, I can't understand. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
error with Admin
I am just working on my first project. I successfully created a couple of models but get the following error when I poin the browser at /admin/ Any ideas ? thks. Running on Ubuntu Feisty w/ .96 backport. 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: /usr/lib/python2.5/site-packages/django/template/ loader.py in find_template_source, line 72 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: Traceback (innermost last) Switch to copy-and-paste view * /usr/lib/python2.5/site-packages/django/core/handlers/base.py in get_response 70. # Apply view middleware 71. for middleware_method in self._view_middleware: 72. response = middleware_method(request, callback, callback_args, callback_kwargs) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
SlugField not prepopulating?
Hi I was wondering whether anyone could help me, I just starting out with Django and am attempting to write a simple web app. Ideally I'd like to use a slug field populated based on the name of my product. However the slug field is not being populated, my model looks like this: class Product(models.Model): name = models.CharField(maxlength=255) category = models.ForeignKey(Category) slug = models.SlugField(prepopulate_from=("name",),unique=True,editable=False) description = models.TextField() size = models.CharField(maxlength=50) price = models.FloatField(max_digits=5, decimal_places=2) delivery = models.ForeignKey(Delivery) in_stock = models.BooleanField() display = models.BooleanField() pub_date = models.DateTimeField(editable=False) def __str__(self): return self.name def save(self): if not self.id: self.pub_date = datetime.datetime.now() super(Product, self).save() Any help would be greatly appreciated --~--~-~--~~~---~--~~ 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: doctest and response.template and response.context problem
Oops.. My fault here. I just realized that everything is ok with tests, problem was with my ./manage.py shell session. Solution is to call: >>> from django.test.utils import setup_test_environment >>> setup_test_environment() Thanks for your help. Jakub On 13 Sie, 20:31, eXt <[EMAIL PROTECTED]> wrote: > Yes, I know that. I use ./manage.py test. I'll add that my django is > latest version from trunk. Any more hints? > > Jakub > > On 13 Sie, 13:19, "Russell Keith-Magee" <[EMAIL PROTECTED]> > wrote: > > > On 8/13/07, eXt <[EMAIL PROTECTED]> wrote: > > > > So here is a template and a context. Why I can't access it in my > > > doctest via response.template and response.context? > > > How are you running your doctest? > > > In order to capture the template rendering details, Django needs to > > add some instrumentation to the template rendering system. If you run > > your tests using ./manage.py test, this instrumentation is added > > automatically. If the instrumentation isn't installed (for example, if > > you are manually running your doctest), you will get 'no template, no > > context' returned through the test system. > > > Yours, > > Russ Magee %-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Great new Website
http://www.pennergame.de/ref.php?uid=4762 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Win 3000 Dollar evey month
Dear I recently joined AGLOCO because of a friend recommended it to me. I am now promoting it to you because I like the idea and I want you to share in what I think will be an exciting new Internet concept. AGLOCO's story is simple: Do you realize how valuable you are? Advertisers, search providers and online retailers are paying billions to reach you while you surf. How much of that money are you making? NONE! AGLOCO thinks you deserve a piece of the action. AGLOCO collects money from those companies on behalf of its members. (For example, Google currently pays AOL 10 cents for every Google search by an AOL user. And Google still has enough profit to pay $1.6 billion dollars for YouTube, an 18-month old site full of content that YouTube's users did not get paid for! AGLOCO will work to get its Members their share of this and more. AGLOCO is building a new form of online community that they call an Economic Network. They are not only paying Members their fair share, but they're building a community that will generate the kind of fortune that YouTube made. But instead of that wealth making only a few people rich, the entire community will get its share. What's the catch? No catch - no spyware, no pop-ups and no spam - membership and software are free and AGLOCO is 100% member owned. Privacy is a core value and AGLOCO never sells or rents member information. So do both of us a favor: Sign up for AGLOCO right now! If you use this link to sign up, I automatically get credit for referring you and helping to build AGLOCO. http://www.agloco.com/r/BBGP3820 Thanks Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Win 3000 dollar
Dear I recently joined AGLOCO because of a friend recommended it to me. I am now promoting it to you because I like the idea and I want you to share in what I think will be an exciting new Internet concept. AGLOCO's story is simple: Do you realize how valuable you are? Advertisers, search providers and online retailers are paying billions to reach you while you surf. How much of that money are you making? NONE! AGLOCO thinks you deserve a piece of the action. AGLOCO collects money from those companies on behalf of its members. (For example, Google currently pays AOL 10 cents for every Google search by an AOL user. And Google still has enough profit to pay $1.6 billion dollars for YouTube, an 18-month old site full of content that YouTube's users did not get paid for! AGLOCO will work to get its Members their share of this and more. AGLOCO is building a new form of online community that they call an Economic Network. They are not only paying Members their fair share, but they're building a community that will generate the kind of fortune that YouTube made. But instead of that wealth making only a few people rich, the entire community will get its share. What's the catch? No catch - no spyware, no pop-ups and no spam - membership and software are free and AGLOCO is 100% member owned. Privacy is a core value and AGLOCO never sells or rents member information. So do both of us a favor: Sign up for AGLOCO right now! If you use this link to sign up, I automatically get credit for referring you and helping to build AGLOCO. http://www.agloco.com/r/BBGP3820 Thanks Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us. --~--~-~--~~~---~--~~ 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: Feed question
That looks like it... thanks! On Aug 12, 8:10 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > http://www.djangoproject.com/documentation/syndication_feeds/#a-compl... > > The example here is pretty much what you want, you just need to change > how you lookup the objects for the feed. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Repair Your (Microsoft) Operating System
Windows XP tips and tricks. Learn how to bypass very common windows problems, to speed up your system and make it more reliable with useful tips and tricks. http://windowsxpsp2pro.blogspot.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Multiple primary keys
Hi all, first of all: django rocks! I'm a database application developer and not a web developer. I'm not even fluent in python. Despite that, the django framework has made it possible for me to develop web based database applications with relative ease. And, I can use the model and the database api for native applications using WxPython. This is really great and this got to be the most productive environment ever. This is what the 4GL languages tried to accomplish back in the 90's, and they all failed miserably. However, there's one significant piece I'm missing when introspecting old database applications and trying to create new user interfaces for them, and that's the lack of multiple fields in the primary key for a table. I know that this has been discussed on this list, but what I would like to know now is: is there any effort going into creating the "multiple fields in the primary key" feature at all? If so, is there anything I could do to help, short of trying to implement it myself, which I doubt that I'll be able to? Any input appreciated. /Lars --~--~-~--~~~---~--~~ 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: Django database API - What is it good for?
On 8/13/07, sagi s <[EMAIL PROTECTED]> wrote: > Surely not. It is... darn - Can I just use SQL and be done with it? Of course. But keep in mind that, when programming in an object-oriented language, it's often more useful to get back a set of domain-specific objects -- which requires using Django's ORM -- than to get back a list of tuples, which is what a simple SQL query would give you. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django database API - What is it good for?
I've been playing around with Django for a couple of weeks. I'm finding myself spending most of my type tinkering with the Database API to try to wrestle the information I need out of my database. At this point it looks to me like I have replaced one set of incantations (SQL) for another (Database API's query languages). I must be missing the point coz I'm starting the miss SQL... For example I want to get all the Users belonging to the "Staff" Group (User and Group are Django models so it's not like I'm laying out my models poorly). Is it: >>> users = User.objects.filter(groups__contains="Staff") ? Surely not. It is... darn - Can I just use SQL and be done with it? Sorry if I'm iconoclasting stuff here. --~--~-~--~~~---~--~~ 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: doctest and response.template and response.context problem
Yes, I know that. I use ./manage.py test. I'll add that my django is latest version from trunk. Any more hints? Jakub On 13 Sie, 13:19, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 8/13/07, eXt <[EMAIL PROTECTED]> wrote: > > > > > So here is a template and a context. Why I can't access it in my > > doctest via response.template and response.context? > > How are you running your doctest? > > In order to capture the template rendering details, Django needs to > add some instrumentation to the template rendering system. If you run > your tests using ./manage.py test, this instrumentation is added > automatically. If the instrumentation isn't installed (for example, if > you are manually running your doctest), you will get 'no template, no > context' returned through the test system. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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: Disabling python-caching with mod_python, Apache 2.2
Thank you, Ethan. On Aug 13, 8:02 pm, Ethan Miller <[EMAIL PROTECTED]> wrote: > On 8/13/07 10:55 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > However, it seems like the requested pages are cached. Not in the > > regular way though, it is as though the compiled Python procedures are > > compiled, while the data is still up to date. > > > I'm wondering if this is a problem with mod_python and does anyone > > know how to turn this "python-caching" off? > > Check this > section:http://www.djangoproject.com/documentation/modpython/#running-a-devel... > server-with-mod-python > > If you don't have enough privileges to restart or configure Apache (like me > on a dreamhost acct) you can also kill your python process 'pkill python' > > - Ethan --~--~-~--~~~---~--~~ 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: application/xhtml+xml MIME won't take
For the site in question yes. It'll be an intranet site where only a tested version of Firefox is allowed for web browsing and they demanded the latest stable versions of all standards to be used. And for other sites where xhtml 1.1 is wanted, I'm planning to use a middleware that'll dynamically change the header depending on the browser. And for why we won't use that on this site is that its another trap for users to see if they didn't tamper with the computers they worked on and installed an app that isn't allowed by company policy. Most of the previous work I did for this company is design ADS policy's and scripts to make sure people don't change anything on these workstations, if they call up to say their "browser" gives a download prompt instead of giving the intranet site, the helpdesk techies only need to go over there and slap them over the head instead of wondering why some users are complaining that some parts of the site doesn't work. The idea there is that once they log off a computer, it needs to be as if no one ever worked on it since its completely Gigabit connected in there, installing apps at login is about as transparent as loading a roaming profile. All their personal stuff is loaded at login, including apps they specifically might need, apps that can run of the network (office for example) are mounted at login. For me personally the idea has always been to stay on the stable edge of the standards. I've always done this with php in the past and I'll do the same in the future with Django. On Aug 13, 7:09 pm, "John Lenton" <[EMAIL PROTECTED]> wrote: > On 8/13/07, TheMaTrIx <[EMAIL PROTECTED]> wrote: > > > > > I'm developing a site that needs to be xhtml 1.1, my page validates > > just fine except that the server keeps spitting it out as text/html > > instead of application/xhtml+xml. > > > How the heck do I make django set application/xhtml+xml for the pages > > it serves? > > > I tried changing the text/html entry in my mime.types file for apache > > to application/xhtml+xml but that does squat. > > do you want to do that, given that a large portion of your (average) > clients will now get a download dialog instead of a web page? > > -- > John Lenton ([EMAIL PROTECTED]) -- Random fortune: > The trouble with a lot of self-made men is that they worship their creator. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Using Django to generate Flash/Flex content
I was wondering if there was any work on the web to use Django to generate Flash and Flex content, instead of HTML content? Flash is rapidly evolving into a more technologically advanced web display technology. HTML rules for text, but is pretty much useless for displaying other sorts of ideas and information. I've rolled my own experiments for generating/editing Flash content in TurboGears and Django, and it seems a natural way to supplement the assorted Flash content creation tools. Maybe I am missing something, but it seems like a large gap in the Python web stack. Sam the Gardener http://samfeltus.com --~--~-~--~~~---~--~~ 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: Disabling python-caching with mod_python, Apache 2.2
On 8/13/07 10:55 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > However, it seems like the requested pages are cached. Not in the > regular way though, it is as though the compiled Python procedures are > compiled, while the data is still up to date. > > I'm wondering if this is a problem with mod_python and does anyone > know how to turn this "python-caching" off? Check this section: http://www.djangoproject.com/documentation/modpython/#running-a-development- server-with-mod-python If you don't have enough privileges to restart or configure Apache (like me on a dreamhost acct) you can also kill your python process 'pkill python' - Ethan --~--~-~--~~~---~--~~ 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: basic testing procedure?
> self.assertEquals(list(self.movie.details_genre.all()), "[ Action-Komödie>, ]") > ... > > output: > AssertionError: [, ] ! > = '[, \xc3\xb6die>]' First, it looks like you're comparing a list of objects to a string. I'm not sure if QuerySets override the magic method to determine if they're equal. However, it should be fairly trivial: genres = self.movie.details_genre.all() expected_results = ['Action-Komödie', 'Komödie'] for genre, test in zip(genres, expected_results): self.assert(genere.description == test) This assumes they'll always come back in the same order. To be sure, you may want to either stick a Meta class in your model. Or you could do something like allowed_results = set(['Action-Komödie', 'Komödie']) for genre in genres: self.assert(genere.description in allowed_results) depending on what you're trying to test. -tim --~--~-~--~~~---~--~~ 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: SQL problem : how to use id thats autoincremented in statement
[EMAIL PROTECTED] wrote: > hi all, > > i have a problem with the current project i am working on.actual thr's > a table X with a field ID(autoincrement) and a field named HASH.which > is md5 of the id.now should i have to make two queries ..first one to > find out whats going to be next id and then insert the hash of it ..or > there is anotherway to do it.In SQL it world fine if i execute > following statement : > > SET @max_id=(SELECT max(ID) from table_X);insert into table_X(HASH) > values(md5(@max_id+1)); > > so please tell me a good solution ..i don't want to query two time.btw > i am using mysql as database backend. A good solution is somewhat dependent on understanding the problem. Why do you need to store an md5 of the ID? a shot in the dark solution is: create a db trigger SET hash = md5(id) (not sure exactly the trigger syntax, but mysql does have an md5: http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html#function_md5 Carl K --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Disabling python-caching with mod_python, Apache 2.2
Recently I begun using Apache instead of the debugging server that comes with Django. After having a rough time configuring and successfully installing mod_python and Django, my projects are once again working. However, it seems like the requested pages are cached. Not in the regular way though, it is as though the compiled Python procedures are compiled, while the data is still up to date. I'm wondering if this is a problem with mod_python and does anyone know how to turn this "python-caching" off? For your information, it doesn't happen with the Django "runserver". --~--~-~--~~~---~--~~ 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: no cookie vs. expired cookie
> Basically, I want a different message for people that presumably have > never seen the site, and those that just need to login again. Could you use two cookies, one that doesn't expire that let's you know that they've been to the site, and another that expires in 2 weeks? Bob --~--~-~--~~~---~--~~ 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: application/xhtml+xml MIME won't take
On 8/13/07, TheMaTrIx <[EMAIL PROTECTED]> wrote: > > I'm developing a site that needs to be xhtml 1.1, my page validates > just fine except that the server keeps spitting it out as text/html > instead of application/xhtml+xml. > > How the heck do I make django set application/xhtml+xml for the pages > it serves? > > I tried changing the text/html entry in my mime.types file for apache > to application/xhtml+xml but that does squat. do you want to do that, given that a large portion of your (average) clients will now get a download dialog instead of a web page? -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: The trouble with a lot of self-made men is that they worship their creator. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
SQL problem : how to use id thats autoincremented in statement
hi all, i have a problem with the current project i am working on.actual thr's a table X with a field ID(autoincrement) and a field named HASH.which is md5 of the id.now should i have to make two queries ..first one to find out whats going to be next id and then insert the hash of it ..or there is anotherway to do it.In SQL it world fine if i execute following statement : SET @max_id=(SELECT max(ID) from table_X);insert into table_X(HASH) values(md5(@max_id+1)); so please tell me a good solution ..i don't want to query two time.btw i am using mysql as database backend. Gaurav verma --~--~-~--~~~---~--~~ 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[2]: XML output
Daniel, > I think you're wrong on this one ...unfortunately :) XSLT 2 and XPath > 2 are mighty things... Yeah. Checked. Just a rumor. I was so excited when heard that for the first time. However files can be processed by the third-party application supporting the 2.0 standard (Saxon f.e.) -- Best regards, Alex mailto:[EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: XML output
On Aug 12, 7:18 am, Alex Nikolaenkov <[EMAIL PROTECTED]> wrote: > You wrote 12 ??? 2007 ?., 1:41:39: > > > Alex Nikolaenkov <[EMAIL PROTECTED]> writes: > >> Hello guys, > >> I like just about everything in django, but at this point of me reading > >> django > >> book I can't imagine the way of xmlizing django. > > >> Is there a way to use XSLT templates instead of standard django > >> template language? > > I have some stuff that is being used for a big project. Works quite > > well... > > Hehe... I've heard that python already supports XSLT 2 & XPATH 2. I think you're wrong on this one ...unfortunately :) XSLT 2 and XPath 2 are mighty things... > very convenient to to use these standards. BTW does python support > XQuery, XInclude, XLink, XPointer and stuff like that? 4Suite supports all the techs you mentioned, except XQuery I think. It also supports XUpdate. XInclude is also supported by lxml, maybe some others support it. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
application/xhtml+xml MIME won't take
I'm developing a site that needs to be xhtml 1.1, my page validates just fine except that the server keeps spitting it out as text/html instead of application/xhtml+xml. How the heck do I make django set application/xhtml+xml for the pages it serves? I tried changing the text/html entry in my mime.types file for apache to application/xhtml+xml but that does squat. --~--~-~--~~~---~--~~ 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: Re[2]: XML output
> Hehe... I've heard that python already supports XSLT 2 & XPATH 2. It's > very convenient to to use these standards. BTW does python support > XQuery, XInclude, XLink, XPointer and stuff like that? Are you sure about XSLT 2 and XPATH 2? I haven't seen version 2 support in python, only XSLT and XPATH version 1. If XPATH 2 does exist than its not much of a leap to XQuery mcb. On 8/12/07, Alex Nikolaenkov <[EMAIL PROTECTED]> wrote: > > You wrote 12 ??? 2007 ?., 1:41:39: > > > Alex Nikolaenkov <[EMAIL PROTECTED]> writes: > > >> Hello guys, > >> I like just about everything in django, but at this point of me reading > >> django > >> book I can't imagine the way of xmlizing django. > >> > >> Is there a way to use XSLT templates instead of standard django > >> template language? > > > I have some stuff that is being used for a big project. Works quite > > well... > Hehe... I've heard that python already supports XSLT 2 & XPATH 2. It's > very convenient to to use these standards. BTW does python support > XQuery, XInclude, XLink, XPointer and stuff like that? > > > But big project is nearing completion so I don't have much time right > > now to upload it to snippetts. > > It will be perfect if you upload your solutions sometime. Good ideas > should be shared. > > -- > Best regards, > Alex mailto:[EMAIL PROTECTED] > > > > > --~--~-~--~~~---~--~~ 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: basic testing procedure?
thanks. that works. now I´m getting an error due to some unicode related stuff: ... self.assertEquals(list(self.movie.details_genre.all()), "[, ]") ... output: AssertionError: [, ] ! = '[, ]' thanks, patrick On 13 Aug., 17:03, Tim Chase <[EMAIL PROTECTED]> wrote: > > now, I just ran into a problem with unittests: > > > ... > > self.assertEquals(self.movie.details_country.all(), []) > > ... > > > the output is: > > AssertionError: [] != [] > > > isn´t that supposed to work? > > all() returns a queryset object that has list-like behaviors. > However, it isn't a list and thus (as you discovered) likely has > trouble when testing for equality with a list-object. You can > try either > > self.assertEquals(list(self.movie.details_country.all()), []) > > or something like > > self.assertEquals(self.movie.details_country.count(), 0) > > -tim --~--~-~--~~~---~--~~ 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: basic testing procedure?
using doctests works fine so far. now, I just ran into a problem with unittests: ... self.assertEquals(self.movie.details_country.all(), []) ... the output is: AssertionError: [] != [] isn´t that supposed to work? thanks, patrick On 13 Aug., 13:14, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 8/13/07, patrickk <[EMAIL PROTECTED]> wrote: > > > > > thanks russ. > > > is it possible to make the testing-output more verbose? I tried "-v", > > but that doesn´t work. It´d be nice to see what tests have been > > running and what the output is (more than just "OK"). > > --verbosity=[0|1|2]. It's in the help when you run ./manage.py. > > > in the django-docs it says, that doctests provide automatic > > documentation. what exactly does that mean? does it refer to the tests > > written within the model or is it possible to generate some output > > (html-file)? > > > concerning the django-docs: > > from my point of view, the description of where to define the tests is > > not easy to understand. > > e.g., it says "You can put doctest strings on any object in your > > models.py, but it's common practice to put application-level doctests > > in the module docstring, and model-level doctests in the docstring for > > each model." > > whats the "module docstring"? > > Erm... the docstring for the module: > > http://www.python.org/dev/peps/pep-0257/ > > We need to walk a fine line here. If Python's documentation was poor, > there would be a good argument to be made here, but Python has > extensive documentation on the doctest and unittest modules. There > really isn't anything served by us duplicating Python's documentation > - in fact, it could be considered detrimental, because it suggests > that Django's test framework is somehow different to Python's. > > > one more issue: > > with our server-setup, it´s much easier to define a seperate user for > > the test-database (instead of using the user from the production- > > database). is that possible? > > Not at present. The test framework uses the main database login to get > access so it can create the test database; moving this into a separate > user could pose some interesting difficulties. I'm also hesitant to > start duplicating all the DB related settings to handle a test login. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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 rewrite SQL for Django
On Aug 13, 2:45 am, Collin Grady <[EMAIL PROTECTED]> wrote: > You cannot. Django does not do aggregates like GROUP BY yet. You will > have to use manual sql to get those values. Thanks for your reply. But how to use sql together with Django so that I can use advantages of paginator? L. --~--~-~--~~~---~--~~ 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: problems with i18n
Hi Heba, I just tried your project with django trunk r5881: I put everything in a folder, modified the settings to use sqlite3, created a db, did manage.py syncdb. Then I started the development server, looked at 127.0.0.1:8000 and it seems to work just fine. What django version are you using ? Koen --~--~-~--~~~---~--~~ 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: Static data on django
> I'm quite new to django, but I'm rather confident that I have looked > for it pretty well. Feel free to yell, if I'm asking a stupid > question. We'll, you've at least learned somewhere that Django shouldn't be handling your media...that's at least something :) > I cannot understand how I can tell django that /images (for example) > is an images folder, located at, say, /home/guruyaya/images/ and no > object should handle it. Is there a way to do that? or do I have to > create a subdomain for static media on my site? While Django *can* serve static files, it's not recommended. To do otherwise, you need to configure your *webserver* to handle those files: http://www.djangoproject.com/documentation/static_files/ For mod_python on Apache, instructions are here: http://www.djangoproject.com/documentation/modpython/#serving-media-files And for lighttpd+FastCGI: http://www.djangoproject.com/documentation/fastcgi/#lighttpd-setup -tim --~--~-~--~~~---~--~~ 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: Static data on django
Ok, I think I got it. django.views.static.serve. I think I can work it out from here. On Aug 13, 4:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm quite new to django, but I'm rather confident that I have looked > for it pretty well. Feel free to yell, if I'm asking a stupid > question. > I cannot understand how I can tell django that /images (for example) > is an images folder, located at, say, /home/guruyaya/images/ and no > object should handle it. Is there a way to do that? or do I have to > create a subdomain for static media on my site? > Thanks in advance > Yair --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Static data on django
I'm quite new to django, but I'm rather confident that I have looked for it pretty well. Feel free to yell, if I'm asking a stupid question. I cannot understand how I can tell django that /images (for example) is an images folder, located at, say, /home/guruyaya/images/ and no object should handle it. Is there a way to do that? or do I have to create a subdomain for static media on my site? Thanks in advance Yair --~--~-~--~~~---~--~~ 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: Proper way to extend contrib.auth
Thanks ! Pretty clever :) Unfortunately it will not work with my application because I need to change the validator on username. Sounds like I have to use the 2nd solution until model subclassing works. On Aug 13, 2:29 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: > Grégoire wrote: > > Hello, > > > I would like to extend some functionnalities of contrib.auth, > > especially in the User model. > > > The objective is to do something clean without hacking django's source > > code. My first idea was to create a new auth application (e.g. myauth) > > and create a new User class in there extending the > > contrib.auth.models.User class. Unfortunately, it doesn't work at all: > > django does not find the other models obviously. I added them by hand, > > then added the relationships to have all the tables and finally > > realized that it doesn't work with the admin interface :( > > > So, what's the good way to add some fields to the User model and > > change some validators? Maybe the only solution is to copy the code > > from contrib.auth and contrib.admin into new applications and start > > from it... > > > Thanks in advance for any advices ! > > > Grégoire > > http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model > > Carl K --~--~-~--~~~---~--~~ 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: Proper way to extend contrib.auth
Grégoire wrote: > Hello, > > I would like to extend some functionnalities of contrib.auth, > especially in the User model. > > The objective is to do something clean without hacking django's source > code. My first idea was to create a new auth application (e.g. myauth) > and create a new User class in there extending the > contrib.auth.models.User class. Unfortunately, it doesn't work at all: > django does not find the other models obviously. I added them by hand, > then added the relationships to have all the tables and finally > realized that it doesn't work with the admin interface :( > > So, what's the good way to add some fields to the User model and > change some validators? Maybe the only solution is to copy the code > from contrib.auth and contrib.admin into new applications and start > from it... > > Thanks in advance for any advices ! > > Grégoire http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model Carl K --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Proper way to extend contrib.auth
Hello, I would like to extend some functionnalities of contrib.auth, especially in the User model. The objective is to do something clean without hacking django's source code. My first idea was to create a new auth application (e.g. myauth) and create a new User class in there extending the contrib.auth.models.User class. Unfortunately, it doesn't work at all: django does not find the other models obviously. I added them by hand, then added the relationships to have all the tables and finally realized that it doesn't work with the admin interface :( So, what's the good way to add some fields to the User model and change some validators? Maybe the only solution is to copy the code from contrib.auth and contrib.admin into new applications and start from it... Thanks in advance for any advices ! Grégoire --~--~-~--~~~---~--~~ 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: Pygments + Markdown
Oh and if you disable markdown, beautifulsoup won't find a code-tag to highlight with pygments. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
HEALTHY LIFESTYLE !!! ®®®
Do you know anyone who plays computer all the time? Perhaps their personal relationships, work and social life are suffering due to their desire to constantly play computer? If this is the case, this person you know may have a computer addiction. http://www.info-computeraddiction.ibiz2u.com This email message was sent specially for: "__(^0^)__" django-users@googlegroups.com (^_^) --~--~-~--~~~---~--~~ 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: doctest and response.template and response.context problem
On 8/13/07, eXt <[EMAIL PROTECTED]> wrote: > > So here is a template and a context. Why I can't access it in my > doctest via response.template and response.context? How are you running your doctest? In order to capture the template rendering details, Django needs to add some instrumentation to the template rendering system. If you run your tests using ./manage.py test, this instrumentation is added automatically. If the instrumentation isn't installed (for example, if you are manually running your doctest), you will get 'no template, no context' returned through the test system. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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: basic testing procedure?
On 8/13/07, patrickk <[EMAIL PROTECTED]> wrote: > > thanks russ. > > is it possible to make the testing-output more verbose? I tried "-v", > but that doesn´t work. It´d be nice to see what tests have been > running and what the output is (more than just "OK"). --verbosity=[0|1|2]. It's in the help when you run ./manage.py. > in the django-docs it says, that doctests provide automatic > documentation. what exactly does that mean? does it refer to the tests > written within the model or is it possible to generate some output > (html-file)? > > concerning the django-docs: > from my point of view, the description of where to define the tests is > not easy to understand. > e.g., it says "You can put doctest strings on any object in your > models.py, but it's common practice to put application-level doctests > in the module docstring, and model-level doctests in the docstring for > each model." > whats the "module docstring"? Erm... the docstring for the module: http://www.python.org/dev/peps/pep-0257/ We need to walk a fine line here. If Python's documentation was poor, there would be a good argument to be made here, but Python has extensive documentation on the doctest and unittest modules. There really isn't anything served by us duplicating Python's documentation - in fact, it could be considered detrimental, because it suggests that Django's test framework is somehow different to Python's. > one more issue: > with our server-setup, it´s much easier to define a seperate user for > the test-database (instead of using the user from the production- > database). is that possible? Not at present. The test framework uses the main database login to get access so it can create the test database; moving this into a separate user could pose some interesting difficulties. I'm also hesitant to start duplicating all the DB related settings to handle a test login. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Pygments + Markdown
Hi, I am trying setup pygments and markdown described here: http://www.unessa.net/en/hoyci/2006/11/highlighting-code-using-pygments-and-beautiful-soup/ My Model.py is: (Also here http://dpaste.com/hold/16731/) - from django.db import models import datetime # Create your models here. class Tag(models.Model): slug = models.SlugField( prepopulate_from=("name",), help_text='Automatically prepopulated from name', ) name = models.CharField(maxlength=30) description = models.TextField( help_text='Short summary of this tag' ) def __str__(self): return self.name def get_absolute_url(self): return "/blog/tag/%s/" % self.slug class Admin: list_display = ('name', 'slug', ) search_fields = ('name', 'description',) class Entry(models.Model): title = models.CharField(maxlength=255, core=True, unique_for_date="pub_date") pub_date = models.DateTimeField(core=True) slug = models.SlugField(maxlength=30, prepopulate_from= ['title']) body = models.TextField(core=True, help_text='Use http://daringfireball.net/projects/markdown/syntax;>Markdown-syntax') body_html = models.TextField(blank=True, null=True) use_markdown = models.BooleanField(default=True) tags = models.ManyToManyField(Tag, filter_interface=models.HORIZONTAL) class Admin: fields = ( (None, {'fields': ('slug', 'title', 'tags', 'use_markdown', 'pub_date', 'body', 'body_html',)}), ) def __str__(self): return self.title def get_absolute_url(self): return "/blog/%s/%s/" % (self.pub_date.strftime("%Y/%m/%d").lower(), self.slug) #from http://www.unessa.net/en/hoyci/2006/11/highlighting-code-using-pygments-and-beautiful-soup/ def _highlight_python_code(self): from pygments import highlight from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(self.body) python_code = soup.findAll("code") if self.use_markdown: import markdown index = 0 for code in python_code: code.replaceWith('mark %i' % index) index = index+1 markdowned = markdown.markdown(str(soup)) soup = BeautifulSoup(markdowned) markdowned_code = soup.findAll("p", "python_mark") index = 0 for code in markdowned_code: code.repalceWith(highlight(python_code[index].renderContents(), PythonLexer(), HtmlFormatter())) index = index+1 else: for code in python_code: code.replaceWith(highlight(code.string, PythonLexer(), HtmlFormatter())) return str(soup) def save(self): import markdown self.body_html = self._highlight_python_code() super(Entry,self).save() - If I create an entry with use_markdown True, and body: this is a regular paragraph `print "hello world"` the body_html is: this is a regular paragraph print hello world If I create an entry with use_markdown False, and body: this is a regular paragraph print "hello world" the body_html is: this is a regular paragraph print hello world I want markdown to find my code blocks or code spans and then let them be colored by pygments. If I turn use_markdown to False, pygments works. If it is True, pygments doesn't work. Maybe there is a problem with the replaceWith() markdowned_code and it isn't getting changed in soup, which is then returned. Thanks, Evan --~--~-~--~~~---~--~~ 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: context processors execution
Hi James can yo ucopy the rest of the email in mate, I'm not sure what my poitn was going to be without seeing it :-) Lots going on. On 13/08/07, james_027 <[EMAIL PROTECTED]> wrote: > > > hi Matt, > > On Aug 13, 3:13 pm, "Matt Davies" <[EMAIL PROTECTED]> wrote: > > James, are you talking about putting a context processor into the > > settings.py file? > > > > yes, and also context processor called as argument on views by > ContextRequest() > > Thanks > james > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
doctest and response.template and response.context problem
Hi I have a doctest which says: """ >>> from django.test.client import Client >>> c.login(username='testuser', password='testpw') True Now we go to the sample page >>> response = c.get('/app/sample_page/') >>> response.status_code 200 So far so good but... >>> response.template >>> response.template.name Traceback (most recent call last) /home/ext/workingenvs/django2.5/src/projects/oms_dystrybutor/ in () : 'NoneType' object has no attribute 'name' >>> print response.template None The same for context: >> response.context >> print response.context None """ My app/sample_page view which is called above ends with: return render_to_response('app/sample_page.html', {'form': form.as_table(), 'opts': User._meta, 'message':message, 'glob_err_message':error_message}, context_instance=RequestContext(request)) So here is a template and a context. Why I can't access it in my doctest via response.template and response.context? regards -- Jakub Wiśniowski --~--~-~--~~~---~--~~ 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: RSS2 feeds and overwriting the item description
I found it One of our developers had created a file called latestnews_description.html in the feeds folder. This was outputting the body. I've now added description_template into all the feeds and either used a generic {{ obj.body_html }} or some other type of output depending on the nature of the data. On Aug 13, 9:07 am, "Matt Davies" <[EMAIL PROTECTED]> wrote: > I have a feeds dictionary prepared like this in my urls.py > > feeds = { > 'latestdocuments': LatestDocuments, > 'latestevents': LatestEvents, > 'latestnews': LatestNews, > 'latestnotices': LatestNotices, > 'latestpages': LatestPages, > 'latestphotos': LatestPhotos, > 'latestjobs': LatestJobs, > > } > > and one urlpattern that describes feeds like this > > urlpatterns += patterns('', > (r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed', > {'feed_dict': feeds}), > ) > > I have a news application, in it the definition of Post, a single item, > returns this. > > def __unicode__(self): > return self.title > > I have a feeds.py file in the application that looks like this > > class LatestNews(Feed): > feed_type = Rss201rev2Feed > title = "Inform News" > link = "/news/" > description = "News from Inform as it happens" > > def items(self): > return Post.objects.filter(approved=1).order_by('-created_at')[:5] > > So when I go to my link, which is > > http://reinform.isd.glam.ac.uk/feeds/latestnews/ > > I get my rss2 feed. > > But in the news feed, the item description in the xml is being filled with > the body of the single Post item. If you look at the raw xml output you'll > see what I mean. > > Now this is what I want. > > In all the other applications though, I've used the same code in their > respective feeds files, but the other apps show the title of the item in the > item description node of the raw xml ouput. > > Has anyone got any ideas why this is happening? > > All the apps have body fields in them and are using this return in their > models file. > > def __unicode__(self): > return self.title > > Any help would be greatly appreciated. --~--~-~--~~~---~--~~ 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: basic testing procedure?
On 13 Sie, 09:48, patrickk <[EMAIL PROTECTED]> wrote: > thanks russ. > > is it possible to make the testing-output more verbose? I tried "-v", > but that doesn´t work. It´d be nice to see what tests have been > running and what the output is (more than just "OK"). ./manage.py test --verbosity 2 (or 1 or 0) > in the django-docs it says, that doctests provide automatic > documentation. what exactly does that mean? does it refer to the tests > written within the model or is it possible to generate some output > (html-file)? I think it says automatic because doctests contain not only code but also some textual descriptions. Take a look at: http://svn.zope.org/zope.testbrowser/trunk/src/zope/testbrowser/README.txt?rev=76064=auto This readme is at the same moment a doctest and what is more it is written in the structured text (or restructured) format. It allows you to easily generate html page from that. Django docs doesn't show so descriptive doctests :/ > concerning the django-docs: > from my point of view, the description of where to define the tests is > not easy to understand. This is my feeling too. What is more, Russel's hint with __test__ dictionary should be included in the docs too. > one more issue: > with our server-setup, it´s much easier to define a seperate user for > the test-database (instead of using the user from the production- > database). is that possible? Very good point. I've got the same problem here. Regards -- Jakub Wisniowski --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---