multiple models in object_list
I'm trying to figure out how I can use more than one model with a call to object_list generic view. currently I have this.. objectlist_dict = {'queryset' : Report.reports.all(), 'extra_context' : {'category_list' : Category.objects.all() }, } urlpatterns = patterns('', (r'^$', object_list, objectlist_dict ) , my template tries this.. All Categories {% for cat in category_list %} {{ cat.name }} {% endfor %} but the category's never get shown. Thoughts? Thanks, John --~--~-~--~~~---~--~~ 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 models in object_list
Thanks for the info. Turns out that I was looking at the wrong bit of code (gr), and wasted 2hrs of my day. John On Nov 4, 2:36 pm, "Matías Costa" <[EMAIL PROTECTED]> wrote: > On Tue, Nov 4, 2008 at 8:37 PM, John M <[EMAIL PROTECTED]> wrote: > > > I'm trying to figure out how I can use more than one model with a call > > to object_list generic view. > > http://www.djangosnippets.org/snippets/1103/ --~--~-~--~~~---~--~~ 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 question : best way to show 1 .. N different categoried items
i have a model for status reports:http://dpaste.com/88760/ The report has 1-N bullet Points, each bullet Point has a category. What I want to figure out, whats my best way to display this in a template, given that the category list is flexible. I mean, a report might have 1 or more categories. I'd like to then group the bullet points for each category on the site. Your help is appreciated. John --~--~-~--~~~---~--~~ 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: Design question : best way to show 1 .. N different categoried items
Bruno, Thanks for pointing me in the right direction, the only thing I needed to as was an order_by("category") to make sure all the bullet points were grouped by category. Again, thank you so much for getting me past this. John On Nov 5, 1:02 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 4 nov, 23:54, John M <[EMAIL PROTECTED]> wrote: > > > i have a model for status reports:http://dpaste.com/88760/ > > > The report has 1-N bullet Points, each bullet Point has a category. > > > What I want to figure out, whats my best way to display this in a > > template, given that the category list is flexible. I mean, a report > > might have 1 or more categories. > > > I'd like to then group the bullet points for each category on the > > site. > > Not tested, but this should work AFAICT: > > # myview.py > def myview(resquest, report_id): > report = get_object_or_404(Report, pk=report_id) > context = dict( > report = report, > bullets = > report.bulletpoint_set.all().select_related('category') > } > return render_to_response('mytemplate.html', context) > > # mytemplate.html > {% regroup bullets by category as grouped_bullets %} > > {% for group in grouped_bullets %} > > {{ group.grouper }} > > {% for bullet in group.list %} > {{ bullet }} > {% endfor %} > > {% endfor %} > > > cfhttp://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup > > HTH --~--~-~--~~~---~--~~ 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: Sort querysets by their data attribute values
I had a similar need based on a calculated column, you'll have to turn it into a list (i.e. mylist = list(queryset) ) and then sort from there. You can still pass the list to a template a loop through it just like a regular queryset, since the objects in the list are just python objects. J On Nov 6, 11:58 am, dexter <[EMAIL PROTECTED]> wrote: > I have a queryset which I have looped thru and added a (temporary) > data attribute to each instance. Now I would like to order the > queryset by the value of the data attributes. If I do it like this: > > sorted(queryset, key=lambda x: x.data_attr) > > the queryset turns into a list and I can't use it like a queryset > anymore = not good! > How can i solve 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 -~--~~~~--~~--~--~---
Getting non-related records
i have a model at http://dpaste.com/88760/ for a particular Report (r), I'd like to get all categories that aren't in it's bulletpoints. For example, If there are four categories: one, two, three, four. there is a report with bullet points for one and two, how can I get a list of three and four. This allows me to offer a user to add bulletpoints in those categories. I hope this makes sense :P John --~--~-~--~~~---~--~~ 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: Getting non-related records
WOW, I knew it would be easy, but that is ridiculous. Thanks Alex! John On Nov 6, 3:00 pm, "Alex Koshelev" <[EMAIL PROTECTED]> wrote: > Hi, John > > Try this: > > Category.objects.exclude(bulletpoint__report=r) > > On Fri, Nov 7, 2008 at 01:54, John M <[EMAIL PROTECTED]> wrote: > > > i have a model athttp://dpaste.com/88760/ > > > for a particular Report (r), I'd like to get all categories that > > aren't in it's bulletpoints. > > > For example, If there are four categories: one, two, three, four. > > there is a report with bullet points for one and two, how can I get a > > list of three and four. > > > This allows me to offer a user to add bulletpoints in those > > categories. > > > I hope this makes sense :P > > > John --~--~-~--~~~---~--~~ 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: Can I use more than one database handle with Django?
Do you want to use more than one Database? Then NO, it's not available directly right now, that's supposed to be an upcoming feature. J On Nov 6, 4:28 pm, turbogears <[EMAIL PROTECTED]> wrote: > Hi, > Can I use more than one database handle with Django? > and how can I do it? > excuse my english! > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using just one custom manager
I wanted to get some feedback on how I'm using custom model managers. I've put all my queries into one manager, each in a different method. Is this the right way to go? So for example: CHOICES_TASK = ( ("NO", "None"), ("GR", "Green"), ("YL", "Yellow"), ("RD", "Red"), ) class TaskManager(models.Manager): use_for_related_fields = True # Task.objects.all() def get_query_set(self): return super(TaskManager, self).get_query_set() # Task.milestones() def Milestones(self): return super(TaskManager, self).get_query_set().filter(milestone=True) def Accomplishments(self): return super(TaskManager, self).get_query_set().filter(milestone=False).filter(completed=True) def Nextsteps(self): return super(TaskManager, self).get_query_set().filter(milestone=False).filter(completed=False) class Task(models.Model): report = models.ForeignKey(Report) name = models.CharField(max_length=50) started = models.BooleanField(default=False) status = models.CharField(max_length=20, choices=CHOICES_TASK, default="NO") completed = models.BooleanField(default=False) duedate = models.DateField(blank=True, null=True) milestone = models.BooleanField(default=False) # Managers objects = TaskManager() milestones = TaskManager().Milestones accomplishments = TaskManager().Accomplishments nextsteps = TaskManager().Nextsteps def __unicode__(self): return self.name --~--~-~--~~~---~--~~ 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 just one custom manager
Dave, Thanks for the quick reply, yea, I figured out what I needed to do, which turns out just what you said. I will change to the pythonic way of doing things, thanks. John On Nov 7, 11:47 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Nov 7, 7:13 pm, John M <[EMAIL PROTECTED]> wrote: > > > > > I wanted to get some feedback on how I'm using custom model managers. > > > I've put all my queries into one manager, each in a different method. > > Is this the right way to go? > > > So for example: > > > CHOICES_TASK = ( > > ("NO", "None"), > > ("GR", "Green"), > > ("YL", "Yellow"), > > ("RD", "Red"), > > ) > > > class TaskManager(models.Manager): > > use_for_related_fields = True > > > # Task.objects.all() > > def get_query_set(self): > > return super(TaskManager, self).get_query_set() > > > # Task.milestones() > > def Milestones(self): > > return super(TaskManager, > > self).get_query_set().filter(milestone=True) > > > def Accomplishments(self): > > return super(TaskManager, > > self).get_query_set().filter(milestone=False).filter(completed=True) > > > def Nextsteps(self): > > return super(TaskManager, > > self).get_query_set().filter(milestone=False).filter(completed=False) > > > class Task(models.Model): > > report = models.ForeignKey(Report) > > name = models.CharField(max_length=50) > > started = models.BooleanField(default=False) > > status = models.CharField(max_length=20, choices=CHOICES_TASK, > > default="NO") > > completed = models.BooleanField(default=False) > > duedate = models.DateField(blank=True, null=True) > > milestone = models.BooleanField(default=False) > > > # Managers > > objects = TaskManager() > > milestones = TaskManager().Milestones > > accomplishments = TaskManager().Accomplishments > > nextsteps = TaskManager().Nextsteps > > > def __unicode__(self): > > return self.name > > There's nothing wrong with the general idea - that's how I do it > myself, although the official docs say to use multiple managers and > override get_query_set on each one. A couple of comments on your > implementation though: > > 1. There's no point in defining a get_query_set model simply to pass > to super. If you don't define it at all, it will just inherit from the > parent class anyway, which is exactly the same as what happens in your > version, so you may as well save two lines of code. > > 2. The convention in Python/Django is to have all lower case names for > functions and methods - so it should be milestones, accomplishments, > etc. > > 3. I don't think there's any point in defining all the extra manager > attributes that you have. Leave objects as TaskManager, then you can > do things like: > Task.objects.milestones() > Task.objects.accomplishments().filter(started=False) > or whatever. > > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using just one custom manager
DR, Now I have a new problem. When I use this as a related_manager (Report.objects.all()[0].task_set.accomplishments()) it returns all the accomplishments. I've even added the use_for_related_fields=True in the manager. The all() (default) call seems to work fine, but the others done. Any ideas? Thanks John On Nov 7, 11:47 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Nov 7, 7:13 pm, John M <[EMAIL PROTECTED]> wrote: > > > > > I wanted to get some feedback on how I'm using custom model managers. > > > I've put all my queries into one manager, each in a different method. > > Is this the right way to go? > > > So for example: > > > CHOICES_TASK = ( > > ("NO", "None"), > > ("GR", "Green"), > > ("YL", "Yellow"), > > ("RD", "Red"), > > ) > > > class TaskManager(models.Manager): > > use_for_related_fields = True > > > # Task.objects.all() > > def get_query_set(self): > > return super(TaskManager, self).get_query_set() > > > # Task.milestones() > > def Milestones(self): > > return super(TaskManager, > > self).get_query_set().filter(milestone=True) > > > def Accomplishments(self): > > return super(TaskManager, > > self).get_query_set().filter(milestone=False).filter(completed=True) > > > def Nextsteps(self): > > return super(TaskManager, > > self).get_query_set().filter(milestone=False).filter(completed=False) > > > class Task(models.Model): > > report = models.ForeignKey(Report) > > name = models.CharField(max_length=50) > > started = models.BooleanField(default=False) > > status = models.CharField(max_length=20, choices=CHOICES_TASK, > > default="NO") > > completed = models.BooleanField(default=False) > > duedate = models.DateField(blank=True, null=True) > > milestone = models.BooleanField(default=False) > > > # Managers > > objects = TaskManager() > > milestones = TaskManager().Milestones > > accomplishments = TaskManager().Accomplishments > > nextsteps = TaskManager().Nextsteps > > > def __unicode__(self): > > return self.name > > There's nothing wrong with the general idea - that's how I do it > myself, although the official docs say to use multiple managers and > override get_query_set on each one. A couple of comments on your > implementation though: > > 1. There's no point in defining a get_query_set model simply to pass > to super. If you don't define it at all, it will just inherit from the > parent class anyway, which is exactly the same as what happens in your > version, so you may as well save two lines of code. > > 2. The convention in Python/Django is to have all lower case names for > functions and methods - so it should be milestones, accomplishments, > etc. > > 3. I don't think there's any point in defining all the extra manager > attributes that you have. Leave objects as TaskManager, then you can > do things like: > Task.objects.milestones() > Task.objects.accomplishments().filter(started=False) > or whatever. > > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Model manager not working with related sets of records.
I have the following model (http://dpaste.com/89869/). The model is for a status report application I'm trying to create at work (so I don't have to do powerpoints). So each report, has several tasks / milestones associated with it. My problem is when I use a related set, the custom manager methods don't work. For example, Report 1 has tasks 1, 2, 3 associated with them, which task 1 is a milestone, 2 and 3 are both next steps (per the filter in the model. Report 2 has tasks 4, 5, 6 associated with them, same types as above. So Report1.task_set.all() works great, and gives me only tasks 1-3. Report2.task_set, same thing. However, If I ask for Report1.milestones() I get all the milestones for all the reports, uggh. Same on the other manager methods (milestones and nextsteps) What am I doing wrong? I can work around this for now, but was hoping it's something i'm doing wrong. Thanks John --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Templates - testing multiple things on IF line
Does the IF tag allow for OR's or AND's? Thanks John --~--~-~--~~~---~--~~ 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: polls tutorial question
What you see is what you get when it comes to templates in the Tutorial. There is no default CSS or anything like that. If you'd like to do CSS from a media file, you'll have to check the docs on serving static files via the builtin server. J On Nov 14, 12:19 pm, prem1er <[EMAIL PROTECTED]> wrote: > Trying to mess with the styling of the polls view from the tutorial. > Where is it reading it's CSS from? Or where is it 'extending' its > style from. I tried to incorporate a CSS sheet from within that > directory and it wouldn't read it. It would only read HTML that I > placed in the document itself. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
What happened to Documentation layout on djangoproject.com?
I just noticed that the documentation layout change (for the better). Did I miss an announcement. Either way, I love it. John --~--~-~--~~~---~--~~ 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: What happened to Documentation layout on djangoproject.com?
Karen, As always, you're the best, thanks. John On Nov 18, 11:33 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Tue, Nov 18, 2008 at 2:23 PM, John M <[EMAIL PROTECTED]> wrote: > > > I just noticed that the documentation layout change (for the better). > > Did I miss an announcement. > > > Either way, I love it. > > http://groups.google.com/group/django-developers/browse_thread/thread... > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Bug? Related manager not working for custom manager?
I have a model with a custom model manager used for related set filtering, but it's not working as expected. See my models and test at http://dpaste.com/92327/ Can someone explain why my manager isn't doing what I think it should? Thanks John --~--~-~--~~~---~--~~ 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 generic view to insert a simple model in the DB
django writes about 90% of the form part for you. This was also an area for me (being new to HTML apps) that was confusing. You have two choices, you can use the {{form}} object in your html, or you can setup each field from the form individually. (http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views- generic-create-update-create-object). If you want to do individual fields, like the example: {{ form.name.label_tag }} {{ form.name }} {{ form.address.label_tag }} {{ form.address }} of if you wanted to have django do the whole thing for your: ((form)) That's about as simple as it gets. Other than the above code IN YOUR TEMPLATE, you'll need to have the basic HTML and sections, you can find those on the web somewhere for examples. Once you have the above setup and happy, you should have what you're looking for to get started. HTH John On Nov 19, 3:57 am, maury <[EMAIL PROTECTED]> wrote: > Updates: > > I found some documentation and I added a code to urls.py like this : > > (r'^poll/add$', create_update.create_object, {'model' : Poll}), > > and the problem is that I have to write a template (I know where the > file should be and how it should be named from the error message I > got) and I don't know how to write it, yet. I have no special needs, > is it possible to let django supply one default template constructed > from the model definition ? > > Thanks a lot > Maury --~--~-~--~~~---~--~~ 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: Bug? Related manager not working for custom manager?
Malcom, Thank you so much for taking the time to look over this, and you're right, looking back, I should have trimmed down the problem for all to see. I've come up with a work-around for now, but will watch the ticket to see when it's fixed. I suspect it's something to do with the fact it's a related manager, cause working with the records as Tasks directly, doesn't seem to have the problem. Thanks again John On Nov 19, 11:52 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-11-19 at 18:21 -0800, John M wrote: > > I have a model with a custom model manager used for related set > > filtering, but it's not working as expected. > > > See my models and test athttp://dpaste.com/92327/ > > > Can someone explain why my manager isn't doing what I think it should? > > This would have been a good situation to really trim down your example > to, say, one extra field plus the ForeignKey in each model. It took a > fair amount of work to untangle your test lines that didn't have any > explanation of what you expected to see and work out what the problem > was that you were actually seeing. Remember that you're always going to > be more familiar with the problem than the people reading it anew. > > After trimming down the example, we end up with ticket #9643. It's a > clearbug. My guess is that it will be easy to fix when I get a few > minutes to look at it. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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: Bug? Related manager not working for custom manager?
Ian, Thanks for the reply, yes I've verified via the db.connections option that something is definitely wrong. John On Nov 19, 6:33 pm, "Ian Lewis" <[EMAIL PROTECTED]> wrote: > John, > > Try checking the log output of the database server to see what is > different about the SQL. Perhaps some kind of caching is going on > where the manager is caching the results of it's queries? > > On Thu, Nov 20, 2008 at 11:21 AM, John M <[EMAIL PROTECTED]> wrote: > > > I have a model with a custom model manager used for related set > > filtering, but it's not working as expected. > > > See my models and test athttp://dpaste.com/92327/ > > > Can someone explain why my manager isn't doing what I think it should? > > > Thanks > > > John > > --~--~-~--~~~---~--~~ 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 just one custom manager
Spoksss, I brought this up as a BUG? subject and got some traction from Malcom. Malcom opened a tracking ticket to get it fixed. I was able to work around it by sending some querysets to my view before, instead of using the related sets in the view. If you'd like to see my work around, please let me know. In the mean time, checkout my new topic, which Malcom answered http://groups.google.com/group/django-users/browse_thread/thread/738460b50b0c96cd/65aa99bd3fcc9812?lnk=gst&q=bug%3F#65aa99bd3fcc9812 John --~--~-~--~~~---~--~~ 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: order_by function
I wanted the same thing long ago, you have a couple of choices: 1. Use custom SQL functions (but kinda locks u in), 2. Use the python sort function. This basically takes ur queryset, turns it into a list and then sorts it. Since all querysets are just lists in python you can do this: orderedlist = list(querysetX). orderedlist.sort... or something like that, you'll have to play with the syntax. But you can't use the Order_by on the queryset, because that translates directly into SQL and that's not available. John On Nov 21, 6:56 am, Luke Seelenbinder <[EMAIL PROTECTED]> wrote: > Can I order_by a function within the model? I know you can list them > in the admin inteface, etc. But can you order_by a model function? Or > would you have to write a custom piece of code to do that? > > Thanks, > Luke --~--~-~--~~~---~--~~ 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 delete button to a form.
Dominic, Welcome to the django forum :) and welcome to django > Which I've tested and seems to be working ok. (The documentation, by > the way, didn't mention anything about requiring > foo_confirm_delete.html but I guess that's not too hard to figure out > from the error message) Actually, at the end of that section for delete, it mentions the template requirements: Template name: If template_name isn't specified, this view will use the template /_confirm_delete.html by default. As do all the generic views. > I could I suppose fairly easily stick a link on the template that > redirects to my generic delete URL. However, one of my aims with this > project is to try to do everything as intelligently as possible, so I > wonder if there is any way I can include django save and add another/ > delete/cancel widgets onto the form automatically? That's how it's done in admin, and that's how i've done it, I don't see an issue with doing it that way. > > I'll eventually be wanting to put those "edit in line" green cross > buttons onto foreign key input fields too, so I'm thinking django must > have a standard sort of widget set to allow this? > I think there was a thread on this the other day. Good Luck. > Cheers, --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
admin css, is this still supported?
I've searched for the admin CSS guide, and found it deprecated (http:// docs.djangoproject.com/en/dev/obsolete/admin-css/?from=olddocs), is there a replacement? Thanks, John M --~--~-~--~~~---~--~~ 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: admin css, is this still supported?
Thanks Malcom, I'll do what I can On Dec 2, 8:05 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-12-02 at 08:21 -0800, John M wrote: > > I've searched for theadminCSSguide, and found it deprecated (http:// > > docs.djangoproject.com/en/dev/obsolete/admin-css/?from=olddocs), is > > there a replacement? > > You can still customise theadminCSS. I suspect it just hasn't been > documented for the neweradminyet. But you'll see a bunch of .cssfiles > in the django/contrib/admin/media/css/ directory and, if all else fails, > poking around with something like Firebug will show the relevant classes > fairly quickly. > > If you are playing around in that area, take notes as you go and you > might be able to help us resurrect the old documentation and make it > appropriate for the newadmin. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
VPS Hosting - Webkeepers
Anyone tried this for django? http://www.webkeepers.com/index.html entry level is 6.95/mo, great for QA site I would think. Just curious Thanks John --~--~-~--~~~---~--~~ 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: Form stays invalid even after required field has been set
I had this same issue, and it turned out i was not showing a necessary field. My advice, try to recreate from the command line with the basic form object and see what it says is missing. Good Luck, John On Dec 10, 7:26 am, Berco Beute <[EMAIL PROTECTED]> wrote: > Here's the code: > > http://dpaste.com/97758/ > > My modelform stays invalid although the required fields of the > instance are set. The 'product' field is excluded from the form > because it shouldn't be edited. When the form is posted I'm trying to > set the product on the form instance again, but that somehow doesn't > work out to well. > > In line 17 the form is found to be invalid although I set the > OrderLineForm's OrderLine instance has the required 'product' field > set with the appropriate object (tested at line 16). I thought > > I've successfully used this strategy in other projects but I'm at a > loss what happens here. I'm also not sure how to debug this properly. > > Any pointers/suggestions would be highly appreciated. > > 2B --~--~-~--~~~---~--~~ 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 Tutorial for NFA has bugs
Given that the group has figured out that you need to run autodiscover() and register any models you want to show in NFA Admin page, I wanted to point out that the tutorial has the same bug, somewhere in Tutorial 2, it tells you to un-comment the # for admin access, which DOES NOT show anything in Admin. The correction would be to add the autodiscover() call. Currently part 2 of the Tutorial shows * Add "django.contrib.admin" to your INSTALLED_APPS setting. * Run python manage.py syncdb. Since you have added a new application to INSTALLED_APPS, the database tables need to be updated. * Edit your mysite/urls.py file and uncomment the lines below the “Uncomment this for admin:” comments. This file is a URLconf; we’ll dig into URLconfs in the next tutorial. For now, all you need to know is that it maps URL roots to applications. But we need to add to the urls.py: from django.contrib import admin admin.autodiscover() This will make the admin site work the way it used to. Thoughts? Thanks john --~--~-~--~~~---~--~~ 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 Tutorial for NFA has bugs
This has been fixed in the latest SVN release. J On Jul 20, 8:42 pm, John M <[EMAIL PROTECTED]> wrote: > Ticket 7861 created for this. > > John > > On Jul 20, 1:25 pm, "Chris H." <[EMAIL PROTECTED]> wrote: > > > On Jul 20, 3:21 pm, John M <[EMAIL PROTECTED]> wrote: > > > > Given that the group has figured out that you need to run > > > autodiscover() and register any models you want to show in NFA Admin > > > page, I wanted to point out that the tutorial has the same bug, > > > somewhere in Tutorial 2, it tells you to un-comment the # for admin > > > access, which DOES NOT show anything in Admin. The correction would > > > be to add the autodiscover() call. > > > Errors, or perceived errors, in documentation should be logged as > > tickets on the trac site. --~--~-~--~~~---~--~~ 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: status of unicode support in 0.96?
Any reason why you wouldn't just use the SVN version, given we're so close to 1.0? Also, not sure if they will update .96 anymore other than security fixes. It's very behind in features compared to SVN version. JOhn On Jul 21, 11:09 am, "Andrew D. Ball" <[EMAIL PROTECTED]> wrote: > Greetings. > > I haven't found any good documentation yet on how Django > supports Unicode in version 0.96. The following webpage > has links for version 0.96 and 0.95, but those links don't > work. :-/ : > > http://www.djangoproject.com/documentation/unicode/ > > Does anyone have some more information on using Unicode with > Django 0.96? > > Thanks for your help. > > Peace, > Andrew > -- > === > Andrew D. Ball > [EMAIL PROTECTED] > Software Engineer > American Research Institute, Inc.http://www.americanri.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: django Tutorial for NFA has bugs
Ticket 7861 created for this. John On Jul 20, 1:25 pm, "Chris H." <[EMAIL PROTECTED]> wrote: > On Jul 20, 3:21 pm, John M <[EMAIL PROTECTED]> wrote: > > > Given that the group has figured out that you need to run > > autodiscover() and register any models you want to show in NFA Admin > > page, I wanted to point out that the tutorial has the same bug, > > somewhere in Tutorial 2, it tells you to un-comment the # for admin > > access, which DOES NOT show anything in Admin. The correction would > > be to add the autodiscover() call. > > Errors, or perceived errors, in documentation should be logged as > tickets on the trac site. --~--~-~--~~~---~--~~ 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: Changing the returned query set in the admin interface 'add' section depending on user permissions.
I suspect you'll have to intercept one of the many signals django has in it's architecture. Sorry, not sure where to point you other than that. John On Aug 19, 4:19 am, chewynougat <[EMAIL PROTECTED]> wrote: > Hi, > > I have an admin add form that allows users to insert documents. I have > a select box which currently displays all company departments and > their relevant categories (e.g. finance and admin -> payroll, finance > and admin -> expenses etc). What I would like to do is display the > relevant departments and categories only to which the current user > belongs. I am totally stumped on how to go about this so any help is > much appreciated. Currently I am overriding get_form and get_fieldset > to display all departments and categories if the user has all > permissions. If the user doesn't have these permissions, the select > box is removed and the department to which the current user belongs is > used - but this limits the choice to the top level (i.e. finance) and > not the categories of the department. > > 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: Boosting your productivity when debugging Django apps
I tried eclipse with pyDev installed and it allows a pretty neat Visual Studio et al look and feel to it. John On Aug 22, 11:20 am, Delta20 <[EMAIL PROTECTED]> wrote: > This question is aimed at those of you who, like me, come from a Java > and C++ background and are used to being able to debug things with a > debugger - setting breakpoints, stepping through code, evaluating > expressions, etc. What do you find to be the most productive approach > to debugging Django apps? > > Personally, I've been trying to get PyDev to work but attempting to > run a Django app crashes Eclipse every time for me so I haven't been > able to evaluate its debugger. I don't much like Eclipse anyway and am > hoping the NetBeans Python debugger will provide a viable > alternative. > > I'm new to both Python and Django, and right now I feel horribly > unproductive without an efficient way to debug things. --~--~-~--~~~---~--~~ 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: Custom manager for many-to-many traversal
Since my_book.auther_set.all() returns a QS, can't you just say something like ...all().filter(author__isalive=True) or something like that? I've never tried, but I thought that django would figure it out? J On Aug 25, 12:11 am, MrJogo <[EMAIL PROTECTED]> wrote: > How do I create a custom manager for many-to-many traversal? An > example will illustrate what I want to do better. Suppose I have the > following models.py: > > class Book(models.Model): > title = models.CharField(max_length=100) > > class Author(models.Model): > books = models.ForeignKey(Book) > name = models.CharField(max_length=100) > is_alive = models.BooleanField() > > This is a many-to-many relationship: a book can have multiple authors > and an author can have written multiple books. > > If I have a book object my_book, and I want to get all the authors, I > do my_book.author_set.all(). How can I set up a custom manager to only > get living authors of that book, so I could do something like > my_book.livingauthor_set.all()? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: exporting apps and db from windows to ubuntu.
from the command line / console / whatever... ./manage.py dumpdata http://www.djangoproject.com/documentation/django-admin/#dumpdata-appname-appname On Aug 25, 3:25 pm, KillaBee <[EMAIL PROTECTED]> wrote: > ok it is dumpdata and loaddata, but where does it go? I searched for > *.json but nothing came up. and there are alot of fixtures. > > On Aug 25, 4:05 pm, KillaBee wrote: > > > I am moving a app and db from a windows server to a Ubuntu server. Is > > there a easy way to export the data from the windows server and import > > it into the Ubuntu server. I don't think that I can copy and paste, > > then change the URLS.py file. I looked for the files but the files I > > did see looks different. It pulls functions that I can't find in the > > Django lib. --~--~-~--~~~---~--~~ 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: Test Application Fails to Appear in Admin
I'm assuming your link meant to point to this instead http://www.djangoproject.com/documentation/tutorial02/#make-the-poll-app-modifiable-in-the-admin. did the main admin site work first, but the Poll app doesn't work? Check the group, there are lots of cases where a typo may have caused it. J On Sep 1, 5:28 pm, Justin <[EMAIL PROTECTED]> wrote: > Hi Team, > > I followed this tutorial > here:http://www.djangoproject.com/documentation/tutorial02/ > up until the step "Make the poll app modifiable in the admin". > > I do this step, but I don't get the Poll application in the admin > section. > > I'm running debian, apache 2, mod_python and mysql 5. I'm using the > latest SVN release. > > manage.py validate returns 0 errors, and syncdb runs fine. > > I'm not sure how to debug this. Any tips on what I can do to see why > it isn't loading, or any ideas? > > jpe --~--~-~--~~~---~--~~ 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: getting max(field) with db-api
i used that for mine and it always worked! Mine was for a list of child records by date, but child.objects.all()[0] always gave me the most recent object. J On Sep 2, 7:23 am, mwebs <[EMAIL PROTECTED]> wrote: > Hello, > > I want to perform a lookup an getting the object with the highest > integer value. > The Model looks something like this: > > MyModel: > name = > number = models.PositiveIntegerField() > > class Meta: > ordering = [-number] > > So I figured out this: > > highest = MyModel.objects.all()[0] > > Is there another, more elegant way like: highest = > MyModel.object.filter(max(number)), so that I dont have to add the > ordering-attribute in the medta-class? > > Thanks, > Toni --~--~-~--~~~---~--~~ 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 in Under a Minute' screencast, requesting feedback before v1-final is ready
I never thought I'd say this, but it's a little TOO QUICK. Maybe 3min ? It's not long enough to really get me interested, but I don't want to take too much time / detail that I start learning the product. Overall though, the quality and idea are awesome, keep it up. John On Sep 3, 2:07 pm, "Ian Ozsvald" <[EMAIL PROTECTED]> wrote: > I've created a 57 second screencast showing 'Django in Under a Minute'. I > recorded it over the last two days using the current Django release > candidate, I'll update the visuals once v1-final is ready and then release a > final > copy:http://procasts.co.uk/examples/DjangoIn1Min_early_cut_for_ReleaseCand... > > I'd like to ask for feedback, there's still time to make minor tweaks if > need be. I've aimed the screencast at users who have heard of Django and > know about web-app frameworks but who haven't yet tried Django. I'm aiming > to show them how easy it is to get on board and start building neat stuff. > > Does the message come through clearly? Do I cover too much/too little? > > Once Django v1 is out I'll update the video element (to show the v1 django > site, not the current release-candidate site) and release the result to > ShowMeDo, Vimeo etc under a CC license. I hope it'll be useful for bloggers > to help spread the word. > > Assuming this video gets a good reception, I'll think about making a 4-part > video accompaniment to the 4-part Django tutorial. This is exactly the sort > of stuff we want to see in ShowMeDo (I'm ShowMeDo's co-founder), assuming > this longer series is well-received then we'd look to do more Django > material. > > Cheers, > Ian (ShowMeDo/ProCasts) > > -- > Ian Ozsvald (Professional Screencaster) > [EMAIL PROTECTED] > > http://ProCasts.co.ukhttp://IanOzsvald.com+http://ShowMeDo.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: What do you use for a user manager in Django?
I think now that the Admin refactor in 1.0 is there, you can just sub- class the user model and use admin that way, no? On Sep 5, 1:28 pm, jmDesktop <[EMAIL PROTECTED]> wrote: > What do you use for a user manager in Django? When I used Django it > was nice, but I couldn't find a way to use it for a CMS, either > Intranet or Internet. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Will the new Django 1.0 work better with IIS?
I wouldn't say it's built for apache, it's just that non-MS based systems don't work 'as well' as IIS native stuff (go figure). I found two quick articles about doing it: http://forums.iis.net/t/1122937.aspx http://support.microsoft.com/kb/276494 Although, I seem to remember something about a .NET version of python, I could be wrong. Found it .http://www.codeplex.com/Wiki/view.aspx? ProjectName=IronPython John On Sep 5, 1:26 pm, jmDesktop <[EMAIL PROTECTED]> wrote: > I know Django is made primarily for Apache, but does anyone know if > the 1.0 version has anything that makes it "really" work with IIS? In > the past I have seen folks run Django with IIS (I have myself), but it > seemed more of a hack than anything else. Certainly not something I'd > want to run in production. > > Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: keeping counts of verbs (downloads, comments, ...)
Any reason why you wouldn't override the save() method of the model in question? When the model with the data you'd like to summarize is saved, you could recalc the data then? J On Sep 17, 4:20 am, "Bram de Jong" <[EMAIL PROTECTED]> wrote: > hello all, > > I have objects in the db which are being commented/favorited/downloaded > many, many times. > I'd like to keep counts of those verbs, in various time spans (#downloads > today, this month, all time). > > Having done this for another site, I have found that this isn't the easiest > thing in the world when you have heavy traffic: > I had some rather large sql queries running once in a while which do the > counting and store in various tables, but updating almost all rows (each > object gets new counts) each time is a pretty bad idea (especially in > postgres), so I ended up running vacuum analyze every time after the > updates. Right now I'm thinking of creating some separate code for it and > actually store the results in memcached instead of the database. > > Can anyone give any advice on how to do this, in particular (or not!) with > django? > > thanks a lot for any hints! > > - Bram > > --http://www.freesound.orghttp://www.smartelectronix.comhttp://www.musicdsp.org --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
vServer Image - Has anyone tried this?
I stumbled on this today http://es.cohesiveft.com/ I've built a django server, and am going to try tonight. Has anyone tried this yet? John --~--~-~--~~~---~--~~ 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 -- very very basic query !
I would suggest taking a couple of hours to do the tutorial, and it basically runs through most of what django can do. Since 1.0 is out, you just need to download, install and run through the tutorial. It runs on any platform. Have fun. John On Sep 21, 7:20 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > I am basically c/c++/Unix dev, and knowing little python stuff. And > little bit about xhtml. > I just wanted to know to learn/develop site using Django, Do i have to > master of Python, Xhtml , Javascript ? > > What kind of stuff, i can do using Django ? > > Thanks > Raxitwww.m4mum.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 -~--~~~~--~~--~--~---
update or add object?
Is there a method I can call in a view that given a key, it checks to see if that object exists and if it does returns that object, or if it doesn't, adds it to the DB and returns the new key? I could have sworn there was a shortcut for this. Thanks John --~--~-~--~~~---~--~~ 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: update or add object?
Dang, I knew there was something there! Thanks R. Gorman :) On Sep 22, 6:10 pm, "R. Gorman" <[EMAIL PROTECTED]> wrote: > get_or_create > > http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-cre... > > R. > > On Sep 22, 7:55 pm, John M <[EMAIL PROTECTED]> wrote: > > > Is there a method I can call in a view that given a key, it checks to > > see if that object exists and if it does returns that object, or if it > > doesn't, adds it to the DB and returns the new key? > > > I could have sworn there was a shortcut for this. > > > Thanks > > > John --~--~-~--~~~---~--~~ 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: Multithreaded development server
Some threads on here have used CherryPy's django Plug-in and it's a full server too. You only need to account for Admin files via some well know workings. J On Jan 24, 4:08 pm, Almad wrote: > Hello, > > is there a way to run development server multithreaded, so it can > handle recurring requests? > > Thanks, > > Almad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-smtpd allows you to handle email messages just like Django processes HTTP requests
Wow, very cool. How will this integrate on a production server? is this a true Mailto: link or something else. I mean it doesn't look like a real SMTP engine. I love the idea though! J On Jan 24, 8:29 am, nside wrote: > Hello, > > I just started a new project that basically allows you to write email > handlers in Django. It could be used in a user-registration > application where the user could reply to the email instead of > clicking on a URL. > I drafted a quick documentation > athttp://code.google.com/p/django-smtpd/wiki/GettingStarted > It shows the basic design of the lib and I'm looking for comments/ > suggestions/use cases if that's of interest to anyone on this list. > Note that this is still in "hacking" phase so don't consider using > this in a production system. > > Thanks! > Denis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
new record - onetoonefield - create related record
Given the model's below, I'm trying to make it add the related 1-1 record automatically, but it's not working, what am i missing? Thanks John class unixhost(models.Model): name = models.CharField(max_length=50) # short name fqdn = models.CharField(max_length=50) # FQDN os = models.CharField(max_length=10, blank=True)# What OS is on the box. level = models.CharField(max_length=10, blank=True) # Prod, QA, DR, DEV # default manager objects = models.Manager() def save(self, force_insert=False, force_update=False): # check if 1-1 record is needed if self.id == None: # Create a hostsetting object print "adding hostsetting to new object" hs = hostsetting() self.hostsetting = hs super(unixhost, self).save(force_insert, force_update) # call the real one. def __unicode__(self): return self.name class hostsetting(models.Model): host = models.OneToOneField(unixhost) hostinfo = models.BooleanField(blank=True) # have we gotten the hostinfo on this box yet? users = models.BooleanField(blank=True) # have we collected users on this box? installed = models.BooleanField(blank=True) # is likewise installed? delay = models.BooleanField(blank=True) # is this delayed? # default manager objects = models.Manager() def __unicode__(self): return "Settings for host " + self.host.name --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: new record - onetoonefield - create related record
Hi Karen, and thanks for the reply. I've always wanted to use the 1-1 field, but whenever a new parent record is added, I want it to automatically add (via the save() ) ovoerride above to the child 1-1 table. Yes, the debug does print, and the above code seems to work from the shell too, it's just when I try to create a new record from the shell, using the above model code, it doesn't work. I'm thinking I'm missing something simple? I wonder if I should create the child record with : hs = hostsetting(host=h) hs.save() ? I hope this helps you find my bug. Thanks John On Jan 30, 8:15 pm, Karen Tracey wrote: > On Fri, Jan 30, 2009 at 4:29 PM, John M wrote: > > > Given the model's below, I'm trying to make it add the related 1-1 > > record automatically, but it's not working, what am i missing? > > Perhaps if you described what "not working" looks like in more detail it > would be easier for people to help. I can see you've got at least one > debugging print -- do you ever see that issued? Also, how are you creating > the objects -- custom view, admin site...? > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
simple record output
I'm trying to use the generic views and templates to get a very simple text output of records. I don't want HTML, but need them available from a command line (via curl). Here's my URL setup. newhosts_dict = { 'queryset' : unixhost.objects.all().filter(hostsetting__userlist = False) } urlspatterns... (r'^likewise/newhosts/$', 'django.views.generic.list_detail.object_list', newhosts_dict), here's the template: {% if object_list %} {% for obj in object_list %} {{ obj.name }} {% endfor %} {% endif %} If the queryset only has 1 record in it, why do I have three lines in my output? 1 blank, 1 record output, and one 1 blank. thoughts? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: simple record output
Grrr, I answered my own quesiton, if I remove all the CR's from the template, then it's OK. So changing the template to {% if object_list %}{% for obj in object_list %}{{ obj.name }}{% endfor %}{% endif %} Works like I want. But now, how can I not have the CR's in the template effect my output? Thanks On Feb 2, 12:57 pm, John M wrote: > I'm trying to use the generic views and templates to get a very simple > text output of records. > > I don't want HTML, but need them available from a command line (via > curl). > > Here's my URL setup. > newhosts_dict = { > 'queryset' : unixhost.objects.all().filter(hostsetting__userlist = > False) > } > > urlspatterns... > > (r'^likewise/newhosts/$', > 'django.views.generic.list_detail.object_list', newhosts_dict), > > here's the template: > > {% if object_list %} > {% for obj in object_list %} > {{ obj.name }} > {% endfor %} > {% endif %} > > If the queryset only has 1 record in it, why do I have three lines in > my output? 1 blank, 1 record output, and one 1 blank. > > thoughts? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: simple record output
BRILLIANT, that's what I was looking for , thanks Jake! On Feb 2, 2:19 pm, Jake Elliott wrote: > hi john - > > you can use the 'spaceless' tag in your > template:http://docs.djangoproject.com/en/dev/ref/templates/builtins/#spaceless > > to filter out spaces & carriage returns. > > -jake > > On Mon, Feb 2, 2009 at 3:41 PM, John M wrote: > > > Grrr, I answered my own quesiton, if I remove all the CR's from the > > template, then it's OK. > > > So changing the template to > > > {% if object_list %}{% for obj in object_list %}{{ obj.name }}{% > > endfor %}{% endif %} > > > Works like I want. But now, how can I not have the CR's in the > > template effect my output? > > > Thanks > > > On Feb 2, 12:57 pm, John M wrote: > >> I'm trying to use the generic views and templates to get a very simple > >> text output of records. > > >> I don't want HTML, but need them available from a command line (via > >> curl). > > >> Here's my URL setup. > >> newhosts_dict = { > >> 'queryset' : unixhost.objects.all().filter(hostsetting__userlist = > >> False) > >> } > > >> urlspatterns... > > >> (r'^likewise/newhosts/$', > >> 'django.views.generic.list_detail.object_list', newhosts_dict), > > >> here's the template: > > >> {% if object_list %} > >> {% for obj in object_list %} > >> {{ obj.name }} > >> {% endfor %} > >> {% endif %} > > >> If the queryset only has 1 record in it, why do I have three lines in > >> my output? 1 blank, 1 record output, and one 1 blank. > > >> thoughts? > > >> Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Coming Soon
django is probably the most updated doc and program I've used. If you watch the community section for feeds of all the blogs and postings, you'll find tons of great information. This group is your second best place to be. There are tons of django sites, etc. I think if you poke around, you'll find that you've made an excellent choice! Have fun! John On Feb 3, 5:57 pm, timlash wrote: > Hello! > > Just finished the four part tutorial and I'm excited to learn more. I > can't help but notice that both the 0.96 and latest version of the > tutorial end with the same "Coming Soon" section: > > Coming soon > > The tutorial ends here for the time being. Future > installments > of the tutorial will cover: > > * Advanced form processing > * Using the RSS framework > * Using the cache framework > * Using the comments framework > * Advanced admin features: Permissions > * Advanced admin features: Custom JavaScript > > In the meantime, you might want to check out some > pointers on where to go from here > > The 0.96 page was last updated February 26, 2007, 10:27 p.m. (CDT). > > I hope such definitional oddities are not prevalent in Django! > > Are there any code sample repositories? > > Thanks! > > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin and 1-1 fields
I tried to find this in the admin code, but was unsuccessful. If I have a model with a 1-1 relationship, and in my admin.py I specify that the 1-1 related model is in an INLINE, I notice that the admin interface is smart enough to add a new 1-1 related record when necessary. I'm wondering in the code where they do this, as I'm trying to do the same. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Cherrypy and view variables caching?
I'm having a strange problem with running django on a Cherrypy server. in my views.py, I setup a variable called oneweekago, and set it to today() - (days=7) (it's obviously a date type variable), then in my query, I ask for all records that are __LTE=oneweekago. This code works perfect the day I start my server, but the next day, if there are records that meet the criteria, it doesn't. Like the variable oneweekago is not getting recalculated. If I restart the server, it works great. Here's the actual code in question: oneweekago = datetime.date.today() - datetime.timedelta(days=7) disablehost_dict = { 'queryset' : unixhost.objects.all().filter( hostsetting__sshkeys = True, hostsetting__userlist = True, hostsetting__installed = True, hostsetting__delayed=False, hostsetting__installdate__lte=oneweekago, unixuser__enabled = True, unixuser__user__disable = True ).distinct(), } I don't know if the local server has the same issue, since I don't run that for more than a day. I'm using runcpserver management plugin to run it under cherrypy. http://lincolnloop.com/blog/2008/mar/25/serving-django-cherrypy/, and it's great (except for this :) Any help is 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Cherrypy and view variables caching?
Malcolm, thanks for the reply and I figured that was my issue. Which leads me to another question, does everyone put all view code into views.py even though a simple generic view is all that's used? THanks again John On Mar 5, 4:05 pm, Malcolm Tredinnick wrote: > On Thu, 2009-03-05 at 14:54 -0800, John M wrote: > > I'm having a strange problem with running django on a Cherrypy > > server. > > > in my views.py, I setup a variable called oneweekago, and set it to > > today() - (days=7) (it's obviously a date type variable), then in my > > query, I ask for all records that are __LTE=oneweekago. > > > This code works perfect the day I start my server, but the next day, > > if there are records that meet the criteria, it doesn't. Like the > > variable oneweekago is not getting recalculated. If I restart the > > server, it works great. > > > Here's the actual code in question: > > > oneweekago = datetime.date.today() - datetime.timedelta(days=7) > > If all this indentation is correct (and the email has screwed things up > pretty badly here, so you might want to use dpaste next time -- and > switch to spaces instead of tabs for your Python code, which is pretty > normal), then this line is going to be a problem. It's evaluated once, > when the file is imported. If the file isn't imported again (which would > happen if the server didn't restart), the value won't change just > because the date did. > > You'd be better off doing that computation each time you need it (once > per function). It's hardly a huge timesink to do the computation. > > Regards, > Malcolm > = --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Cherrypy and view variables caching?
Well, given my example, i would think it does. I put the generic's in the URL.PY file and it's not performing as planned, I'm not sure how I would keep the generic view inside the URL and get what I want? Either way, doesn't matter, I'm going to put all 'view' code into views.py eitherway. J On Mar 5, 6:33 pm, Malcolm Tredinnick wrote: > On Thu, 2009-03-05 at 18:32 -0800, John M wrote: > > Malcolm, thanks for the reply and I figured that was my issue. > > > Which leads me to another question, does everyone put all view code > > into views.py even though a simple generic view is all that's used? > > That question doesn't really make sense. If you're only using a simple > generic view, then what does "all view code" mean, since there isn't > anything else? > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
manage.py dumpdata app.model doesn't seem to work?
I tried using the command $ python manage.py dumpdata app.model. where app is the name of my application and model is one of it's models, I didn't actually use the names app and model. I get the following error: django.core.exceptions.ImproperlyConfigured: App with labelapp.model could not be found. I'm running 1.1 alpha 1. Thoughts? I'd love to be able to dump the data for just one table and then reload it. Thanks John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: File Upload : Memory consumption
I've seen quite a few posts on this, and I think it's documented as well. As I recall, there is a certain way of doing large uploads, search the docs and the forum and I'm sure you'll find it. On Jun 24, 3:20 am, alecs wrote: > Hi! I'm trying to upload a large file (700Mb) and something wrong with > django happens: First it starts caching enormously (4Gb of ram are > used), than it starts to purge caches and starts swapping (1Gb of swap > is used). > Have you ever faced with such a thing ? Django 1.02, mod_wsgi + Apache > 2.2 > Thanks :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Good OneToOneField design?
Hey everyone, I'm trying to use the 1-1 fields, and love the examples and how it works, once it's created. However, I'm having trouble determining when in my code to create the actual instance of the 1-1 object. What I really want is for the save() method of the 'master' side of the model to create the 1-1 record, and that's easy enough, but if I then start putting the 1-1 model into the admin interface, it seems to error out when I try saving new records in the admin interface. Am I off in thinking the creation of the 1-1 record should be done in the save() method or should it be somewhere else in a view? What I'd love to hear are peoples examples of how they used 1-1 fields and implemented them in their code. Thanks so much John Matthew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
DecimalField's and lots of math
I'm wondering how people deal with the DecimalField in django? I've just discovered the amount of typecasting I have to do to work with this field, example: field1 = models.DecimalField(...) you can't do : y = field1 / 100.0 you have to do y = field1 / Decimal(100) But then you can't do this either: y = field1 / Decimal(a + b / 2.0) Am I missing something, or does the Decimal field just require a ton of typecasting to keep it sane? Thanks John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to use several different querysets in one single template(for a single url)?
You might want to think about using the direct_to_template function instead, it uses the Request Context values, which allows you to take advantage of the login system, where as the render_to_response does not (by default). J On Apr 13, 7:16 pm, jason wrote: > using the common view function(render_to_response) would solve the > problems. i should have checked the django documentation more > carefully. > > On Apr 13, 7:48 pm, jason wrote: > > > hi guys, > > > i want to create a page includes several querysets to display several > > boards of different staffs. i used the generic.list_detail to do this, > > but the object_list seemed to accept only one dictionary argument to > > go. so how can i use several querysets in the single template to > > display different record sets? like the index page of most websites, > > there are many contents from different data sources. > > > thanks. > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Leopard deploy directory?
/opt is the typical linux location, my mac has a few things there now. J On Apr 13, 4:12 pm, Shannon wrote: > Hi -- I am working on a django-powered site on Leopard server. Where > is the recommended/conventional deployment directory? Every example I > see uses a particular user's home directory, but that does not seem > appropriate for a production-level site. I'm fairly new to the > Leopard environment and am curious what people typically use for their > production deployment directory. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FT Django/Python developer position
you should also post this on www.djangogigs.com On Apr 21, 7:39 am, HPL wrote: > World renowned company located in the heart of Washington, DC is > looking to hire a Python/Django developer to work on website developed > on Python-based Django web application framework, Linux environment. > Developer would work on a small ridiculously talented team. The site > is very cool - interactive, has videos, sections on music, history, > science, space, photography, daily news, animals, puzzles, etc. > > Challenging, creative and fun environment. I have known the Director > of Application Development at National Geographic for over 10 years. > Before this position, he worked at Discovery Communications. He is a > creative, ethical, smart man and a delight to work with. > > Position is one year with excellent benefits. > > In these hard economic times, web developers, like everyone are being > laid off. If you think of someone who is very talented and might be a > good fit, please feel free to forward this email. > > If you are interested, please contact Ms. Lewis at (202) 244-9343 and > send your resume to hlewisconn...@starpower.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I retrieve this Customer.objects.filter(serial<>'')
is it empty like " " or is it null? customer.objects.filter(serial__isnull=True) HTH On Apr 28, 9:16 am, equalium wrote: > Hello, I'm new to django. I want to retrieve a record of Customers > with an empty serial field. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help with schema
In addition to Malcolms comments, you'll need a way to track if the agent was fired or not, you could do this in several ways: 1. a date fired field (you may want a date hired), a fired boolean field, or a more complicated way, an archive type setup that moves the fired agents to another table (this probably would be the best performance option, but more coding). HTH J On May 5, 11:01 am, Malcolm Tredinnick wrote: > On Tue, 2009-05-05 at 06:02 -0700, Chris McComas wrote: > > I have a site/database that tracks baseball players and their agents. > > Players can have multiple agents at one time, they also can fire > > agents and hire new ones at anytime, and I'd like to track all of > > their agents, current, or previous. I was thinking of this schema for > > my models, but wasn't sure the best way to handle the previous agents, > > etc. Also, players can rehire a previous agent... > > > Would it be best to have another model that has a FK to player and MTM > > to agent with the dates of hire, fired? > > >http://dpaste.com/41109/ > > I think you're thinking along the right lines. Since you already have > Player and Agent objects, you only have to model the relationship > between them. It seems to me this is a many-to-many relationship with > some extra information on the intermediate table: the start and > (nullable) end dates of the relationship. > > This is an ideal situation for ManyToManyField(through=), where the > "through" table contains the two dates, as well as ForeignKeys to the > Player and Agent models. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: disable django cache
Are you sure it isn't your browser? have you tried testing your concern with curl? On May 14, 12:19 pm, online wrote: > Hi all, > > I have a small project still under development. I don't set any cache > stuff yet. But for somehow django still cache all web pages. > > Why django default uses cache? How can i disable the all level > caches? > > I tried > > from django.views.decorators.cache import cache_control > > @cache_control(private=True) > > and > > from django.views.decorators.cache import never_cache > > @never_cache > > on views.py but not working > > Thanks for any help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: View returns no queryset
I suspect that the query isn't being executed, cause you're not accessing any elements? have you tried to print games and see what comes out? passing {games:"object_list"} seems like it should make sense, but since I'm not an expert on Python or django, I'd imagine that the "object_list" isn't being hit, hence the no query. Try the print, and then you'll know if it's a variable in your template error or something. Do you have the code that you used when you used a generic view? HTH J On Nov 28, 3:15 pm, "R. Gorman" wrote: > I've got a real stumper. Well, a stumper for me; I'm hoping someone > has some insight. Here's the view I'm calling: > > def season_schedule_month(request, league_slug, year, month): > """Given a league slug, retrieve the season's schedule > month by month. > return date_based.archive_month( > request, > year = year, > #month_format = "%m" > month = month, > date_field = 'date', > queryset = Game.season.schedule(league_slug), > template_name ='season_schedule.html')""" > #games = Game.season.schedule(league_slug).filter > (date__month=month) > games = Game.objects.all() > return render_to_response('season_schedule.html', > {games:"object_list"},context_instance = RequestContext(request)) > > It was originally a generic view, but I've reduced it down to a simple > all objects request because of the bug in my code I'm trying to figure > out. So the generic view does not work either. The same query run in > the Django shell produces something like 30 objects. This page is > returned without any errors but also without any queryset. It doesn't > even give an empty set of brackets, denoting an empty queryset. I've > looked at the django debug-toolbar and it does not show the SQL query > in the queries list, so it appears the query is not even run. Rest of > the site, which often accesses the same model, runs fine. I have no > idea why this simple query will not run correctly. It is code related > because I've moved the code to a different server with a different > setup and the problem follows. > > Anyone run into this before? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Installation Problem on Mac OS Leopard
Me too, I'm not having any issues. I just installed on 10.6 by downloading 1.1.1 and running the install command sudo python setup.py install and no issues. After install I run django-admin.py --version and it shows 1.1.1 You'll need to give us more info to help. Are you using sudo? What version of OSX? I wonder what version of Python you have? Maybe that's the issue? HTH John On Nov 27, 1:15 pm, Christophe Pettus wrote: > On Nov 27, 2009, at 1:01 PM, Eric wrote: > > > Why doesn't > > Mac have an easy way to install stuff. > > I think we'll need a bit more information about the problem you're > having; installing Django 1.1 on my Leopard MacBook Pro was entirely > painless. What errors are you getting at which steps? > > -- > -- Christophe Pettus > x...@thebuild.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Chart tool
We started playing with FusionCharts, they have a free version which is pretty slick. It's flash based, and not sure about the printing aspect yet. It's generated with some XML and an SWF file. J On Nov 25, 12:07 pm, "S.Selvam" wrote: > Hi all, > > This is my first post here andi am new to django. > > I need to show some data as a chart. > > I would like to achieve a high quality rendering. > > Is reportlab or matplotlib enough ? > > I hope you can direct me on track. > > -- > Yours, > S.Selvam > Sent from Bangalore, KA, India -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: custom query unique and ordered
I would be easier to see it as a django table, but you'll need to checkout the distinct() feature of the queryset http://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct But yes, I'd say it's possible. J On Nov 30, 4:10 pm, Ali Rıza Keleş wrote: > Hi all, > > I need a little custom db query. My db table with sample data: > > id content_id author_id order is_public > 1 68 1 1 1 > 3 189 2 2 1 > 4 154 2 3 1 > > I want to catch unique authors public content ordered by order field. > > The result must be: > > id content_id author_id order is_public > 1 68 1 1 1 > 3 189 2 2 1 > > How can I do it? > > Thanks.. > > -- > Ali -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Help with Custom Manager and UNION query?
I'm not sure a Manager is what you want, what about Q(http:// docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with- q-objects) objects? I've used them before and I think it's about what you'd need. As for performance, not sure how they stack up On Nov 30, 2:45 pm, Info Cascade wrote: > Hi -- > > I've been programming with Django about a year, and really like it, but > I've run into something that I can't quite solve on my own. > I think someone else may be able to offer the answer, or at least a hint > to send me in the right direction. > > I have two tables I want to search in simultaneously, Article and Tag. > They have a many-to-many relationship. > I want to get a QuerySet of Articles that match a query term on > article.title, as well as those that match on tag.name. > I can get what I want using SQL, but how do I do it in Django (with > acceptable performance)? > Ideally, I want to be able to add .filter() and .exclude() to the > QuerySet. These SQL examples below are the basic idea, but in some > cases I'm adding .filter and .exclude. > Currently, the code looks something like this (I simplified it a bit, > but this should give an idea): > > > art_list = Article.objects.filter(status__status='PUBLISHED') > > art_list = art_list.extra( > > where=["title_tsv @@ plainto_tsquery(%s)"], > > params=[term]) > > if channel: > > art_list = art_list.filter(channel=channel) > > art_list = art_list.distinct() > > art_list = art_list.order_by(*order_by) > > Somehow, I want to include the fulltext search on the tag.name field, > where=['name_tsv @@ plainto_tsquery(%s)'], > params=[term]) > > The two SQL example queries below both give the correct results. > However, the first one with joins takes over 20 seconds. > The second one with UNION is quite fast. > > I think what I need to do might be to create a custom manager for > Article that would execute the UNION query and return a QuerySet with > all the matching Articles. I'm not sure quite how to do that, > especially if I expect it to work with the .filter() and .exclude() > methods. > > -- full-text search on article.title and tag.name > SELECT DISTINCT article.title > FROM article JOIN article_tags ON article.id = article_tags.article_id > JOIN tag ON article_tags.tag_id = tag.id > JOIN article_status ON article_status.id = article.status_id > WHERE article_status.status = 'PUBLISHED' > AND (tag.name @@ plainto_tsquery('french restaurants') > OR title_tsv @@ plainto_tsquery('french restaurants')) > ORDER BY article.title; > > -- alternative full-text search on article.title and tag.name with UNION > -- with ranking > SELECT DISTINCT article.title, ts_rank_cd(title_tsv, q1) AS rank > FROM plainto_tsquery ('french restaurants') AS q1, article > JOIN article_status ON article.status_id = article_status.id > WHERE article_status.status = 'PUBLISHED' AND > title_tsv @@ q1 > UNION > SELECT DISTINCT article.title, ts_rank_cd(name_tsv, q2) AS rank > FROM plainto_tsquery('french restaurants') AS q2, article > JOIN article_tags ON article.id = article_tags.article_id > JOIN article_status ON article.status_id = article_status.id > JOIN tag ON article_tags.tag_id = tag.id > WHERE article_status.status = 'PUBLISHED' AND > tag.name @@ q2 > ORDER BY rank DESC, title; > > So -- if anyone can offer any advice on this, I would very much > appreciate it!!! > > Best, > Liam -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to call this function
I think you're confusing Templates and HTML in this one, the for loop is just a construct while the template is constructing the final HTML code, not executing the HTML alongside the template? Does that help? I think you'll need to look at custom filters http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-filters for a solution to what you want, but if you could tell us what ShowDomain does, that would help alot. On Nov 30, 9:42 pm, David wrote: > Hello, > > In my template file I have > > {% for value in data %} > {% ifequal all_domain 1 %} > class="odd" id="{{value.publisher}}" > "showDomain('{{value.publisher}}', '{{value.country}}');" > {% else %} > ... > {% endifequal %} > > > > {% endfor %} > > "showDomain(...)" is a JavaScript function. I would like this function > to be called in each iteration of the for-loop when all_domain == 1. > Anybody knows how to call this function? There are no events (click, > drag, mouseover, etc) here. > > Thanks so much. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Can't run Django from the command line using just "manage.py runserver", following attempt to install Python2.6 on windows 7.
Sounds like the .py extension isn't seen as using python, should be an easy fix. Check your file associations (where they are in Win7) I'll have to find at work tomorrow, but that should fix your issue. Or, it could be some new security scheme that MS has come up with to not allow associations at the CMD level? sounds like that would break too much stuff though, I'll try it at work tomorrow and if it's not an association thing, I'll check back on this thread. J On Nov 30, 8:36 am, Rodrigo Cea wrote: > Following an abortive attempt to install Python2.6 on Windows 7, I > can't run the Django dev server without prepending "python" before > "manage.py runserver". > > I tried recently to install Python2.6 on a windows 7 system that > already has python 2.5 installed. I had problems running some Django > applications I'm working on, so I uninstalled it. > > Now I can't run the dev server the way I used to: "manage.py > runserver", I get: > > "Type 'manage.py help' for usage." > > If I run it like so: "python manage.py runserver" it works. > > I have checked for other python installs on the system, and there was > just one in Cygwin which I have deleted. > I have checked running programs with and without "python" and the > executable is the same: "C:\python2.5\python.exe". > > This also affects other programs, e.g.: easy_setup, which I can't just > run as "easy_setup package_name" anymore, but rather "python /path/to/ > easy_setup package_name". > > This is more annoying than anything else, but any help is 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: A Design Question
Even though it is outside the scope, I'd say start simple and build slowly with related tables, those are easy to add to a system. I'd probably find the attributes you'd like to capture in the 'extra details' and start putting them in a table. Determine what the purpose of these attributes are, searching, reporting, calculations, etc and that should help you determine if you need more than one 'extra' table. HTH John On Nov 29, 10:36 am, Ramdas S wrote: > This is probably outside Django. But I am checking out since I am building > it with Django. > > I am building a specialized closed group social networking web site for > special set of medical practitioners. Idea for my client is to be a mini- > LinkedIn of sorts for this small community. > > We want to capture as many details as possible from some clinical practices, > to education, work experience, papers submitted etc. However at registration > time we want to limit it to just the basic details like name, email and may > be some license number. > > However over a period of time we would like the user to add details. > > Do I build one large UserProfile Table, with ForeignKey to colleges, > specializations etc or do I break it up into number of smaller profiles, and > link each profile to a User. What's the best practice? > > -- > Ramdas S -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to populate the database
You could also use OpenOffice with the SQLIte connector (I think) I use Access in Windows, works great! But you might try getting the CSV into a JSON format that the manage.py loaddata command could use, that set's you up for the future too. J On Dec 10, 8:57 am, Zeynel wrote: > Can anyone point me in the right place in documentation for populating > my sqlite3 tables with the data in the .csv file? Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Cross tabulation in template
I've got data that looks like this from a query {'status': u'E', 'env__count': 15, 'env': u'dev'} {'status': u'H', 'env__count': 31, 'env': u'dev'} {'status': u'I', 'env__count': 164, 'env': u'dev'} {'status': u'N', 'env__count': 149, 'env': u'dev'} {'status': u'I', 'env__count': 17, 'env': u'dr'} {'status': u'H', 'env__count': 2, 'env': u'prod'} {'status': u'I', 'env__count': 34, 'env': u'prod'} {'status': u'E', 'env__count': 2, 'env': u'qa'} {'status': u'H', 'env__count': 1, 'env': u'qa'} {'status': u'I', 'env__count': 63, 'env': u'qa'} {'status': u'N', 'env__count': 5, 'env': u'qa'} {'status': u'E', 'env__count': 1, 'env': u'stage'} {'status': u'H', 'env__count': 4, 'env': u'stage'} {'status': u'I', 'env__count': 59, 'env': u'stage'} {'status': u'N', 'env__count': 2, 'env': u'stage'} {'status': u'E', 'env__count': 8, 'env': u'xxx'} {'status': u'H', 'env__count': 1, 'env': u'xxx'} {'status': u'I', 'env__count': 38, 'env': u'xxx'} {'status': u'N', 'env__count': 3, 'env': u'xxx'} is there anyway to make a cross-tab output in a template? My only solution right now is to pass in several dictionaries with each of the status's and their counts. Other ideas would help. Thanks John -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Hosting for django?
There was recently a blog on several of the VPS's, EC2 scored a very poor last place, while LiNode scored the best. You can find it on the djangoproject community link. J On Dec 22, 10:59 am, yummy_droid wrote: > Hi, > > Has anyone had good experiences with hosting companies that I can use > for production django apps, with backups, etc.? > > I would also want to add some extensions etc. as well (e.g. > matplotlib, reportlab, etc.). > > Anyone use godaddy? > > Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: more complex queries
Sounds like two queries to me, sum all the refunds and then subtract them from all the non-refund amounts. does that work for ya? On May 20, 5:17 pm, Chris Withers wrote: > Hi All, > > I have a Transaction model with a DecimalField called "amount" and a > CharField called "action". > > How do I sum all the transactions, multipling the amount by -1 when the > action is REFUND? > > cheers, > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > -http://www.simplistix.co.uk > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Model inheritance and simple access
I've gotten model inheritance working just fine, but was hoping someone could confirm the best way to access the model. When I have a Base model which has a ForeignKey to a parent table, and that base model has inherited models after it, how can I refer to only one name when referencing the parent model. As an example: class Base(models.Model): parent = models.ForeignKey(Model1) class Meta: abstract = True def basemethod(): print "hello" class ChildA(Base): pass class ChildB(Base): pass p1 = Model1() p1.save x = ChildA() x.parent = P1 x.save() p2 = Model1() p2.save() y = ChildB() y.parent = P1 y.save() Now, I want to access the children from the parent, but I don't want to have to know what base class they are, is there a way to do that? Right now I'm using a property which figures it out based on some other fields, but would love to be able to say p = Parent1.objects.get(id=1) p.child.basemethod() Is this possible? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Model inheritance and simple access
Hmm, that doesn't really get me what I want, it just caches the related child objects in one SQL query. What I want is a single interface and have django figure out what type of child object I have (like multiple inheritance but 'better'). So in my example: p = Parent1.objects.get(id=1) p.child.basemethod() django would know what p.child is (either ChildA or ChildB) and I wouldn't need to know. Is that available? J On Jun 8, 11:09 am, Dejan Noveski wrote: > http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4 > > select_related() > > > > On Tue, Jun 8, 2010 at 8:05 PM, John M wrote: > > I've gotten model inheritance working just fine, but was hoping > > someone could confirm the best way to access the model. > > > When I have a Base model which has a ForeignKey to a parent table, and > > that base model has inherited models after it, how can I refer to only > > one name when referencing the parent model. > > > As an example: > > > class Base(models.Model): > > parent = models.ForeignKey(Model1) > > > class Meta: > > abstract = True > > > def basemethod(): > > print "hello" > > > class ChildA(Base): > > pass > > > class ChildB(Base): > > pass > > > p1 = Model1() > > p1.save > > x = ChildA() > > x.parent = P1 > > x.save() > > > p2 = Model1() > > p2.save() > > y = ChildB() > > y.parent = P1 > > y.save() > > > Now, I want to access the children from the parent, but I don't want > > to have to know what base class they are, is there a way to do that? > > Right now I'm using a property which figures it out based on some > > other fields, but would love to be able to say > > > p = Parent1.objects.get(id=1) > > p.child.basemethod() > > > Is this possible? > > > Thanks > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > -- > Dejan Noveski > Web Developer > dr.m...@gmail.com > Twitter:http://twitter.com/dekomote| > LinkedIn:http://mk.linkedin.com/in/dejannoveski -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Model inheritance and simple access
I was hoping to avoid that type of code, but instead have put a field in the linked parent to indicate what type the child is and then have a method in the parent as a property which returns the correct child type. Works for now, would be nice if the framework kept track of it, but it's a rare case. J On Jun 8, 12:41 pm, Dan Harris wrote: > Not sure if this will work as I don't usually do much with model > inheritance but according to docs > at:http://docs.djangoproject.com/en/dev/topics/db/models/#id7 > this might work (not pretty, but somewhat minimal code)... > > p = Parent1.objects.get(id=1) > try: > p.childa.basemthod() > except: > try: > p.childb.basemethod() > except: > raise Execption("not ChildA or ChildB") > > Django adds in the lower cased name of the class as a property when > you query the super class and throws an exception if you access a > property that isn't there. So something like the above "might" work. > And obviously if you have like 5 child classes, this gets ugly very > quickly. > > Dan Harris > dih0...@gmail.com > > On Jun 8, 3:27 pm, John M wrote: > > > Hmm, that doesn't really get me what I want, it just caches the > > related child objects in one SQL query. > > > What I want is a single interface and have django figure out what type > > of child object I have (like multiple inheritance but 'better'). > > > So in my example: > > > p = Parent1.objects.get(id=1) > > p.child.basemethod() > > > django would know what p.child is (either ChildA or ChildB) and I > > wouldn't need to know. > > > Is that available? > > > J > > > On Jun 8, 11:09 am, Dejan Noveski wrote: > > > >http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4 > > > > select_related() > > > > On Tue, Jun 8, 2010 at 8:05 PM, John M wrote: > > > > I've gotten model inheritance working just fine, but was hoping > > > > someone could confirm the best way to access the model. > > > > > When I have a Base model which has a ForeignKey to a parent table, and > > > > that base model has inherited models after it, how can I refer to only > > > > one name when referencing the parent model. > > > > > As an example: > > > > > class Base(models.Model): > > > > parent = models.ForeignKey(Model1) > > > > > class Meta: > > > > abstract = True > > > > > def basemethod(): > > > > print "hello" > > > > > class ChildA(Base): > > > > pass > > > > > class ChildB(Base): > > > > pass > > > > > p1 = Model1() > > > > p1.save > > > > x = ChildA() > > > > x.parent = P1 > > > > x.save() > > > > > p2 = Model1() > > > > p2.save() > > > > y = ChildB() > > > > y.parent = P1 > > > > y.save() > > > > > Now, I want to access the children from the parent, but I don't want > > > > to have to know what base class they are, is there a way to do that? > > > > Right now I'm using a property which figures it out based on some > > > > other fields, but would love to be able to say > > > > > p = Parent1.objects.get(id=1) > > > > p.child.basemethod() > > > > > Is this possible? > > > > > Thanks > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups > > > > "Django users" group. > > > > To post to this group, send email to django-us...@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > > django-users+unsubscr...@googlegroups.com > > > groups.com> > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/django-users?hl=en. > > > > -- > > > -- > > > Dejan Noveski > > > Web Developer > > > dr.m...@gmail.com > > > Twitter:http://twitter.com/dekomote|LinkedIn:http://mk.linkedin.com/in/dejannoveski -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New tutorial added to Django by Example
WOW, this is very cool, you should see if you can add it to the main django tutorial someway? J On Jul 6, 3:50 pm, Rainy wrote: > I've added a new tutorial: A simple Blog to my Django by Example site. > As > always, feedback is appreciated. > > This tutorial covers display of monthly archive, pagination, a simple, > basic comment system, notification when comments are posted and a > flexible > interface for deletion of spammy comments. > > Hope you enjoy it! -ak -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Question on the Tutorial
Also check out the paginator view http://docs.djangoproject.com/en/dev/topics/pagination/ On Jul 9, 12:27 pm, rupert wrote: > I'm creating an app based on the tutorial. Is there a way to display > all of the objects that are created on the same page using a view? > Could someone help me with 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Help Converting a Query getting one result using .filter() to .get()
Why does it matter? You could just say next_game[0] instead. J On Jul 12, 4:28 pm, Chris McComas wrote: > I have this query, trying to get the next game in the future. > > today = datetime.datetime.now() > next_game = Game.objects.filter(date__gt=today).order_by('date')[:1] > > I need to use .get() if possible, instead of .filter() how can I 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: manually add objects to a QuerySet
I asked a similar question like, I want to sort a QS on a meta field, can it be done? The answer worked, and is the same one you're getting, use a list. qs1 = model1.objects.filter(...) qs2 = model2.objects.filter(...) lqs1 = list(qs1) lqs2 = list(qs2) now you have something that is a python list that won't hit the db. J On Aug 7, 9:15 pm, chefsmart wrote: > I had asked this on stackoverflow, but I guess I couldn't explain > myself clearly enough. I'll try to ask again here: > > Say I have two objects obj1 and obj2 of the same model (MyModel), now > I would like to add these objects to a new QuerySet. Can I create a > QuerySet manually like the following > > my_qs = QuerySet(model=MyModel) > > and then add obj1 and obj2 to this QuerySet like > > my_qs.add(obj1) > my_qs.add(obj2) > > Regards, > CM. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How is this feature called?
So the example you gave of "other peoples" looks like they have a related table for "Service Checks" and that table has two fields, one for check and the other for options, from what I can tell. HTH J On Sep 1, 7:03 am, norus wrote: > Hi all, > > I've decided to start learning Django and Python at the same time. The > project I'm working on will help configure Nagios directly from the > Django administation page. Here's a sample screenshot of what I've > done so far:http://valiyev.net/tmp/progress.png > > Now my question is as follows, under "Check options", how do I add an > additional CharField where I would be able to submit arguments to the > command in "Service Checks"? Here's how other people did it (all I > could find was this > screenshot:http://www.linuxaddicted.de/blog/wp-content/uploads/2009/03/picture-6...). > > Thanks in advance. > > norus -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Iterating over a queryset to run another query?
is the subcategory the same for all the top level categories? if so, i think you should be able to query your category queryset, like this? finalset = Category.objects.filter().filter(subcategory__field=) Unless I'm not understanding. On Oct 13, 10:52 am, Austin Govella wrote: > I have a category page that lists all of its subcategories on it. > > For each subcategory, I would like to query for one product in that > subcategory. > > In PHP, I think I did this in the page, outputting HTML as I went. But > I can't figure out how to do this in Django. My programming brain is > just rusty, so I probably just need a pointer to how I overwriting the > variables when I iterate through the queryset. > > Many thanks, > -- > Austin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Treat two fields as one in a queryset
I think you'll have to sort the list yourself by creating a calculated field, since you're only returning a small number, I don't see this as a big issue. So, get the records back that you want via the ORM, and then copy them over to a list. HTH John On Feb 20, 6:26 pm, shacker wrote: > Given a model like: > > class Item(models.Model): > title = models.CharField(max_length=140) > created_date = > models.DateTimeField(default=datetime.datetime.now) > completed = models.BooleanField(default=False) > completed_date = models.DateTimeField(blank=True,null=True) > ... > > I want to create a queryset that retrieves the last 30 Items that were > either created OR completed most recently. In other words, the > created_date and the completed_date fields need to be treated as if > they were a single date field on the model, so that the returned items > would be chronological by either date (completed_date would only be > considered for items where completed=True) > > I've tried both: > > .order_by('-completed_date','-created_date')[:30] > > and > > .order_by('-completed_date').order_by('-created_date')[:30] > > but neither of these are quite right. Not sure what the right approach > to this should be. Suggestions? Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Adding records to 2 tables at the same time from admin page
If you write something in the model's save() method that should do what you want. On Mar 28, 10:05 pm, cnone wrote: > The admin page has a button to add records. When I click a table from > admin page and click add, I can enter data. What I want to do is I > want to add records to 2 table at the same time. The admin page will > show me all the fields to enter data for both table. When I click save > the data will be saved to both tables. But the tables are not related. > How can I do this from admin page? Is there a way to edit save button > functionality? > > Or another way is to show the first table.When I click save it will > save and redirect to the second table. Is this also possible? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: form_for_model, custom save(), and saving excluded fields?
I had a similar issue, and after lurking around a bit, banging the head on the table, etc, I figured out I could make a form, set the fields to non-editable, use the form.save(commit=False) option, and do exactly what I needed. I was creating a form for a child model,and wanted to fill in the relationship (parent) field/ID myself. Heres a sample of what I did on an update routine (handles adds and edits in same code): def update1(request, portid, holdid=None): objportfolio = Portfolio.objects.get(pk=portid) if holdid is None: # Add function modelform = form_for_model(Holding, form=HoldingForm) form = modelform() else: instance = Holding.objects.get(id__exact=holdid) modelform = form_for_instance(instance, form=HoldingForm) form = modelform(instance.__dict__) if request.POST: form = modelform(request.POST) if form.is_valid(): obj = form.save(commit=False) obj.portfolio = objportfolio obj.save() return HttpResponseRedirect('/holding') return render_to_response('holding/update.html', {'form': form} ) Hope this helps. John --~--~-~--~~~---~--~~ 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: python manage.py startapp freepostcards
Good Luck and have fun. Make sure you post all your pictures on www.tabblo.com (a django site of course). J On Jun 25, 9:20 pm, Kelvin Nicholson <[EMAIL PROTECTED]> wrote: > Dear Djangoers: > > I have thoroughly enjoyed the last few months on this list, yet I must > take a temporary leave. Starting on the 30th I'm heading for a tour > around SE Asia -- Hong Kong, China, Tibet, Laos, Cambodia and Vietnam. > Eventually I will end up in Sydney. > > So why am I making this public? I wanted to make an offer to the > community: if you want a postcard, shoot me a private email with a > mailing address or PO box. There are going to be some long bus/train > rides, and I need something to kill the time with. > > If you receive a postcard and feel like dropping a dollar into my paypal > account to cover postage, that would be nice, but certainly not > necessary. > > Cheers to Django, > > Kelvin > > -- > Kelvin Nicholson > Voice: +886 9 52152 336 > Voice: +1 503 715 5535 > GPG Keyid: 289090AC > Data: [EMAIL PROTECTED] > Skype: yj_kelvin > Site:http://www.kelvinism.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 -~--~~~~--~~--~--~---
Mapping models to CRUD urls?
Loving django still, and now I'm at the point where I'm running into a limit on my understanding on how to map the Model CRUD functions (non- admin style) to a URL pattern. For example: Model1: fielda fieldb Model2: key=Foreignkey(model1) fielda fieldb Model3: key=foriengkey(model2) fielda fieldb So, i'm looking for some help to allow me to CRUD each of these models, and I've come up with a few: http://.../model1/add - calls a view to add a new model1 object to the DB. http://.../model1/edit/#- calls a view to update the model1 ID = # http://.../model2/add/#- calls a view to add a new model2, with a foreign key model1 of # http://.../model2/edit/#- calls a view to edit a model2 of ID #. I guess I continue the same pattern for all sub-models? so model3 would be: http://.../model3/add/#- calls a view to add a new model3, with foreign key model2 of # http://.../model3/edit/#- calls a view to edit a model3 of ID# It seems simple enough, but wanted to get everyones feedback on anything I'm missing, or is it just this simple? Thanks John --~--~-~--~~~---~--~~ 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: Mapping models to CRUD urls?
Russ, Wow, thanks so much for clearing that up, I was never sure about the parameters part of the URL, since this is my first real web program EVER, and I figured django was the right way to go. Does caching matter that much in my example, since it's dynamic data anyway? John On Jul 19, 5:43 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/20/07, John M <[EMAIL PROTECTED]> wrote: > > > > >http://.../model3/add/# - calls a view to add a new model3, with > > foreign key model2 of # > >http://.../model3/edit/# - calls a view to edit a model3 of ID# > > > It seems simple enough, but wanted to get everyones feedback on > > anything I'm missing, or is it just this simple? > > It's pretty much that simple, although there are a few details I would > suggest: > > - You have add and edit views, but no 'view' view - i.e., just show me > the object. The best place for this is probablyhttp://.../model1/# > for model1, ID # (repeated for other models). Alternatively, if there > is no such thing as a non-editing view - if you want an object to be > editable whenever it is viewed, just make thehttp://.../model1/#view > the edit view. If you do this, make sure you do a HttpResponseRedirect > when you POST to prevent the POST request ending up in the browser > history. > > - You might want to have a think about your method of foreign key > hinting using the URL. Each URL should be a unique, cachable resource > - in this case, "add an instance of model3". Adding > transient/suggested data to your URL would generally violate this > principle. On top of that, what do you do to the URL space if you need > to specify 2 foreign keys? > > A alternate approach would be to pass in the preferred foreign key as > part of the GET dictionary i.e., your request would be: > /model3/add/?model1=3. That way, there is only 1 URL resource (the add > page at /model3/add/), and the view can still work if you have no or > multiple specified foreign key references (just modify the handling of > the GET dictionary to inspect 0, 1 or many keys). > > 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 -~--~~~~--~~--~--~---
Private (owner) vs. public records
I want to create a model system where a user can own a record (i.e. foreign key to users table) and those records are only seen by that user OR the user can choose to make the record public (boolean field in model) that allows others to view-only the record. I was trying to come up with some simple model managers to do this, but wanted to get some input first. a Model something like: class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) owner = models.ForeignKey(user) public = models.booleanfield() Basically, this will be a site where users can keep track of their stuff, but allow others to view what they have too (the person model isn't what I'm going to use, just an example). Any thoughts? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Running django+apache on my macbook
OK, So I know Linux / Apache pretty well, never really done any hard-core stuff with it. Now I want to use apache on my macbook (intel) OSx 10.5 (upgrade),but have no clue about how to do it. Googling for how to install mod_python results in a lot of issues from what I can find, 64bit vs 32bit, etc. So my question is, whats the easiest way to just get my macbook intel 10.5 to run apache and Django. Thanks everyone John --~--~-~--~~~---~--~~ 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: Running django+apache on my macbook
I guess I wasn't clear on the PURPOSE to do it, experience, not practicality. I love the built-in django server, it's awesome, how much easier could anyone make it, I think none. But, I wanted to get ready for what it might be like to deploy django at a hosting facility, or maybe even on a home setup in Apache, thats all. Since I have a macbook, with Apache 2 installed, I figured I'd try it. after checking the config and various googles, it turns out that getting mod_python on the mac os X might not be as easy as say a debian apt-get kind of thing :). So, back to the question, how do I get a mac book with stock apache installed, to run django? Thanks John On Jan 18, 12:08 pm, Christian Joergensen <[EMAIL PROTECTED]> wrote: > John M wrote: > > OK, > > > So I know Linux / Apache pretty well, never really done any hard-core > > stuff with it. Now I want to use apache on my macbook (intel) OSx > > 10.5 (upgrade),but have no clue about how to do it. > > > Googling for how to install mod_python results in a lot of issues from > > what I can find, 64bit vs 32bit, etc. > > > So my question is, whats the easiest way to just get my macbook intel > > 10.5 to run apache and Django. > > You don't really need Apache and mod_python for developing Django, just > use the built-in webserver. > > Take a look here:http://www.djangoproject.com/documentation/install/ > > Note the first paragraph of "Install Apache and mod_python". Developing > your applications under mod_python is quite a hassle IMO. > > Regards, > > -- > Christian Joergensen | Linux, programming or web > consultancyhttp://www.razor.dk | Visit us at:http://www.gmta.info --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Running django+apache on my macbook
Thanks for the macports idea, i'll have a look. On Jan 18, 10:13 am, William Siegrist <[EMAIL PROTECTED]> wrote: > I recommend installing apache, python, and mod_python via MacPorts. > Thats what I do to run django on various Mac platforms. Granted, I > work with the MacPorts project, so maybe I'm biased, but I also came > from a linux environment and find MacPorts to be very useful for > package management. > > http://www.macports.org/ > > -Bill > > On Jan 18, 2008, at 9:55 AM, John M wrote: > > > > > OK, > > > So I know Linux / Apache pretty well, never really done any hard-core > > stuff with it. Now I want to use apache on my macbook (intel) OSx > > 10.5 (upgrade),but have no clue about how to do it. > > > Googling for how to install mod_python results in a lot of issues from > > what I can find, 64bit vs 32bit, etc. > > > So my question is, whats the easiest way to just get my macbook intel > > 10.5 to run apache and Django. > > > Thanks everyone > > > John > > > > > > smime.p7s > 3KDownload --~--~-~--~~~---~--~~ 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: Running django+apache on my macbook
Anton, that was sort of my question, how do I complete your second idea but w/o the recompile. The mac already comes with apache 2 installed and running rather well, how hard would it be to add mod_python or mod_wsgi to that environment? Thanks John On Jan 18, 10:09 am, "Anton P. Linevich" <[EMAIL PROTECTED]> wrote: > Greeting, John! Fri, Jan 18, 2008 at 09:55:55AM -0800, retireoncsco wrote: > > > > > OK, > > > So I know Linux / Apache pretty well, never really done any hard-core > > stuff with it. Now I want to use apache on my macbook (intel) OSx > > 10.5 (upgrade),but have no clue about how to do it. > > > Googling for how to install mod_python results in a lot of issues from > > what I can find, 64bit vs 32bit, etc. > > > So my question is, whats the easiest way to just get my macbook intel > > 10.5 to run apache and Django. > > * If you need it for developing, just use django bulidin server. > * If you have a free time, than compile apache2 in your homedirectory with > mod_python and other modules. > * you can run any of Linux liveCDs on your macbook with preinstalled > apache, mod_python and django > > -- > Anton P. Linevich --~--~-~--~~~---~--~~ 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: Running django+apache on my macbook
Thakn you Graham, thats what I'm talking about. I just finished trying to compile mod_python, and it's not working, and I figured it was something like that. So it's off to try mod_wsgi. Thanks J On Jan 18, 4:29 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Jan 19, 8:49 am, John M <[EMAIL PROTECTED]> wrote: > > > I guess I wasn't clear on the PURPOSE to do it, experience, not > > practicality. > > > I love the built-in django server, it's awesome, how much easier could > > anyone make it, I think none. But, I wanted to get ready for what it > > might be like to deploy django at a hosting facility, or maybe even on > > a home setup in Apache, thats all. Since I have a macbook, with > > Apache 2 installed, I figured I'd try it. after checking the config > > and various googles, it turns out that gettingmod_pythonon the mac > > os X might not be as easy as say a debian apt-get kind of thing :). > > > So, back to the question, how do I get a mac book with stock apache > > installed, to run django? > > Simple, don't use mod_python as it hasn't been patched to build > cleanly on a 64bit Intel MacOSX Leopard machine. Use instead mod_wsgi > 2.0 (RC) as it will build out of the box on MacOSX. See: > > http://www.modwsgi.org > http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX > > Graham > > > Thanks > > > John > > > On Jan 18, 12:08 pm, Christian Joergensen <[EMAIL PROTECTED]> wrote: > > > > John M wrote: > > > > OK, > > > > > So I know Linux / Apache pretty well, never really done any hard-core > > > > stuff with it. Now I want to use apache on my macbook (intel) OSx > > > > 10.5 (upgrade),but have no clue about how to do it. > > > > > Googling for how to installmod_pythonresults in a lot of issues from > > > > what I can find, 64bit vs 32bit, etc. > > > > > So my question is, whats the easiest way to just get my macbook intel > > > > 10.5 to run apache and Django. > > > > You don't really need Apache andmod_pythonfor developing Django, just > > > use the built-in webserver. > > > > Take a look here:http://www.djangoproject.com/documentation/install/ > > > > Note the first paragraph of "Install Apache andmod_python". Developing > > > your applications undermod_pythonis quite a hassle IMO. > > > > Regards, > > > > -- > > > Christian Joergensen | Linux, programming or web > > > consultancyhttp://www.razor.dk|Visit us at:http://www.gmta.info --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---