Question re: defining nature of relationship with ManyToManyFields
Hi, I am new to Django, so please forgive me if my question is very basic and/or stupid. I would like to keep track of Song and Album models, with a many-to- many relationship between the two (albums contain multiple songs, and songs can appear on multiple albums). class Song(models.Model): title = models.CharField(max_length=300) class Album(models.Model): title = models.CharField(max_length=300) tracks = models.ManyToManyField(Song) What I'd like to do is have the ManyToManyField have some notion of what track number a song is on an album. This isn't information that can be contained in the Song model since songs are assigned different track numbers on different items. When I've dealt with such matters in the past, I would set up a MySQL table with fields 'song_id', 'album_id', 'track_number', and would thereby be able to do tasks like getting a song's track number on any given album and getting a list of songs sorted by track number.for a given album. Is there a way to accomplish these tasks in Django? I expected some sort of ability to add extra fields to the relationship table when declaring a ManyToManyField, but so far have not been able to find any documentation on anything like that. Thank you for the help! Again, I'm new to all this, so I apologize if this is covered in some bit of documentation I missed; if that's the case, a link to the right page would be much appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: SESSION_SAVE_EVERY_REQUEST creates new session?
On Jan 5, 6:33 pm, Peter Rowell <[EMAIL PROTECTED]> wrote: > > only save sessions which have been modified > > Actually, the code in the sessions/middleware is: > if modified or settings.SESSION_SAVE_EVERY_REQUEST: > so the whole point is to save it whether it's modified or not. This wasn't related to your issue, just wanted to put out something I'd been chewing on. Specifically, there's no point in saving a session if it's empty and hasn't been modified. > > But then you mentioned: > > > perhaps a misconfigured COOKIE_PATH > > Does "not configured" count as misconfigured? :-) > Sheesh, do I ever feel stoopid. No, I was just wondering whether you had set some weird setting -- the defaults work fine for most. > I just checked the site cookies with WebDeveloper Toolbar and the > sessionid Host looks perfectly valid: > > So, that doesn't seem to be a problem ... is it? > > So, I'm back to ... what's with all of the rapid session creation? Well if it's creating the cookie fine, then I'm not really sure! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
plz closed
Dear Sir, I want closed your side plz except. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
join now
I want to join your group can you except me waiting your reply. Regard. Sankar. --~--~-~--~~~---~--~~ 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 on MediaTemple (dv) howto?
That is to say, the home directory of the user 'django' is '/home/ django'... On Jan 5, 1:09 am, Josh Ourisman <[EMAIL PROTECTED]> wrote: > Ok, I'm still having problems. :( > > As near as I can tell Django is installed properly, and my project is > configured correctly (I'm able to run manage.py syncdb and it actually > does create the proper tables in the database). I created a separate > user called django with a home directory of /home/directory to house > my Django projects. However, when I try and preview the domain through > plesk (the domain name still points to my old server while I try and > get this working) I just get normal test files that plesk installs. > > Here is the exact text of my vhosts.conf file, the name of my project > is 'dydx': > SetHandler python-program > AddHandler mod_python.py > > PythonPath "['/home/django'] + sys.path" > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE dydx.settings > PythonDebug Off > > > SetHandler None > > > Is there something I'm missing? Is it just that it doesn't work if I > use plesk's preview function and will work when I actually switch over > my DNS settings? > > On Jan 3, 6:42 pm, Katie Lohrenz <[EMAIL PROTECTED]> wrote: > > > myproject.settings is relative to your python path. > > > Look at this line: > > > PythonPath "['/path/to/django'] + sys.path" > > > /path/to/django is the (hypothetical) folder where all my django > > projects live. So inside it is a folder called myproject which has > > settings.py in it. > > > (And if you have more questions and would prefer to email me directly, > > feel free. I'm happy to help.) > > > On Jan 3, 4:27 pm, Josh Ourisman <[EMAIL PROTECTED]> wrote: > > > > Perfect, exactly what I've been looking for. Thanks! > > > > One other question that I haven't really been able to find a straight > > > answer on: what am I actually supposed to replace myproject.settings > > > with? Some people seem to be saying that it needs to be the path to > > > the settings.py file for my project, is that the case? What should the > > > path be relative to? --~--~-~--~~~---~--~~ 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 on MediaTemple (dv) howto?
Ok, I'm still having problems. :( As near as I can tell Django is installed properly, and my project is configured correctly (I'm able to run manage.py syncdb and it actually does create the proper tables in the database). I created a separate user called django with a home directory of /home/directory to house my Django projects. However, when I try and preview the domain through plesk (the domain name still points to my old server while I try and get this working) I just get normal test files that plesk installs. Here is the exact text of my vhosts.conf file, the name of my project is 'dydx': SetHandler python-program AddHandler mod_python.py PythonPath "['/home/django'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE dydx.settings PythonDebug Off SetHandler None Is there something I'm missing? Is it just that it doesn't work if I use plesk's preview function and will work when I actually switch over my DNS settings? On Jan 3, 6:42 pm, Katie Lohrenz <[EMAIL PROTECTED]> wrote: > myproject.settings is relative to your python path. > > Look at this line: > > PythonPath "['/path/to/django'] + sys.path" > > /path/to/django is the (hypothetical) folder where all my django > projects live. So inside it is a folder called myproject which has > settings.py in it. > > (And if you have more questions and would prefer to email me directly, > feel free. I'm happy to help.) > > On Jan 3, 4:27 pm, Josh Ourisman <[EMAIL PROTECTED]> wrote: > > > Perfect, exactly what I've been looking for. Thanks! > > > One other question that I haven't really been able to find a straight > > answer on: what am I actually supposed to replace myproject.settings > > with? Some people seem to be saying that it needs to be the path to > > the settings.py file for my project, is that the case? What should the > > path be relative to? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Context Processors: {{ MEDIA_URL }} not available in templates
> Well, if I can't get this working I suppose I can just stuff the > settings.MEDIA_URL variable into each template render by placing it > into the render dictionary myself each time. Nah, don't do that. I think your problem is that you are running 0.96 instead of trunk. I am on trunk/6688 and there is, in fact, a media processor and I'm even using it in a production site. I noticed you started off by saying: >Hi, I read that if I install a context processor, MEDIA_URL will >automatically be available to my templates. So the question is: where did you read that? Was it the online tutorial? Did it say 0.96 or SVN trunk? IMWTK! (Inquiring Minds Want To Know!) --~--~-~--~~~---~--~~ 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: elif or elseif template tag
> You would have to write your own version of the "ifequal" tag, since > that is what is responsible for parsing the whole > "ifequal"..."else"..."endif" block in these cases, so you'd need to > teach it about "elif" as well. Copy the existing code in > django/template/defaulttags.py if you want to do this. > > Malcolm I'm trying to wrap my head around adding elif into the ifequal tag, but I'm not sure if I'm doing it right (not being a python programmer and all...). Here's what I have right now, but I'm not sure how to tell it to parse more bits when it encounters the elif portion of the tag. def do_ifequal(parser, token, negate): bits = list(token.split_contents()) if len(bits) != 3: raise TemplateSyntaxError, "%r takes two arguments" % bits[0] end_tag = 'end' + bits[0] nodelist_true = parser.parse(('elif','else', end_tag)) token = parser.next_token() if token.contents == 'elif': nodelist_false = parser.parse(('elif','else',end_tag)) parser.delete_first_token() elif token.contents == 'else': nodelist_false = parser.parse((end_tag,)) parser.delete_first_token() else: nodelist_false = NodeList() return IfEqualNode(bits[1], bits[2], nodelist_true, nodelist_false, negate) --~--~-~--~~~---~--~~ 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: elif or elseif template tag
> You would have to write your own version of the "ifequal" tag, since > that is what is responsible for parsing the whole > "ifequal"..."else"..."endif" block in these cases, so you'd need to > teach it about "elif" as well. Copy the existing code in > django/template/defaulttags.py if you want to do this. > > Malcolm I'm trying to wrap my head around adding elif into the ifequal tag, but I'm not sure if I'm doing it right (not being a python programmer and all...). Here's what I have right now, but I'm not sure how to tell it to parse more bits when it encounters the elif portion of the tag. def do_ifequal(parser, token, negate): bits = list(token.split_contents()) if len(bits) != 3: raise TemplateSyntaxError, "%r takes two arguments" % bits[0] end_tag = 'end' + bits[0] nodelist_true = parser.parse(('elif','else', end_tag)) token = parser.next_token() if token.contents == 'elif': nodelist_false = parser.parse(('elif','else',end_tag)) parser.delete_first_token() elif token.contents == 'else': nodelist_false = parser.parse((end_tag,)) parser.delete_first_token() else: nodelist_false = NodeList() return IfEqualNode(bits[1], bits[2], nodelist_true, nodelist_false, negate) --~--~-~--~~~---~--~~ 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: elif or elseif template tag
> > You would have to write your own version of the "ifequal" tag, since > that is what is responsible for parsing the whole > "ifequal"..."else"..."endif" block in these cases, so you'd need to > teach it about "elif" as well. Copy the existing code in > django/template/defaulttags.py if you want to do this. > > Malcolm > > -- > The only substitute for good manners is fast > reflexes.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Experimental port of Django to Java
This is pretty amazing. Thank you for doing it! I'd love to be able to expand/hack on it. Just out of curiousity, how much time went into getting it to this point? -- --Leo On Jan 4, 1:12 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Why, I have no idea just got the urge to see if I could. Probably > stems more from a basic dislike of the Java options (Struts, Spring, > etc) but that is for another list. I guess I got bored of real work > so I dreamed up something else to do over the new years holiday. > > And yes for some clients I am tied to Java, for others I have been > using Django. Most of my Java clients are AS400 shops with legacy > databases, not something Django would like very much (composite keys > and all) even if I could figure out how to connect to the AS400 > database from Python. > > John > > On Jan 4, 3:54 pm, "Jon Atkinson" <[EMAIL PROTECTED]> wrote: > > > On 1/4/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > For some unknown reason I have created a Java port of parts of > > > Django, > > > I'd love to know a little more about *why* you did this. Are you tied > > to Java as a platform? I think it's an impressive achievement, but are > > you so stuck with Java that a switch to Python would be impossible? > > > --Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Context Processors: {{ MEDIA_URL }} not available in templates
On Jan 4, 4:19 pm, Peter Rowell <[EMAIL PROTECTED]> wrote: > > (3) Imported the RequestContext object in my views.py file: > > > from django.template import Template, Context, RequestContext > > I know this is a silly question, but did you *use* RequestContext, or > just import it? > > E.g. > return render_to_response('base.html', > RequestContext(request, {'stuff': stuff, } ) ) Thanks for the fast response, no I was not actually using it, I thought it got added automatically to any template being rendered. But after I do that: return render_to_response('index.html', renderParams, RequestContext(request)) I'm now getting the following error: Exception Type: ImproperlyConfigured Exception Value:Module "django.core.context_processors" does not define a "media" callable request processor Exception Location: /Library/Frameworks/Python.framework/Versions/2.5/ lib/python2.5/site-packages/django/template/context.py in get_standard_processors, line 81 Looking at the source code, it certainly looks like it DOES provide a 'media' function (I have 0.96 installed): def media(request): """ Adds media-related context variables to the context. """ return {'MEDIA_URL': settings.MEDIA_URL} Well, if I can't get this working I suppose I can just stuff the settings.MEDIA_URL variable into each template render by placing it into the render dictionary myself each time, or worst-case I can hard- code the media paths, but I'd still like to know why it's not working. I've had nothing but headaches with MEDIA_URL and associated settings, I tried for a long time to get static media serving on the dev server, but it never worked. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
fixtures using django contrib user
I have a few models that use django.contrib.auth.models.User Those models cannot be dumped as a fixture. Is this expected behavior? I searched for quite a while, but could not find any information about it. The error I get when trying to dump the fixture is: Error: Unable to serialize database: User matching query does not exist. If I comment out the line in my model that references the User model via a foreignkey, the fixture data dumps out just fine. --~--~-~--~~~---~--~~ 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: SESSION_SAVE_EVERY_REQUEST creates new session?
Hi Peter, I've been delving around in that code recently. The only thing I can think of is that your cookies aren't getting received (perhaps a misconfigured COOKIE_PATH or one of the other related settings?) so a new session is getting created and sent each request. As a side note, I've been thinking that the SAVE_EVERY_REQUEST method could be optimized to only save sessions which have been modified or are not empty. Not that it will fix your problem, just wanted to mention it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: elif or elseif template tag
On Fri, 2008-01-04 at 16:48 -0800, Steve wrote: > It's possible that maybe I've missed an obvious way of performing this > feat, and if that's the case I'll apologize early for my naivety. > > I'm working on some templates that are drawing a form, and there are a > couple of special cases that I want to account for, but I don't want > to have to have ifequal after ifequal statements nested inside of each > other, just to cover the special cases that I'm wanting to cover. > > Is there possibly an elif or elseif template tag? If not, how hard > would it be to make it? I'm not much of a Python programmer, though I > know enough to be dangerous. You would have to write your own version of the "ifequal" tag, since that is what is responsible for parsing the whole "ifequal"..."else"..."endif" block in these cases, so you'd need to teach it about "elif" as well. Copy the existing code in django/template/defaulttags.py if you want to do this. Malcolm -- The only substitute for good manners is fast reflexes. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Presence of ForeignKey in list_display kills admin list view
On Jan 3, 11:58 pm, Lee Hinde <[EMAIL PROTECTED]> wrote: > I have two models, presented below: > > class Winery(models.Model): > """(Winery description)""" > name = models.CharField(blank=False, maxlength=100, > db_index=True) > winery_id = models.CharField(blank=True, maxlength=100) > corporate_name = models.CharField(blank=True, maxlength=100) > address = models.CharField(blank=True, maxlength=100) > city = models.CharField(blank=True, maxlength=100) > state = models.CharField(blank=True, maxlength=10) > zipcode = models.CharField(blank=True, maxlength=11) > > class Admin: > list_display = ('name',) > search_fields = ('name',) > class Meta: > ordering = ('name',) > verbose_name_plural = "Wineries" > > def __str__(self): > return self.name > > def __unicode__(self): > return self.name > > class Wine(models.Model): > """The Wine table""" > class_number = models.CharField(blank=True, maxlength=100) > wine_name = models.CharField(blank=True, maxlength=100, > db_index=True) > appellation = models.CharField(blank=True, maxlength=100) > appellation_id = models.ForeignKey(Appellation, > verbose_name="Appellation") > vintage_date = models.CharField(blank=True, maxlength=10) > estate_bottled = models.NullBooleanField() > vineyard_designation = models.NullBooleanField(default=False) > vineyard_name = models.CharField(blank=True, maxlength=100) > varietal = models.CharField(blank=True, maxlength=100) > varietal_id = models.ForeignKey(Varietal, verbose_name="Varietal") > gallons_produced = models.PositiveIntegerField(blank=True, > null=True) > residual_sugar = models.DecimalField(max_digits=2, > decimal_places=2) > retail_price = models.DecimalField(max_digits=5, decimal_places=2) > bottle_size = models.CharField(blank=True, maxlength=100) > winery_id = models.ForeignKey(Winery, verbose_name="Winery") > > class Meta: > ordering = ('winery_id','appellation_id','class_name') > > class Admin: > ordering = ('winery_id','appellation_id','class_name') > list_display = > ('winery_id','wine_name','class_name','vintage_date') > list_filter = ("award_medal",) > search_fields = ('^winery_id__name',) > > def __unicode__(self): > return self.wine_name > > In Admin, no data is shown when I list Wines. If I remove the > "winery_id" reference in Wine's list_display, I get a complaint about > the Meta classes' ordering line. ((1054, "Unknown column > 'winecomp_winery.name' in 'order clause'")) > > If I comment out the Meta class (and remove the winery_id field), I > get a list. But without the Winery field. > > If I comment out the Meta class and leave in the winery_id field, I > get a list, but with no data. > > Django version 0.97-pre-SVN-unknown, using settings > 'winesite.settings' > > I started playing around with this app as a learning tool last summer, > it's evolved and I picked it up again as I gave myself the Django book > as a Christmas present. It seems like this was working before. But it > was several months ago and I'm old and foggy. > > The book says that the __str()__ of the related object is used if a > foreign key is used in a list_display. When I came back to the > project, it seemed like in some situations (that I can't recall right > now) __unicode()__ was preferred. That's why I have both. > > Any guidance would be appreciated. I've googled the group and the > internet without much recent commentary on this, so I'm hoping there's > a typo someone will see. I got some help on #django today that helped with this. 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 -~--~~~~--~~--~--~---
elif or elseif template tag
It's possible that maybe I've missed an obvious way of performing this feat, and if that's the case I'll apologize early for my naivety. I'm working on some templates that are drawing a form, and there are a couple of special cases that I want to account for, but I don't want to have to have ifequal after ifequal statements nested inside of each other, just to cover the special cases that I'm wanting to cover. Is there possibly an elif or elseif template tag? If not, how hard would it be to make it? I'm not much of a Python programmer, though I know enough to be dangerous. Example: {% for field in form %} {% ifequal field.name "city" %} {{ field.label| title }}{{ field }} {% elif field.name "state" %} ... {% else %} more form markup {% endif %} {% endfor %} --~--~-~--~~~---~--~~ 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: testing and request.META['REMOTE_ADDR']
On Fri, 2008-01-04 at 14:30 -0800, Thomas wrote: > I am testing django.contrib.comments with django.test.client that does > not provide request.META['REMOTE_ADDR'] and therefore dies at > http://code.djangoproject.com/browser/django/trunk/django/contrib/comments/views/comments.py#L252 > > There has been a ticked #407 but that did not change all > request.META['REMOTE_ADDR'] to request.META.get() > > Question: what is the best way to fix this? Work out which standards are relevant. If REMOTE_ADDR *must* be supplied by all web servers, then the test client is in error. If not, any code that cannot handle it being missing is in error. Regards, Malcolm -- Experience is something you don't get until just after you need it. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms-admin, modelform: ModelForm(Instance()) or ModelForm(instance=Instance())?
On Fri, 2008-01-04 at 09:51 -0800, Michel Thadeu Sabchuk wrote: > Hi guys, > > I´m using the newforms-admin branch and I have one thing to note about > modelforms. I used a revision (I can´t tell what) and to instanciate > the form I need to do: > > edit_form = ModelForm(request.POST, instance=instance_object) > create_form = ModelForm(request.POST) > > Now the revision changed to: > > edit_form = ModelForm(instance_object, request.POST) > create_form = ModelForm(Instance(), request.POST) > > I don´t want to be the boring but, why I need to specify instance as > the first argument? Isn´t the form related to the model? I liked the > older method, so I can set the instance to none and spend less > lines ;) Sounds like your checkout is a little behind the tip of that branch. As of [6955] (the latest newforms-admin commit), the branch includes changes from trunk up to [6952]. That means it includes changeset [6915], which moves the instance argument out of the first position in ModelForms. Short version: if you're using newforms-admin checkout prior to December 4, update so that you have the right ModelForms syntax. Regards, Malcolm -- Experience is something you don't get until just after you need it. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Make Django admin edit return to custom page?
On Fri, 2008-01-04 at 06:04 -0800, Ulf Kronman wrote: [...] > This solution may not be rock-solid for the future, since it involves > a bit of tampering with the URL to the admin list, Barring any completely hidden and totally showstopping bug, you can count on admin URLs being stable. "Cool URIs don't change" and all that. Because somebody may have bookmarked a link to such a URL, if we were to change it, we would be hurting users (not just application developers, but their users -- the people sitting in front of browsers we have no way of contacting). So you can be fairly comfortable with relying on a stable URL structure. Regards, Malcolm -- I've got a mind like a... a... what's that thing called? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Context Processors: {{ MEDIA_URL }} not available in templates
> (3) Imported the RequestContext object in my views.py file: > > from django.template import Template, Context, RequestContext I know this is a silly question, but did you *use* RequestContext, or just import it? E.g. return render_to_response('base.html', RequestContext(request, {'stuff': stuff, } ) ) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Context Processors: {{ MEDIA_URL }} not available in templates
Hi, I read that if I install a context processor, MEDIA_URL will automatically be available to my templates. However, it's not. Here's what I've done: (1) Added the image files to my ftp server here: myserver.com/sites/myapp/images/ (2) Added this to settings.py (TEMPLATE_CONTEXT_PROCESSORS was not already defined): MEDIA_URL = 'http://mysite.com/sites/myapp/' TEMPLATE_CONTEXT_PROCESSORS = ('django.core.context_processors.auth', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media' ) (3) Imported the RequestContext object in my views.py file: from django.template import Template, Context, RequestContext (4) In my HTML template, I have this line: But when I run it, the image does not appear, and the page source looks like this (in my settings.py file I have TEMPLATE_STRING_IF_INVALID = ''): However, if I hard-code the direct path like this, the image appears as it should, so I know the image is OK: It's the same way with javascript and CSS files too. What am I doing wrong? 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: Running a Django project off my iDisk
Nevermind, it was because of some funky characters in a directory name On Jan 4, 6:17 pm, Josh Ourisman <[EMAIL PROTECTED]> wrote: > Ok, this is probably a bit odd. > > I'm working in OS X (obviously). I generally keep my work files stored > on my iDisk because this makes it incredibly easy to 1) keep > everything backed up, and 2) keep all my files up to date on multiple > computers. I use the iDisk sync feature so that everything is stored > locally on my hard drive and I don't actually need to be online to get > access to it I'm currently working on a Django site, and have it set > up to run locally with a SQLite backend so I can easily work on it > without internet access. The project and apps are stored on my iDisk, > and all is well for the most part, I can run the test server and play > with the admin interface to my heart's content. However I'm having > problems when I try to load templates: I consistently get a template > does not exist error. In my settings.py file I set my TEMPLATE_DIRS to > '/Volumes/iDisk.username/Documents/some/directories/djangoproject/ > templates', which is what a 'pwd' returns when I'm in the templates > directory in the terminal. > > As far as I can tell all of my settings are correct (based on my > settings for other Django apps that I have running online), so all I > can think of is that there's some issue with my TEMPLATE_DIRS path. > Does anyone have any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
SESSION_SAVE_EVERY_REQUEST creates new session?
It appears that setting SESSION_SAVE_EVERY_REQUEST = True is causing a new session to be created on each page access. Background: I was doing some fiddling with a 'session browser' so that we can get an idea of how people are dealing with our new site. I set this config value because I wanted the timestamp to represent the most recent page fetch. (In another thread someone had a method for caching a dict of user/timestamp, but it would seem like this method should be quite usable.) After taking a week off from working on this, I couldn't figure out why formatting the output of Session.objects.all() was taking so long. I popped into phpMyAdmin and was amazed to find that we have over 290,000 sessions. This site normally gets about 4000 unique visitors a day, so this number was over the Moon. I limited my view to the most recent 200 sessions (so it would not crash) and was surprised to see that I had many sessions for a single user when I would have expected only one. For example, in less than a minute this user had at least 8 sessions created for her. 2008-01-04 13:44:59 kirsten d01ac014bdd9f4ec8eb9cd8e2186f6d8 2008-01-04 13:44:58 kirsten 0c06dc7c91e07b114ef1c4e7094f5de0 2008-01-04 13:44:48 kirsten db1997ac362a61355f6112d3ca145901 2008-01-04 13:44:44 kirsten be54f80dfe008b390c2afeb3eb9bd8c7 2008-01-04 13:44:36 kirsten a21147e03b2b73fc9112c4ba3fc4b1f5 2008-01-04 13:44:27 kirsten e50affc7642530c038b6331855fea006 2008-01-04 13:44:18 kirsten c95ba03513b916c47e516cb8ad483236 In phpMyAdmin I kept refreshing the Structure window on django_session and saw the number of rows going up by dozens at a time. Setting it to False + restart caused everything to calm down. I set it to True and sessions were again being created on each page. Set to False, and things were normal. I looked at contrib/sessions/*.py and the only place it referenced this value (middleware.py:process_response) looked completely reasonable. Does this ring a bell for anyone? I am running trunk/6688 on an RHEL 4 box, Python 2.5.1, Apache 2.0.52, mod_python 3.3.1. TIA, Peter --~--~-~--~~~---~--~~ 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 a Django project off my iDisk
Ok, this is probably a bit odd. I'm working in OS X (obviously). I generally keep my work files stored on my iDisk because this makes it incredibly easy to 1) keep everything backed up, and 2) keep all my files up to date on multiple computers. I use the iDisk sync feature so that everything is stored locally on my hard drive and I don't actually need to be online to get access to it I'm currently working on a Django site, and have it set up to run locally with a SQLite backend so I can easily work on it without internet access. The project and apps are stored on my iDisk, and all is well for the most part, I can run the test server and play with the admin interface to my heart's content. However I'm having problems when I try to load templates: I consistently get a template does not exist error. In my settings.py file I set my TEMPLATE_DIRS to '/Volumes/iDisk.username/Documents/some/directories/djangoproject/ templates', which is what a 'pwd' returns when I'm in the templates directory in the terminal. As far as I can tell all of my settings are correct (based on my settings for other Django apps that I have running online), so all I can think of is that there's some issue with my TEMPLATE_DIRS path. Does anyone have any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting specific related objects via URL variable
How about a template tag? Pass it the image name and have it set a var to the correct image. On Jan 4, 3:29 pm, Emil <[EMAIL PROTECTED]> wrote: > Thanks Alex, I'm not quite sure what you mean, but I actually gave it > another go and got something working. I'm passing the value from the > image_detail GET-variable ("products/productname/?image_detail=1") > along with the extra_context to the variable, and looping over the > image set comparing the value to the id of the image. Feels a bit > inefficient though: I'm not sure if it's better to try and do that in > the view? On the other hand, if i do it in the view, the queryset is > on all products, (even if the generic view drills it down to one > product in the end) so how do I then "attach" each main image to each > product so to speak? > > //emil > > On 4 Jan, 21:59, Alex Koshelev <[EMAIL PROTECTED]> wrote: > > > Select needed image object from base and pass it explicitly to > > template context > > > On 4 янв, 23:43, Emil <[EMAIL PROTECTED]> wrote: > > > > Greetings, fellow Djangonauts. > > > > Some background to my question: > > > I'm building a site where I have Products that each can have one or > > > more Images (related via a Product f.k on the Image side). The product > > > images are default ordered by a SmallIntegerField with a priority > > > rating (of 1-5, 5 being highest). When I show a single product, I use > > > a generic view (object_detail), through a wrapper function to be able > > > to filter based on category in the URL among other things. > > > > Printing out all product images for a product should be fairly easy - > > > just get the list of images via product.images_set.all. One image is > > > the "main" image for the product - it's presented bigger, the other > > > ones are smaller thumbnails. Default, the main image is the one with > > > highest priority, thus the first one, no problem there. > > > > Now to the problem: When the user clicks any other image on the > > > product page, the page should reload but with the clicked image as > > > main/bigger image instead. Naturally, this should be through some > > > parameter in the URL (either like "products/productname/image1/" or > > > "products/productname?image=1", not sure which is cleanest/easiest). > > > How do I get to filtering out, and assigning a template variable for, > > > the main image from that parameter? > > > > It feels like there should be some fairly simple solution here, but I > > > can't seem to come up with anything... > > > > //emil --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
testing and request.META['REMOTE_ADDR']
I am testing django.contrib.comments with django.test.client that does not provide request.META['REMOTE_ADDR'] and therefore dies at http://code.djangoproject.com/browser/django/trunk/django/contrib/comments/views/comments.py#L252 There has been a ticked #407 but that did not change all request.META['REMOTE_ADDR'] to request.META.get() Question: what is the best way to fix this? Thomas --~--~-~--~~~---~--~~ 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... False promises?
> Are you sure? I think that the online docs are actually correct here... Yes, i am sure. If you try to set CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True, you will notice that the version on django book is the correct one. From Django Documentation: Put the CacheMiddleware before any other middleware that might add something to the Vary header (response middleware is applied in reverse order). The following middleware modules do so: -SessionMiddleware adds Cookie -GZipMiddleware adds Accept-Encoding -LocaleMiddleware adds Accept-Language More from the docs ... Note that if you use CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you should make sure you've activated AuthenticationMiddleware and that AuthenticationMiddleware appears before CacheMiddleware in your MIDDLEWARE_CLASSES. So following the Django Documentation it is NOT possible to set the order as required, AuthenticationMiddleware before CacheMiddleware and CacheMiddleware before SessionMiddleware, since SessionMiddleware is needed before AuthenticationMiddleware. AuthenticationMiddleware CacheMiddleware SessionMiddleware Following Django Book this is possible: (Put the CacheMiddleware ***after*** any middlewares that might add something to the Vary header. (SESSION MIDDLEWARE is one of then) SessionMiddleware AuthenticationMiddleware CacheMiddleware Tested with memcache and working this way. Regards, Marcelo - Original Message - From: "SmileyChris" <[EMAIL PROTECTED]> To: "Django users"Sent: Friday, January 04, 2008 6:15 PM Subject: Re: Django... False promises? > > On Jan 5, 4:09 am, "Marcelo Sanches" <[EMAIL PROTECTED]> wrote: > > I agree ! After trying to configure the django cache system I notice that > > the online docs are wrong and the django book have the correct information > > about the order of MIDDLEWARE_CLASSES. > > > > ONLINE DOCS YOU WILL FIND: > > ... > > > > DJANGO BOOK YOU WILL FIND THE CORRECT INFORMATION > > ... > > Are you sure? I think that the online docs are actually correct here... > > > > -- > Esta mensagem foi verificada pelo sistema de antivírus e > acredita-se estar livre de perigo. > --~--~-~--~~~---~--~~ 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 specific related objects via URL variable
Thanks Alex, I'm not quite sure what you mean, but I actually gave it another go and got something working. I'm passing the value from the image_detail GET-variable ("products/productname/?image_detail=1") along with the extra_context to the variable, and looping over the image set comparing the value to the id of the image. Feels a bit inefficient though: I'm not sure if it's better to try and do that in the view? On the other hand, if i do it in the view, the queryset is on all products, (even if the generic view drills it down to one product in the end) so how do I then "attach" each main image to each product so to speak? //emil On 4 Jan, 21:59, Alex Koshelev <[EMAIL PROTECTED]> wrote: > Select needed image object from base and pass it explicitly to > template context > > On 4 янв, 23:43, Emil <[EMAIL PROTECTED]> wrote: > > > Greetings, fellow Djangonauts. > > > Some background to my question: > > I'm building a site where I have Products that each can have one or > > more Images (related via a Product f.k on the Image side). The product > > images are default ordered by a SmallIntegerField with a priority > > rating (of 1-5, 5 being highest). When I show a single product, I use > > a generic view (object_detail), through a wrapper function to be able > > to filter based on category in the URL among other things. > > > Printing out all product images for a product should be fairly easy - > > just get the list of images via product.images_set.all. One image is > > the "main" image for the product - it's presented bigger, the other > > ones are smaller thumbnails. Default, the main image is the one with > > highest priority, thus the first one, no problem there. > > > Now to the problem: When the user clicks any other image on the > > product page, the page should reload but with the clicked image as > > main/bigger image instead. Naturally, this should be through some > > parameter in the URL (either like "products/productname/image1/" or > > "products/productname?image=1", not sure which is cleanest/easiest). > > How do I get to filtering out, and assigning a template variable for, > > the main image from that parameter? > > > It feels like there should be some fairly simple solution here, but I > > can't seem to come up with anything... > > > //emil --~--~-~--~~~---~--~~ 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: Experimental port of Django to Java
Why, I have no idea just got the urge to see if I could. Probably stems more from a basic dislike of the Java options (Struts, Spring, etc) but that is for another list. I guess I got bored of real work so I dreamed up something else to do over the new years holiday. And yes for some clients I am tied to Java, for others I have been using Django. Most of my Java clients are AS400 shops with legacy databases, not something Django would like very much (composite keys and all) even if I could figure out how to connect to the AS400 database from Python. John On Jan 4, 3:54 pm, "Jon Atkinson" <[EMAIL PROTECTED]> wrote: > On 1/4/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > For some unknown reason I have created a Java port of parts of > > Django, > > I'd love to know a little more about *why* you did this. Are you tied > to Java as a platform? I think it's an impressive achievement, but are > you so stuck with Java that a switch to Python would be impossible? > > --Jon --~--~-~--~~~---~--~~ 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 specific related objects via URL variable
Select needed image object from base and pass it explicitly to template context On 4 янв, 23:43, Emil <[EMAIL PROTECTED]> wrote: > Greetings, fellow Djangonauts. > > Some background to my question: > I'm building a site where I have Products that each can have one or > more Images (related via a Product f.k on the Image side). The product > images are default ordered by a SmallIntegerField with a priority > rating (of 1-5, 5 being highest). When I show a single product, I use > a generic view (object_detail), through a wrapper function to be able > to filter based on category in the URL among other things. > > Printing out all product images for a product should be fairly easy - > just get the list of images via product.images_set.all. One image is > the "main" image for the product - it's presented bigger, the other > ones are smaller thumbnails. Default, the main image is the one with > highest priority, thus the first one, no problem there. > > Now to the problem: When the user clicks any other image on the > product page, the page should reload but with the clicked image as > main/bigger image instead. Naturally, this should be through some > parameter in the URL (either like "products/productname/image1/" or > "products/productname?image=1", not sure which is cleanest/easiest). > How do I get to filtering out, and assigning a template variable for, > the main image from that parameter? > > It feels like there should be some fairly simple solution here, but I > can't seem to come up with anything... > > //emil --~--~-~--~~~---~--~~ 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: Experimental port of Django to Java
On 1/4/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > For some unknown reason I have created a Java port of parts of > Django, I'd love to know a little more about *why* you did this. Are you tied to Java as a platform? I think it's an impressive achievement, but are you so stuck with Java that a switch to Python would be impossible? --Jon --~--~-~--~~~---~--~~ 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: full media_url in db
Thanks Marty, at least now I know why it's happening. :-) //emil On 4 Jan, 21:35, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Jan 4, 2008 3:23 PM, Emil <[EMAIL PROTECTED]> wrote: > > > > > Hi people, > > > I'm working on a project where I try to utilize the dumpdata and > > loaddata commands from manage.py to extract and load data, since I'm > > constantly moving stuff I'm entering into the db between local > > development server and test server. > > > However, I find myself consantly having to change the path to my > > images manually in the xml files, since the full path, including > > domain (like 'http://example.test/media/image.jpg'on the devel > > server, 'http://example.domain.com/media/image.jpg'on the testing > > server) gets stored in the db - or at least in the xml dump. Isn't the > > ImageField only supposed to store only the file path relative to media > > root? > > > Luckily, I don't have that many entries in the db at this time, and > > search & replace helps out, but still - I shouldn't be forced to > > change MEDIA_URL to only an absolute file path without the domain > > (like "/media/" instead of "http://example.com/media/;), right? > > This has been reported, and is being tracked as issue #5574. I looked > at it briefly during my work on updating FileField, but it looks more > like a question for serialization experts (of which I'm not one). The > short story is: yes, the database does store just the path *after* > MEDIA_ROOT, but the serializer prepends MEDIA_URL to it. > > If I had to hazard a guess, I'd wager that this was done in an attempt > to allow consumers of the serialized data to retrieve the actual files > themselves, using only the information provided in the serialized > output. But, as you and others have noticed, this approach causes > problems when using serialization as a means to transfer data from > database to database, without having to worry about the files > themselves. > > -Gul > > [1]http://code.djangoproject.com/ticket/5574 --~--~-~--~~~---~--~~ 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: Experimental port of Django to Java
> I have posted what I have so far on google code (http:// > code.google.com/p/javango) if anyone is interested. Interesting, for sure ... -steve --~--~-~--~~~---~--~~ 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 specific related objects via URL variable
Greetings, fellow Djangonauts. Some background to my question: I'm building a site where I have Products that each can have one or more Images (related via a Product f.k on the Image side). The product images are default ordered by a SmallIntegerField with a priority rating (of 1-5, 5 being highest). When I show a single product, I use a generic view (object_detail), through a wrapper function to be able to filter based on category in the URL among other things. Printing out all product images for a product should be fairly easy - just get the list of images via product.images_set.all. One image is the "main" image for the product - it's presented bigger, the other ones are smaller thumbnails. Default, the main image is the one with highest priority, thus the first one, no problem there. Now to the problem: When the user clicks any other image on the product page, the page should reload but with the clicked image as main/bigger image instead. Naturally, this should be through some parameter in the URL (either like "products/productname/image1/" or "products/productname?image=1", not sure which is cleanest/easiest). How do I get to filtering out, and assigning a template variable for, the main image from that parameter? It feels like there should be some fairly simple solution here, but I can't seem to come up with anything... //emil --~--~-~--~~~---~--~~ 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: full media_url in db
On Jan 4, 2008 3:23 PM, Emil <[EMAIL PROTECTED]> wrote: > Hi people, > > I'm working on a project where I try to utilize the dumpdata and > loaddata commands from manage.py to extract and load data, since I'm > constantly moving stuff I'm entering into the db between local > development server and test server. > > However, I find myself consantly having to change the path to my > images manually in the xml files, since the full path, including > domain (like 'http://example.test/media/image.jpg' on the devel > server, 'http://example.domain.com/media/image.jpg' on the testing > server) gets stored in the db - or at least in the xml dump. Isn't the > ImageField only supposed to store only the file path relative to media > root? > > Luckily, I don't have that many entries in the db at this time, and > search & replace helps out, but still - I shouldn't be forced to > change MEDIA_URL to only an absolute file path without the domain > (like "/media/" instead of "http://example.com/media/;), right? This has been reported, and is being tracked as issue #5574. I looked at it briefly during my work on updating FileField, but it looks more like a question for serialization experts (of which I'm not one). The short story is: yes, the database does store just the path *after* MEDIA_ROOT, but the serializer prepends MEDIA_URL to it. If I had to hazard a guess, I'd wager that this was done in an attempt to allow consumers of the serialized data to retrieve the actual files themselves, using only the information provided in the serialized output. But, as you and others have noticed, this approach causes problems when using serialization as a means to transfer data from database to database, without having to worry about the files themselves. -Gul [1] http://code.djangoproject.com/ticket/5574 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Experimental port of Django to Java
For some unknown reason I have created a Java port of parts of Django, this is not using Jython but instead native Java code using the same basic syntax (well as close as Java allows). So far it is pretty interesting and some basic functionality is there (url mapping, newforms, etc.). I choose to use Hibernate and Freemarker for the Model and Template but these could be easily switched out. I have posted what I have so far on google code (http:// code.google.com/p/javango) if anyone is interested. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
full media_url in db
Hi people, I'm working on a project where I try to utilize the dumpdata and loaddata commands from manage.py to extract and load data, since I'm constantly moving stuff I'm entering into the db between local development server and test server. However, I find myself consantly having to change the path to my images manually in the xml files, since the full path, including domain (like 'http://example.test/media/image.jpg' on the devel server, 'http://example.domain.com/media/image.jpg' on the testing server) gets stored in the db - or at least in the xml dump. Isn't the ImageField only supposed to store only the file path relative to media root? Luckily, I don't have that many entries in the db at this time, and search & replace helps out, but still - I shouldn't be forced to change MEDIA_URL to only an absolute file path without the domain (like "/media/" instead of "http://example.com/media/;), right? /emil --~--~-~--~~~---~--~~ 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... False promises?
On Jan 5, 4:09 am, "Marcelo Sanches" <[EMAIL PROTECTED]> wrote: > I agree ! After trying to configure the django cache system I notice that > the online docs are wrong and the django book have the correct information > about the order of MIDDLEWARE_CLASSES. > > ONLINE DOCS YOU WILL FIND: > ... > > DJANGO BOOK YOU WILL FIND THE CORRECT INFORMATION > ... Are you sure? I think that the online docs are actually correct here... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Vote For Milano Candidateship for Expo 2015 Milano's
Last 90 days !!! Vote for Milano Please !!! *www.infoexpo2015.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 -~--~~~~--~~--~--~---
Vote For Milano Candidateship for Expo 2015 Milano's
Last 90 days !!! Vote for Milano Please !!! www.infoexpo2015.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 -~--~~~~--~~--~--~---
Vote For Milano Candidateship for Expo 2015 Milano's
Last 90 days !!! Vote for Milano Please !!! www.infoexpo2015.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: Ajax widget
Malcolm thanks for the reply, The javascript code above was working i was just unable to implement it into my template input box. I will try as you suggest. On Jan 4, 10:59 am, Empty <[EMAIL PROTECTED]> wrote: > So I'm really confused. You asked this same question on > 12/14:http://groups.google.com/group/django-users/browse_frm/thread/3415d1b... > > The original author of the Wiki page that you're referring to > responded. The code is a year and a half old and it seems to not be > working. But now you're asking the same question again. > > My recommendation is to take the ideas that are in that code and > rewrite them to make them work, if you're stuck on that dojo > implementation. If you're not up to that task then I suggest you look > at several on Django Snippets: > > Jquery:http://www.djangosnippets.org/snippets/269/ > YUI:http://www.djangosnippets.org/snippets/392/ > > If neither of those suit you, contact me directly and I can send you > some other code for a YUI implementation. > > Good luck. > > Michael Trier > blog.michaeltrier.com > > On Jan 4, 2008 9:52 AM, mike <[EMAIL PROTECTED]> wrote: > > > > > thx for the reply malcolm, I am trying to implement the Dojo select > > box into one of my forms, I followed the instructions and i know the > > javascript is working because I can get results by using the query > > string in my browser, > > >http://localhost:8000/myapp/reporter_lookup/?q= returns results, > > The last part involves using a template tag (formtags.py) that comes > > with the nong javascript package and loading it with a {% load > > formtags %} statement then using a > > > {% selectrow form.reporter "/myapp/reporter_lookup/?q=% > > {searchString}" > > "first_name" %} > > > statement to spit out the code for the input box. This template tag is > > no longer valid and cannot be imported so the select row statement > > will no longer work > > > On Jan 3, 8:36 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > > wrote: > > > > On Thu, 2008-01-03 at 15:25 -0800, mike wrote: > > > > I am trying to implement the Dojo Select box into a template I am > > > > creating. > > > > I have used the formtags that is inluded in the nongselect tar > > > > package. but It seems with the development version of django the > > > > import > > > > statements {% load formtags %} no longer work, I need a way to > > > > replace the > > > > You seem to be mixing up multiple problem reports here, but let's start > > > with this one. The "load" tag still works in Django. So you should try > > > to figure out why whatever third-party code you're using doesn't want to > > > load with the development version. > > > > Regards, > > > Malcolm > > > > -- > > > No one is listening until you make a > > > mistake.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Please Vote for Milano !!! Expo 2015
Last 90 days !!! Vote for Milano Please !!! www.infoexpo2015.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: Replicating admin behavior in front end
> If I am understanding your requirement correctly you are looking for > databrowse. I actually tried that, but it doesn't really have the structure I need, and too many options. Basically, I want what the admin interface has: a paginated grid with various fields across the top allowing you to sort forwards or backwards by any field, and a list of filters. Thanks, Rodriog --~--~-~--~~~---~--~~ 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: a Django TextMate theme
I wish someone would right something like this for gedit! On Jan 4, 6:46 am, Bert Heymans <[EMAIL PROTECTED]> wrote: > Hi, > > If you're a TextMate user this greenish Django syntax highlighting > theme could interest you:http://www.tmthemes.com/theme/Django/ > > The colours are easy on the eyes, and it feels like the djangoproject > site. I like it :) > > Cheers, > > Bert Heymans --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Basic Form Design Question: Pulling as much as possible from models
Thanks Malcom. That reassured me greatly. I didn't think of the clever id meta-fields to keep the form from modification, but I ended up getting a shell implementation with each question being it's own question form, and the overall quiz form just adds in as many question forms as there are questions in a quiz. I'll need to abstract out that functionality, just like you've suggested, but overall I think it will end up making sense in a month when I have to look at it again and I wonder who wrote this junk :) Thanks -Wes On Jan 3, 9:28 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-01-03 at 09:51 -0800, Wes Winham wrote: > > Hello, > > > I've got a bit of a design issue I'm trying to wrap my head around in > > order to do things the Django Way. > > > I'm attempting to creating a simple form that allows a user to take a > > multiple choice "quiz." Quiz is a model and it has a many to many with > > Questions which has a m2m with AnswerOptions. > > > I'm also not sure on which is the best way to get the questions and > > answers to the form and I'm not sure if I should be using one form, or > > a collection of forms. > > Hmm deja vu. I've been working on an almost analogous problem this > morning. I haven't coded it all up yet, but here's my current design > thinking... > > Each question is a form class. You can use the same form class each time > and part of its __init__ method will be to store the "question" string > (say in self.question). I will display 'N' of these on the page using > the "prefix" attribute to the form's __init__ method. So it will look > something like this: > > class QuestionForm(forms.Form): >answers = forms.ChoiceField(widget=forms.RadioSelect) > >def __init__(self, question, *args, **kwargs): > super(Question, self).__init__(*args, **kwargs) > self.question = question > self.fields['answers'].choices = ... > > I also have some meta-information in the form, such as a security hash > to make sure the form isn't modified, so that uses another form class > (which currently just contains the security hash, but I might need other > stuff when I flesh things out). > > Then my view will look like this: > > def quiz_view(request, quiz_id): >quiz = Quiz.objects.get(pk=quiz_id) >if request.method == 'POST': > # TODO ... >else: > meta = MetaForm(quiz) > q_forms = [] > for num, question in enumerate(quiz.questions.all()): > q_forms.append(QuestionForm(question, prefix=str(num))) >return render_to_response('quiz.html', {'meta': meta_form, > 'question_forms': q_forms}) > > and then, in the template: > > > {{ meta }} > {% for form in question_forms %} > {{ form.question }} > {{ form.as_p }} > {% endfor %} > > > > Obviously, a lot has been glossed over here (and there are no doubt some > bugs, as I haven't finalised the code in my case yet and I'm simplifying > a bunch of stuff). The point I want to make, though, is that I'm using > multiple form classes to render a *single* HTML form. I'm also shoving > things like the question text into the appropriate form so that I can > use that normally in the template (it's not a form field, so it wouldn't > normally be displayed). > > In the final analysis, I'll end up pulling out the form creation stuff > into a separate function, since I need to do it in multiple places (at > least, in both the POST and GET paths), but that's just normal stuff. > > Hopefully this gives you another idea to play with. I don't think any of > your options allowed for the possibility of multiple form classes, but > sometimes that can make things a lot easier. > > Regards, > Malcolm > > -- > Save the whales. Collect the whole set.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
newforms-admin, modelform: ModelForm(Instance()) or ModelForm(instance=Instance())?
Hi guys, I´m using the newforms-admin branch and I have one thing to note about modelforms. I used a revision (I can´t tell what) and to instanciate the form I need to do: edit_form = ModelForm(request.POST, instance=instance_object) create_form = ModelForm(request.POST) Now the revision changed to: edit_form = ModelForm(instance_object, request.POST) create_form = ModelForm(Instance(), request.POST) I don´t want to be the boring but, why I need to specify instance as the first argument? Isn´t the form related to the model? I liked the older method, so I can set the instance to none and spend less lines ;) Thanks and congratulations about the good work, Happy new year! --~--~-~--~~~---~--~~ 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: Ajax widget
So I'm really confused. You asked this same question on 12/14: http://groups.google.com/group/django-users/browse_frm/thread/3415d1b0bf21cf7a/c26747fb42ae3b24?lnk=st=AJAXWidgetComboBox#c26747fb42ae3b24 The original author of the Wiki page that you're referring to responded. The code is a year and a half old and it seems to not be working. But now you're asking the same question again. My recommendation is to take the ideas that are in that code and rewrite them to make them work, if you're stuck on that dojo implementation. If you're not up to that task then I suggest you look at several on Django Snippets: Jquery: http://www.djangosnippets.org/snippets/269/ YUI: http://www.djangosnippets.org/snippets/392/ If neither of those suit you, contact me directly and I can send you some other code for a YUI implementation. Good luck. Michael Trier blog.michaeltrier.com On Jan 4, 2008 9:52 AM, mike <[EMAIL PROTECTED]> wrote: > > thx for the reply malcolm, I am trying to implement the Dojo select > box into one of my forms, I followed the instructions and i know the > javascript is working because I can get results by using the query > string in my browser, > > http://localhost:8000/myapp/reporter_lookup/?q= returns results, > The last part involves using a template tag (formtags.py) that comes > with the nong javascript package and loading it with a {% load > formtags %} statement then using a > > {% selectrow form.reporter "/myapp/reporter_lookup/?q=% > {searchString}" > "first_name" %} > > statement to spit out the code for the input box. This template tag is > no longer valid and cannot be imported so the select row statement > will no longer work > > On Jan 3, 8:36 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > On Thu, 2008-01-03 at 15:25 -0800, mike wrote: > > > I am trying to implement the Dojo Select box into a template I am > > > creating. > > > I have used the formtags that is inluded in the nongselect tar > > > package. but It seems with the development version of django the > > > import > > > statements {% load formtags %} no longer work, I need a way to > > > replace the > > > > You seem to be mixing up multiple problem reports here, but let's start > > with this one. The "load" tag still works in Django. So you should try > > to figure out why whatever third-party code you're using doesn't want to > > load with the development version. > > > > Regards, > > Malcolm > > > > -- > > No one is listening until you make a > > mistake.http://www.pointy-stick.com/blog/ > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: a Django TextMate theme
> If you're a TextMate user this greenish Django syntax highlighting > theme could interest you:http://www.tmthemes.com/theme/Django/ But a bit odd that they use what looks like Ruby code to demo it! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting Access to form.data from a template
From the template you cannot call function with parameters so yoo must explicitly pass list to the template context. On 4 янв, 18:35, Paul Childs <[EMAIL PROTECTED]> wrote: > I am trying to get all the values from 'tail_number' in the form data > that gets passed to a template... > > form.data (printed in view before response is sent back): > 'tail_number': ['1', '2', '3'], ... }> > > I know that if I want access to the tail numbers in a view I can just > do this: > form.data.getlist('tail_number') > > I have tried a number of things like: > > {% form.tail_number %} > > and > > {% for tn in form.data.tail_number %} > {{ tn }} > {% endfor %} > > I always get '3' since I am just getting back a string. > > Does anyone know how to do this? > > 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 -~--~~~~--~~--~--~---
Getting Access to form.data from a template
I am trying to get all the values from 'tail_number' in the form data that gets passed to a template... form.data (printed in view before response is sent back): I know that if I want access to the tail numbers in a view I can just do this: form.data.getlist('tail_number') I have tried a number of things like: {% form.tail_number %} and {% for tn in form.data.tail_number %} {{ tn }} {% endfor %} I always get '3' since I am just getting back a string. Does anyone know how to do this? 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: Django... False promises?
> While I understand Ken's point about the book, in that it is no longer > the complete reference, I would *not* recommend just forgetting it. > Instead, use it as the valuable resource it is, and supplement your > nautical sojourn with reference to the online documentation as needed. > I, for one, have found the book to be extremely helpful overall, as > well as useful in helping to clarify parts of the online documentation > that are, perhaps, overly terse. I agree ! After trying to configure the django cache system I notice that the online docs are wrong and the django book have the correct information about the order of MIDDLEWARE_CLASSES. ONLINE DOCS YOU WILL FIND: If you use CacheMiddleware, it's important to put it in the right place within the MIDDLEWARE_CLASSES setting, because the cache middleware needs to know which headers by which to vary the cache storage. Middleware always adds something to the Vary response header when it can. Put the CacheMiddleware *before* any other middleware that might add something to the Vary header (response middleware is applied in reverse order). DJANGO BOOK YOU WILL FIND THE CORRECT INFORMATION If you use CacheMiddleware, it's important to put it in the right place within the MIDDLEWARE_CLASSES setting, because the cache middleware needs to know the headers by which to vary the cache storage. Put the CacheMiddleware ***after*** any middlewares that might add something to the Vary header. As you can see the djangobooks can help sometimes ;-) Regards, Marcelo Sanches --~--~-~--~~~---~--~~ 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: a Django TextMate theme
Cool Bert! Thanks for posting the link. Just tried out this theme and it's pretty nice. --gordy --~--~-~--~~~---~--~~ 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: Ajax widget
thx for the reply malcolm, I am trying to implement the Dojo select box into one of my forms, I followed the instructions and i know the javascript is working because I can get results by using the query string in my browser, http://localhost:8000/myapp/reporter_lookup/?q= returns results, The last part involves using a template tag (formtags.py) that comes with the nong javascript package and loading it with a {% load formtags %} statement then using a {% selectrow form.reporter "/myapp/reporter_lookup/?q=% {searchString}" "first_name" %} statement to spit out the code for the input box. This template tag is no longer valid and cannot be imported so the select row statement will no longer work On Jan 3, 8:36 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-01-03 at 15:25 -0800, mike wrote: > > I am trying to implement the Dojo Select box into a template I am > > creating. > > I have used the formtags that is inluded in the nongselect tar > > package. but It seems with the development version of django the > > import > > statements {% load formtags %} no longer work, I need a way to > > replace the > > You seem to be mixing up multiple problem reports here, but let's start > with this one. The "load" tag still works in Django. So you should try > to figure out why whatever third-party code you're using doesn't want to > load with the development version. > > Regards, > Malcolm > > -- > No one is listening until you make a mistake.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'WSGIRequest' object has no attribute 'user'
> > > On Dec 29 2007, 11:03 am, Alex Koshelev <[EMAIL PROTECTED]> wrote: > > > Is there 'django.contrib.auth.middleware.AuthenticationMiddleware' in > > > your MIDDLEWARE_CLASSES ? > > > No. Uncommenting > >'django.middleware.common.CommonMiddleware', > >'django.contrib.sessions.middleware.SessionMiddleware', > >'django.contrib.auth.middleware.AuthenticationMiddleware', > > in the distribution settings file was progress, resulting in a > > complaint about no login.html file. > > Going from the online version of the book, this was included in Step 3 here: > > http://www.djangobook.com/en/1.0/chapter06/ A search of chapter06 for MIDDLEWARE_CLASSES turns up only the following sentence: Also uncomment all the lines in the MIDDLEWARE_CLASSES setting tuple and delete the TEMPLATE_CONTEXT_PROCESSOR setting to allow it to take the default values again. >From this I concluded that other stuff didnt' need to be uncommented. I guess there's more there or elsewhere in the chapter than I understand. > ("Also uncomment all the lines in the MIDDLEWARE_CLASSES setting tuple...") > > Copying django/controb/admin/templates/admin/ to templates fixed that Both fixed, simplifying my setup and perhaps avoiding future trouble. Thanks. Rereading chapter06 on template directories I see that if I'd looked carefully at the commented-out lines in the initial settings file I could have deduced that uncommenting was the way to go. But a more straightforward reading of chapter06 could easily convince a newby that the directory copy I did instead as the way to go. > > and it works now. > > You should not have had to copy the admin templates anywhere, if the app > template loader (' > django.template.loaders.app_directories.load_template_source') is listed in > TEMPLATE_LOADERS. I thought it was there by default -- was it not in your > case? > > The generally excellent book indicates only a few of the changes > > > necessary to enable the admin system. > > Near as I can tell (working from the online version), the book does cover > all that needs to be done to enable admin. Nevertheless it seems like I've > seen a lot of people post here with trouble in this area, so I'm trying to > understand why. Perhaps step 3 in Chapter 6 should be more specific (list > exactly what should be in MIDDLEWARE_CLASSES), or split into two steps, > since it covers both ensuring that INSTALLED_APPS and MIDDLEWARE_CLASSES are > set properly. But even that wouldn't address whatever caused you to have to > copy the templates -- I don't understand what happened there. If chapter 6, and doubtless some others, were more explicit it would help. I've seen related comments on this site. In some cases (especially databases) there are system variations and changes that would make this degree of explicitness impractical and even counterproductive, but that doesn't seem to be the case in this chapter. Just trying to be helpful in convening the newbe perspective. The very good news for this newbe, anyway, is that this mailing list has been very responsible with helpful fixes. Chris --~--~-~--~~~---~--~~ 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... False promises?
On Jan 4, 2008 2:26 AM, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > forget running the debian version - it will always be way out of > date. Use the latest svn trunk as described in the tutorial. Also > forget about using the django book - use the latest docs on the web > site. The latest svn has too many goodies not present in .96 that it > is a shame not to use it. > While I understand Ken's point about the book, in that it is no longer the complete reference, I would *not* recommend just forgetting it. Instead, use it as the valuable resource it is, and supplement your nautical sojourn with reference to the online documentation as needed. I, for one, have found the book to be extremely helpful overall, as well as useful in helping to clarify parts of the online documentation that are, perhaps, overly terse. In addition, having things explained in a different way provides extra perspective. And, more to the point, you've already dropped the sawbucks on the book, right? Regards, ---Peter --~--~-~--~~~---~--~~ 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: Replicating admin behavior in front end
Hello, If I am understanding your requirement correctly you are looking for databrowse. Here it is what the documentation says about it: """ Databrowse is a Django application that lets you browse your data. As the Django admin dynamically creates an admin interface by introspecting your models, Databrowse dynamically creates a rich, browsable Web site by introspecting your models. """ You will find the documentation there: http://www.djangoproject.com/documentation/databrowse/ On 4 jan, 03:14, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote: > I am making a site that will handle and display a magazine article > database. I would like for front end (anonymous, not logged in) users > to be able to use some of the same functionality the admin interface > offers, namely the ability to sort by column (and reverse the order), > and filter by year, publication, etc. > Ideally, it should be as easy as adding the 'Admin' subclass is to a > class in models.py: > > class Admin: > list_display = ('titulo', 'revista', 'ano','visible') > list_filter = ('revista', 'pais','categoria','ano') > ordering = ('-ano',) > search_fields = ('titulo','autores','revista') > date_hierarchy = 'fecha_modificacion' > save_on_top = True > > Basically, I wonder if there's some read-only, public version of the > admin interface. > > Thanks, > > Rodrigo --~--~-~--~~~---~--~~ 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: Make Django admin edit return to custom page?
Hi all, I believe that I now have found a way to use the Django admin edit form, addressed from an external page, and then get returned back to the external page, rather than the default admin listing of records. I got a first good hint from Malcolm, and after a little tweaking of URL configs and a making custom "relay" view, I got it working. The general idea is to intercept the URL pointing at the admin listing of records and point to a custom view that directs the user back to the external page. But as I wanted the admin listing to be left untouched if you in fact arrived to the admin edit from the admin listing of records, I had to make a new URL pointing at it, to get there without disturbance of my own previous interception. This solution may not be rock-solid for the future, since it involves a bit of tampering with the URL to the admin list, but I want to post it here as a general idea, if someone else want to do something like this. Maybe you can give me some feedback and suggestions for improving the solution and/or making it more stable. This is how the code looks: The URLConf pointing at my relay view for external linking: -- from django.conf.urls.defaults import * urlpatterns = patterns('kvalster.publications.views', (r'^publication/(?P\d+)/admin_edit_relay', 'admin_edit_relay'), ) - The URLConf pointing at the relay for linking back: -- from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^admin/(publications)/(publication)/list$', 'django.contrib.admin.views.main.change_list'), (r'^admin/publications/publication/$', 'kvalster.publications.views.admin_edit_relay'), (r'^admin/', include('django.contrib.admin.urls')), ) - And the relay view itself: # == def admin_edit_relay(request, publication_id = ''): ''' Redirects to the admin edit page, and sets referrer as return address Redirects from the admin list, if user entered from a custom publication list ''' # Check if user is coming from outside of admin area if request.META['HTTP_REFERER'].find('admin') < 0 : # Set an URL to return to, after editing, as a session parameter request.session['return_to'] = request.META['HTTP_REFERER'] # Send user to admin edit page return HttpResponseRedirect('/admin/publications/publication/' + publication_id) # If user is coming from admin edit else: # If we have a custom return to address set if 'return_to' in request.session: str_return_to = request.session['return_to'] del request.session['return_to'] return HttpResponseRedirect(str_return_to) # Otherwise, return to ordinary admin list, with new custom URL else: return HttpResponseRedirect('/admin/publications/ publication/list') # == This is how it works from an external page: 1. Links from the external publication list points to my relay view (/ publications//admin_edit_relay). 2. The relay view sets a session parameter return_to that has the value of the referring URL and sends user on to admin edit page. 3. After editing and returning to the admin list of records my URLConf intercepts and sends user to the relay once again, this time using the session parameter to redirect the user to the initial page. This is how it works from internal admin edit: 1. When you enter the URL /admin/publications/publication/ the relay view intercepts, but as it sees that we are coming from the admin area and don't have the session parameter return_to set, it redirects to the URL /admin/publications/publication/list which works fine for sending directly to the admin list view as long as parameters with application and model name is sent with it in the URLConf: (r'^admin/(publications)/(publication)/list$', 'django.contrib.admin.views.main.change_list') 2. The same applies when you are returning from the admin edit page; the URL interception take an extra turn and makes the URL to /admin/ publications/publication/list , and thus stays at the admin listing. Hope this can be of any use to anyone. Regards, Ulf --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
online jobs
online jobs Why wasting time on internet?? Earn money online by doing data entry jobs! No experience needed!! Earn upto $250 by working 30 - 45 minutes per day! Just log on for more details www.onlinejobsoffer.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
online jobs
Why wasting time on internet?? Earn money online by doing data entry jobs! No experience needed!! Earn upto $250 by working 30 - 45 minutes per day! Just log on for more details www.onlinejobsoffer.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
online jobs
Why wasting time on internet?? Earn money online by doing data entry jobs! No experience needed!! Earn upto $250 by working 30 - 45 minutes per day! Just log on for more details www.onlinejobsoffer.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Counting and indexing objects
Thanks malcolm and tim, it does look like this is the only way to to do this. Tom On Jan 4, 2008 3:43 AM, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > On Fri, 2008-01-04 at 03:26 +, Tom Badran wrote: > > Sure malcolm. Essentially what i have is table of pictures defined by > > the following model (forgive typos, this is just extracted minus extra > > junk. Album class is a model with title fields etc.): > > > > class Picture(models.Model ): > > album = models.ForeignKey(Album) > > image = models.ImageField(upload_to="some_sane_directory") > > > > class Meta: > > ordering = ['id'] > > > > Then in my view i get a picture by id using: > > > > picture = get_object_or_404(Picture, id=id) // where id is the > > parameter to the view function > > > > And i want to be able to do something along the lines of (but with > > minimal amount of database stress): > > > > album_pictures = Picture.objects.filter(album=picture.album) > > total = album_pictures.count() > > index = album_pictures.index_of(picture) > > Okay, so you have to do this boring way and just pull things back into > Python structures. You want to used .index(), so convert from an > iterator to a list and you'll be able to do that: > >index = list(album_pictures).index(picture) > > This works because two Model instances compare as "equal" when their > primary keys are equal. So although album_pictures won't contain exactly > the same Python object (in the sense that id() will return different > values), it will contain something with the same pk as picture and that > is all that's required. > > Regards, > Malcolm > > > -- > He who laughs last thinks slowest. > http://www.pointy-stick.com/blog/ > > > > > -- Tom Badran http://badrunner.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
a Django TextMate theme
Hi, If you're a TextMate user this greenish Django syntax highlighting theme could interest you: http://www.tmthemes.com/theme/Django/ The colours are easy on the eyes, and it feels like the djangoproject site. I like it :) Cheers, Bert Heymans --~--~-~--~~~---~--~~ 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: passing data to view using httpresponseredirect
Ok, thanks. This explains what was going on. I did read that when I was first learning python, but I bet now, I won't forget about it anymore. I tried working around it, but that wasn't really working as the default value for the arguments get changed, also using messages = None wasn't an option as that would clear the message. I am not using sessions yet, but that will probably be a later add on and could also solve the problem. My solution for now is that I added a small class (global object) that contains the arrays errors and messages. It has addError, addMessage, getError and getMessage. I call the set methods whenever I want to add a notice to the user (error or message) and I call the get method in the render_to_response statements. The get methods return the arrays and clear them. def getErrors(self): retrieve = self.errors self.errors = [] return retrieve This allows me to add all errors and messages and then display them once. This is working for me and does the job for both httpresponseredirect and render_to_response. Basic setup: view(request): if(request.POST): #do stuff setErrors, setMessages httpresponseredirect else: rendertoresponse(... { 'error_list':getErrors, 'message_list':getMessages}) cheers, Maarten On Jan 3, 7:38 pm, Peter Rowell <[EMAIL PROTECTED]> wrote: > I didn't like my own explanation and did a little more searching. > > I just found a better description of this > athttp://requires-thinking.blogspot.com/2007/10/note-to-self-default-pa > > He points out that the 'def' is an executable statement and it's only > executed once. Therefore, the foo=[] only happens once. > > See the Python Language Reference for the authoritative description > http://docs.python.org/ref/function.html > > Note the subsection titled "Default parameter values are evaluated > when the function definition is executed." --~--~-~--~~~---~--~~ 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: Recommended tool for web load & stress testing
Interface is still a bit clunky - it's Swing after all, though not as bad as something like SoapUI (ugh). Stability is reasonable if don't mix java versions when doing distributed testing. On 1/3/08, mamcxyz <[EMAIL PROTECTED]> wrote: > > I remember use JMeter eons ago. I dislike the clunky interface and the > stability problems... > > Maybe is improved now? > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How especify the default form (html)
Ah, just to be clear: the request.POST.has_key('name') searches for the name of the tag and value is what you get when doing you_get = request.POST['name'] On Jan 4, 10:14 am, Maarten <[EMAIL PROTECTED]> wrote: > Hi, > > I have a view with that also requires 3 different actions (and 3 > forms). All 3 redirect to this same view once more. > > As Jeff said, be sure to get your tags fixed, but you can also add the > following to the submit buttons: > > > > > > > > > > > Then in your view put this: > > if(request.POST.has_key("search")): > # do search stuff > elif(request.POST.has_key("login")): > #do login stuff > elif(request.POST.has_key("values")): > # update values > else: > # no post, most likely first time you hit this page or after a > httpresponseredirect. > > This is usefull to identify what form has been used. Also, you may > want to consider using a GET for the search if it doesn't change > anything serverside. ==> if(request.GET) elif(request.POST) else: no > get nor post. > > There is also another way of doing this, which I also use (I think > I'll need to build up my consistency a bit), it's not as clean though. > > try: > request.POST['whatever_field_you_need'] ... > except KeyError, e: > > try: > request.POST['the_second_fields_you need] > except KeyError, e: > > etc... > Ok, now that I've written this bit down I'm actually going to change > this last thing in my program into the first I said. > > cheers, > Maarten > > On Jan 3, 9:45 pm, mamcxyz <[EMAIL PROTECTED]> wrote: > > > I don't know if this question is ignorance or what! > > > I have 3 forms in the same html. One is for search, another for singup > > y anoter for login. I'm in singup, enter the values and hit enter. But > > search is executed (so, I get a nasty: Invalid login). > > > I think this must be a obvious usability problem, but my googling not > > tell me nothing (except the trick of focus a textbox). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How especify the default form (html)
Hi, I have a view with that also requires 3 different actions (and 3 forms). All 3 redirect to this same view once more. As Jeff said, be sure to get your tags fixed, but you can also add the following to the submit buttons: Then in your view put this: if(request.POST.has_key("search")): # do search stuff elif(request.POST.has_key("login")): #do login stuff elif(request.POST.has_key("values")): # update values else: # no post, most likely first time you hit this page or after a httpresponseredirect. This is usefull to identify what form has been used. Also, you may want to consider using a GET for the search if it doesn't change anything serverside. ==> if(request.GET) elif(request.POST) else: no get nor post. There is also another way of doing this, which I also use (I think I'll need to build up my consistency a bit), it's not as clean though. try: request.POST['whatever_field_you_need'] ... except KeyError, e: try: request.POST['the_second_fields_you need] except KeyError, e: etc... Ok, now that I've written this bit down I'm actually going to change this last thing in my program into the first I said. cheers, Maarten On Jan 3, 9:45 pm, mamcxyz <[EMAIL PROTECTED]> wrote: > I don't know if this question is ignorance or what! > > I have 3 forms in the same html. One is for search, another for singup > y anoter for login. I'm in singup, enter the values and hit enter. But > search is executed (so, I get a nasty: Invalid login). > > I think this must be a obvious usability problem, but my googling not > tell me nothing (except the trick of focus a textbox). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing request object in templates
On Jan 4, 7:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-01-03 at 23:10 +0530, venkata subramanian wrote: > > Hi, > > I had a problem recently. > > To access the request object in all of my templates. > > The solution I got surprised me. It involved explicitly passing on > > the request object from the views. > > (Example, to pass a RequestContext object as a context_instance > > parameter in render_to_response method). > > > It surprised me because since request object is available to every > > view, why should the request > > object not be accessible in all templates by default? > > Using RequestContext means that all the context processors are run. This > overhead isn't needed in all cases. So Django provides a way to render a > temlpate without the context processors being run (if you use Context()) > and with the context processors being run (if you use RequestContext()). > If we always did the second thing, there would be no way to do the first > thing. > > It's trivial (not just easy, completely trivial) to write your own > version of render_to_response() if you always want to use > RequestContext. The entire function is two lines long. Of course, you'll > have to pass it the 'request' instance every time, so that it's > initialised correctly, but that's the cost of wanting request-related > stuff. > I agree it is trivial. Also, after looking around, and asking people, I find that many people do (independently) write that two line function. (And I guess, each of those must have done some looking around and asking people themselves to come to that two line function). Example: http://www.djangosnippets.org/snippets/3/ If it is more like an idiom, then is why is it not a built in shortcut function? 1. It will prevent many people from writing that same 2 line code. 2. While reading the documentation as a newbie, it will become evidently clear about how one can pass the request object to the template. > Yes, we could have the default being the reverse of what it is now, but > the arguments each way are pretty easily balanced. Sometimes you always > want to use RequestContext, sometimes you don't need it at all. So > there's no strong reason to change things when it's so easy to write > your won alternative shortcut. > > Regards, > Malcolm > Thanks a lot for your explanation. Its much clearer to me now. > -- > The early bird may get the worm, but the second mouse gets the > cheese.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Accessing request object in templates
Thanks a lot for your detailed answer. In Zen terms, I am 'enlightened' now ;) On Jan 4, 1:07 am, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Jan 3, 2008 2:33 PM, annacoder <[EMAIL PROTECTED]> wrote: > > > > > I understand *how* it is done. > > > But, my question was not related to the how part. > > Here's a quick rundown of the "why". > > Templates aren't triggered by HTTP requests like views are. Instead, > they're rendered inside views, which *are* triggered by HTTP requests. > Since the request triggers the view, it makes sense for the view to > receive the request object. Since templates are rendered by views, it > makes sense for templates to receive whatever the view sends them, and > nothing more. This is a design decision for at least a few reasons. > > 1) It allows templates to be more easily used outside of views, for > things like rendering reports about the content in the database or > anything else you might imagine. > > 2) It provides a clean separation of concerns. Views deal with > requests and responses, templates deal with variables and output > formatting. And since the view's the one "in charge" of the > relationship, it should be up to the view to decide what the template > gets access to. > > 3) The request would have to come from somewhere. Either you provide > it to the template explicitly (usually via RequestContext) or the > template code has to reach into Python's internal runtime data to > magically retrieve the request from the view. This process is very bad > because it: > > * isn't very fast > * is very very ugly > * is far from foolproof > * makes the view feel like Rob Lowe at the end of Wayne's World (if > you haven't seen it, trust me, it's not a good thing) > > 4) If you're more philosophical, this is also covered very clearly in > Tim Peter's Zen of Python: "Explicit is better than implicit." You > explicitly send the request to the template, so it's a Good Thing. > > -Gul --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---