Re: New django 1.0 website: www.astronomy2009.org

2008-09-11 Thread Rock

Very interesting. Nice work.

That scrolling calendar widget near the bottom right of the home page
needs a reset button.
Once you scroll a bit, it fills up with so many events that finding
your way back to today is tough.
(Or maybe that thing is supplied by Google and so you are hosed as
they almost never fix bugs of that nature.)
Fortunately the menus provide access to current events so maybe this
SNAFU is ignorable.

Also I noticed "The Portal to the Universe" project. Are you guys
doing that one? If so, how can I help?

Rock



On Sep 11, 9:16 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> We just released a new website for the International Year of Astronomy
> 2009 (http://www.astronomy2009.org). It's based on the improved
> versions of the django applications we used forwww.iau.org. We are
> still working towards decoupling the core applications from the rest
> of the site, so it can be released for the public benefit, however
> when time is short, short-cuts are made, so there is still some
> cleanup to do ;-)
>
> Thanks for viewing,
> Lars Holm Nielsen
> European Space Agency/Hubble
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to setup LDAP authorisation in django/apache.

2008-09-19 Thread Rock

We rolled our own LDAP authorization. First I created a python module
that imported ldap from the python-ldap-2.2.1 package and wrapped in
functions that performed authentication and pulled selected data from
our corporate LDAP server. Then one of my partners used that to create
our own login_required decorator. We wrapped selected application
pages with that and used the regular auth system to define a few non-
LDAP users who needed to use the Admin. We have been using that for
about 2 years.

I have a task ahead of me to update this functionality to 1.0. I'll
post some notes on that when I am done.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-To-Many with extra fields

2008-09-19 Thread Rock

In my code I have a reference and a name such that I can do perform a
"get" to procure the reference to the correct intermediate object.
Then I simply interrogate that object directly. It should be possible
to do a "values" style query instead if you only want a particular
field or set of fields.

Hope that helps!


On Sep 19, 7:37 pm, Nate Thelen <[EMAIL PROTECTED]> wrote:
> Looking at the docs here:
>
> http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-o...
>
> I cannot find any reference to how to access the data in the
> "Membership" table.  For example, if I have a reference to the
> "beatles" object, how do I find the "date_joined" for each of the
> "Person" objects.  I have looked through the other sections of the
> documentation, searched this group, and searched via Google, but
> couldn't find the info.
>
> Thanks,
> Nate
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: INSTALLED_APPS from a template

2008-09-25 Thread Rock

I have no idea, but it only took me a few minutes to create a filter
you can put in some templatetags module:


from django import template
from django.conf import settings
from django.template.defaultfilters import stringfilter

register = template.Library()

@register.filter
@stringfilter
def installed(value):
apps = settings.INSTALLED_APPS
if "." in value:
for app in apps:
if app == value:
return True
else:
for app in apps:
fields = app.split(".")
if fields[-1] == value:
return True
return False


Assuming that you named this file "installed.py" then your template
can do this:

{% load installed %}

{% if "django.contrib.sites"|installed %}
   and so forth

If the string you supply (or the string yielded by your variable) has
a dot in it ("."), then the full name must match. Otherwise the filter
will just check the last component of the name. (You can edit that out
of the filter if you don't like that behavior.)

{{ "admin"|installed }}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 'get_latest' is not a valid tag library

2008-09-25 Thread Rock
You need an empty __init.py__ in the directory or else the python
files there will not be found.

On Sep 25, 10:29 pm, Matthew Crist <[EMAIL PROTECTED]> wrote:
> Here's my template:
>
> {% load get_latest %}
>  "http://www.w3.org/TR/html4/loose.dtd";>
> 
>         
>                 My Site - {%block pagetitle %}{% endblock %}
>         
>         
>                 My Site
>                 
>                         
>                                 home
>                                 Blog
>                                 Links
>                                 About
>                         
>                 
>                 
>                         
>                                 {% block title %}{% endblock %}
>                                 {% block primary %}{% endblock %}
>                         
>                         
>                                 Recent Entries:
>                                 {% get_latest blog.Entry 5 as recent_posts %}
>                             
>                                 {% for obj in recent_posts %}
>                                         
>                                                 {{ obj.title}}
>                                         
>                                         {% 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: Can I create unique instances of a model to live under another model?

2008-09-26 Thread Rock


It may be as simple as creating an intermediary field between Document
and agency called Study. (See the Django docs regarding adding extra
fields to a many-to-many relationship.)

In any event, it is wise not to think of models as objects so much as
stand-ins for DB tables (which is what they are.) So this should be
treated like a schema design problem, not an OO design problem. (Yes I
know models can be inherited abstractly and concretely and I take
advantage of that in my own code, but that can gt you into trouble if
you aren't clear of the limitations that inheriting models imposes.)

If you are unclear on the difference between database schema design
and OO design, then you might want to consider procuring a consultant
to review your schema design in light of your complete set of project
requirements at some time point early in the design process. That
might save you a ton of time and money in the long run.

Rock

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can I create unique instances of a model to live under another model?

2008-09-26 Thread Rock

Oops. I meant intermediary class, not intermediary field.

On Sep 26, 1:39 pm, Rock <[EMAIL PROTECTED]> wrote:
> It may be as simple as creating an intermediary field between Document
> and agency called Study. (See the Django docs regarding adding extra
> fields to a many-to-many relationship.)
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 'get_latest' is not a valid tag library

2008-09-26 Thread Rock


Hmmm... Here are some guesses:

If that return statement in render is a single doublequote instead of
2 singlequotes, then your code probably won't parse and, even if it
does,  get_latest certainly won't be found.

It seems to me like you need to coerce the string being assigned to
self.num as make it an int. (Better yet, put that logic in the parse
section.) However that is unlikely to be the cause of the error that
you are seeing.

You might want to try compiling the code by hand to make sure there
are no stray typos.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: alphabetize options in a ForeignKey dropdown?

2008-10-01 Thread Rock


Have you tried setting the order within your model? I think that is
the only simple way to tackle this at this time.

class Meta:
ordering = ("fruit",)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Dynamically appending a step to FormWizard

2008-10-02 Thread Rock

I can't show you the code yet since I haven't got permission to post
it cleared from my company, but I got this working. (It was not easy
and req
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Dynamically appending a step to FormWizard

2008-10-02 Thread Rock

I cannot show you the entire code since the company lawyers have not
had time to allow me to release this snippet, but I did get this
working. However it was not easy and required some interaction with
the guys who created FormWizard.

My approach was to create a DummyForm which I put in the second slot
of the form_list. I also had a dictionary of possible replacement
forms which were chosen via a selection on the first form.
The critical bit of processing looks like this:

def process_step( self, request, form, step ):
if step == 0:
if form.is_valid():
selection = form.cleaned_data["selection"]
self.extra_context["selection"] = selection
if self.form_list[1] != self.form_dict[selection]:
self.form_list[1] = self.form_dict[selection]

The is_valid call forces a reclean of the first form's data each time,
but is required since you can't reliably save state data during this
process. (Also don't freak out that step == 0 occurs with each
iteration through your wizard as you go to subsequent steps.)

There may be more challenges after you get across this bridge, so
please post a follow up on how this works out for you.

Rock


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: alphabetize options in a ForeignKey dropdown?

2008-10-02 Thread Rock



On Oct 2, 2:00 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Wiadomość napisana w dniu 2008-10-02, o godz. 01:03, przez Rock:
>
> > Have you tried setting the order within your model? I think that is
> > the only simple way to tackle this at this time.
>
> >    class Meta:
> >        ordering = ("fruit",)
>
> This will change default ordering across the whole site. To change  
> ordering only in admin app just define ordering in admin class for the  
> model.
>

My understanding is that this does not work for foreign keys. See
Ticket #6585.

It is sure nice to see Bennett's handy dandy code pattern. Tres
formidable.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Rendering just child template...

2008-10-02 Thread Rock


No. Typically you would make a stand-alone template that does not
extend anything else. This template only renders the contents of the
container in question. It can be used by your AJAX view to create an
updated container which can be passed back to the browser. But the
same template can also be included by a child template (or templates)
at the appropriate place to perform the original rendering of that
container on full pages as required. So your child template now
"includes" this same template:

{% include "my_dynamic_container.html" %}

Hope that helps...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there anything like the RailsKits for Django?

2008-10-10 Thread Rock

Satchmo is your best bet at this time. It provides a rather complete
Django-based web storefront and includes explicit support for
subscription management.

See satchmoproject.com for more information.

There is a Google group for satchmo users called satchmo-users.


On Oct 10, 7:19 am, Wayne M <[EMAIL PROTECTED]> wrote:
> I am currently debating between using Django or Ruby on Rails for a
> new SaaS web app I'm thinking of making.  I've not done a subscription-
> based site before, so I'm looking for something that provides the
> basic functionality since I would probably not be able to write my own
> without it taking a long time.
>
> I like the look and feel of Django a little better than Rails (some
> minor beefs like how you have to add customization to get the
> development server to display images and stylesheets, when Rails'
> "WEBRick" server does so out of the box), as well as the fact Django
> is more customizable, but so far the biggest detriment I have found is
> that the Rails community seems much larger, with many common things
> already built by the community so you just have to install a plugin or
> a gem, and you get exactly what you need.
>
> In this specific case, there is the SaaS RailsKit (http://www.railskits.com) 
> that provides the framework for a subscription-
> based site out of the box, with account management, having account
> subdomains (e.g. customer1.mydomain.com, customer2.mydomain.com),
> different plans, recurring billing, and the like.  It's a bit pricey,
> but as I said I would probably be unable to write my own for all of
> this as I would also need to learn Ruby and Rails/Python and Django in
> order to be able to develop my app in the first place.  I've done some
> basic tutorials in both, but I want to choose one and stick with it.
>
> Is there anything similar to this for Django?  I would rather not
> switch between the two as the languages are similar and I would
> probably get confused at some point.  I did find a "django-accounts"
> module (I don't know what plugins are called in Django parlance,
> sorry) at Google Code, but it doesn't seem to have been updated since
> 2007 and there are no instructions at all on how to actually integrate
> it into an existing application.
>
> I apologize if these questions are a little noobish in nature; I'm
> trying to choose a development language and framework so I can start
> working on this application, and Rails/Django are my two major choices
> - I like the feel of both but as I said above, Django seems less "Do
> it this way and only this way" and more customizable than Rails, so
> I'm leaning towards Django... it's just that there doesn't seem to be
> as many resources out there.
>
> Can anyone provide assistance?
>
> Thanks,
>
> Wayne
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: page not updating right away

2008-10-18 Thread Rock

A very common problem is that the timezone or system clock is off.
Most Blog implementations allow you to create a blog entry "in the
future" so it shows up on your web page only after a specified time.
This capability plays havoc with noobies who haven't bothered to set
their timezone correctly in their settings.py. A 2 hour delay is the
most common since the settings.py defaults to Chicago and many shared
host servers are based in the Pacific timezone.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Splitting models.py won't install models

2008-10-28 Thread Rock

I tried to do this several months ago during the run up to the 1.0
release and, at that time, the capability was broken. Furthermore I
recall having a discussion with some core developer that it was not on
the short list to fix for 1.0. I didn't submit a ticket for this, but
it may have been because someone else had already done so. I suggest
searching the tickets before spending any more time trying to make
this work.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: populating forms using models

2008-11-01 Thread Rock

In brief, your forms field for province does not have to have anything
to do with your corresponding model field.
Just make a forms.ChoiceField with the data filled in that you need
(or else look up the pattern for loading dynamic data into a
forms.ChoiceField and do something like that.) If you go the dynamic
route, make sure your form gets initialized properly when you create
it for initial use and also when you create it for POST processing.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: updating a single field / attribute, is it possible? or better practices?

2008-11-01 Thread Rock

In the meantime, creating and executing your own update command is not
difficult.
Here is a snippet for a custom PositionField that updates itself when
necessary with an SQL UPDATE:

http://www.djangosnippets.org/snippets/884/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Sphinx Search ORM

2008-11-11 Thread Rock

You are going to have better luck using David Cramer's project which
is up to date with Django 1.0:

http://code.google.com/p/django-sphinx/

On Nov 11, 6:05 am, dusans <[EMAIL PROTECTED]> wrote:
> Has onyone been able set make Sphinx Search ORM to 
> workhttp://www.djangosnippets.org/snippets/231/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: compare old and new model field value

2008-11-11 Thread Rock

Take a look at http://code.google.com/p/django-reversion/ which may be
more than what you need, but certainly fills the bill for your general
use case.

On Nov 10, 1:03 pm, Tim <[EMAIL PROTECTED]> wrote:
> Basically, I want to be able to do something if the value of a field
> changes in a model.
>
> c = Category.objects.get(pk=1)
> c.name = "New Name"
> c.save()
>
> At any point (when the model is saved, when the value is set, etc.) is
> it possible to compare the old and new value? The first thought that
> popped into my head was something like this. I know this exact code
> isn't possible, it's just an example of what I'm trying to do.
>
> class Category(models.Models):
>
>     def save(self):
>         if self.name.old_value != self.name.value:
>                 do something fun here
>         super(Category, self).save()
>
> If something like this isn't built in to Django, I was thinking of
> writing a custom field and overwriting __set__() to store the old
> value somewhere, since that seems to be the only place that would have
> access to the new and old value.
>
> Any thoughts on whether that's the best method?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 best-practice question: reusable apps: where to write views in my proj?

2008-11-11 Thread Rock

I have used both approaches on different occasions. I feel the choice
boils down to the quantity of shared stuff that you need. For a large
app I recently created a "common" app that ended up having no models,
but did include a large assortment of shared views, choices, forms,
templatetags, utility functions and the base templates for the
project.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 pluggable adressbook/mini-CRM?

2008-11-11 Thread Rock

I have looked for this myself and in my opinion the answer is no.
There are several mini-crm prototypes that were started in pre-1.0
days and abandoned. None of them includes a basic design that I find
compelling.

The minibooks app is the closest thing to a working Django CRM, but it
has several annoying problems that make it unusable in its' current
state. Also it combines a CRM and a ledger system in an intertwined
manner such that neither the CRM nor the ledger is "pluggable" without
the other which, in my book, is not an ideal design.

Let me know if you find anything or start a new project along these
lines.

On Nov 10, 3:40 pm, Mikkel Høgh <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I'm working on a small time tracking app (http://github.com/mikl/djime/
> tree/master – in case anyone is interested), and I'm looking to track
> time spent on clients, projects and tasks, and currently I'm on the
> lookout for some sort of address book or CRM that I could utilize
> instead of writing my own. Must be plugable, of course.
>
> Does anyone know of anything like that I could use?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: App for creating "subsites"

2008-11-12 Thread Rock

First you have to figure out how you want to map your users to their
pages.
Do you want to use subdomains? How about something like the
delicious.com scheme
(i.e., http://delicious.com/username/ ) Or perhaps you have something
else in mind.

After you figure out your URL mapping, the rest looks like standard
Django stuff to me.
You have your different Django apps and you simply pull data out of
each of them on a per user basis. You will need to look into a
"paglet" model like django-chunks for managing content from several
different Django apps in a single user page. Lot's of people have
created their own implementations of this particular capability as it
is not difficult to do.

The tricky part will be what to do if your site gets popular and
suddenly you are managing a ton of data. Then you may need to start
using advanced techniques to scale your site. But for now I wouldn't
worry about premature optimization. Just keep it simple for now.


On Nov 12, 8:42 am, Andreas <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Using Pinax I am looking to create a site where users can create their
> own "subsites", ie similar to Ning.com or Wordpress.com. Each subsite
> will be administered by the user that created it, and several
> different Django Apps are needed to give each subsite the
> functionality it needs (photo gallery, blog etc). Preferably this
> should be done by using some existing App to handle the subsite
> specific functionality, but I have not found any such App.
> django.contrib.sites is not really an option since it requires editing
> settings.py for each new subsite and the creation of a new subsite
> should be as automated as possible.
>
> Do anyone know of an existing App that can be used for this?
> Any tips on how this could be structured?
>
> I would appreciate any pointers as I am relativly new to Django.
>
> Thanks!
> Andreas
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Database

2008-11-26 Thread Rock

http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/

On Nov 26, 8:30 am, "Austin Gabel" <[EMAIL PROTECTED]> wrote:
> Hello,
> I am currently attempting to roll my own multiple database support for
> django for a new project.  I have attempted to search for examples of this
> but have not found very much.  Does anyone have some examples on how I can
> accomplish this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing dynamic apps

2008-11-26 Thread Rock

I took a similar path. I cloned the run_tests function from
django.tests.simple.py and put it in my project directory as
test_setup.py while adding this near the top of the function:

if settings.TEST_APPS:
settings.INSTALLED_APPS += settings.TEST_APPS

That at least allows me to define TEST_APPS in my main settings file
for the project and in a location near INSTALLED_APPS so that I am
less likely to introduce unintended collisions. But my approach feels
dirty too. It shouldn't take much work to incorporate a TEST_APPS
construct into the existing test framework. I realize it might be
nicer if each batch of unit tests could define their own set of extra
test models, but I think that a master list of additional test apps
like above has the advantage of simplicity. But I haven't given this a
lot of thought beyond this simple minded hack.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: can't pass a parameter to my named url using {% url %} tag in template

2008-11-27 Thread Rock

I had the same problem recently in a template that was created for use
in an inclusion_tag. My workaround was to the perform the reverse call
in the templatetag and pass in the resulting url.

If that is not an appropriate workaround for you, perhaps a "with"
will do the trick. If that doesn't work and you can't figure out how
to make this work within the template, then you are going to have to
create a custom version of the url templatetag that can handle the
variable correctly.

This deficiency in the url templatetag may warrant a Django ticket
(unless there is already one posted for this scenario.)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Training

2008-12-12 Thread Rock


Steve,

I think that the book by Forcier, Bissex and Chun called "Python Web
Development with Django" is worth looking at with regards to ideas for
a lesson plan. To me it seems that it would be an excellent workbook
for a very full week of classes. Their chapter 1 on python and the
first few pages of chapter 3 on dynamic web site concepts can be
viewed as either a good set of prerequirements or else as required pre-
reading for the class. Also note that the book is based on Django 1.0
which makes it unique in this regards at this time.

I like their idea of jumping in right away and building a simple
project as they do in Chapter 2 and then doubling back and going over
the core concepts starting with Part II of Chapter 3 and then Chapters
4, 5 and 6. I think this material could be covered in 2 days worth of
classes.

After that the book presents a bunch of example projects and advanced
concept chapters and appendices that can be used to round out the
class. Mix in some hands on exercises and you have a very full week of
learning while the book itself makes for a nice take away for the
students,

Just my thoughts. In case you are wondering, I am not being paid by
Addison Wesley to make these comments nor do I know any of the
authors. I simply read the book and then decided that if I decided to
put together a Django training class that I would probably use the
book as the basis for such an offering.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Recipe 534109: XML to Python data structure

2009-01-06 Thread Rock

Elementtree is now part of the python distribution. I am using it in a
Django app I created for a client to extract data from XML provided by
a web service. It works well but the documentation could be clearer.

On Jan 6, 9:27 am, "shi shaozhong"  wrote:
> I am reading in a xml from a web service.  I wish to find a Python
> script to turn the xml into a Python data array for further
> manipulation and to be saved in a .dbf file.
>
> Has anyone tried the following 
> script?http://code.activestate.com/recipes/534109/
>
> How do I use it?
>
> Regards.
>
> David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Blueprint css versus YUI grids versus ?

2009-01-19 Thread Rock

I have generated several static sites using Django aym-cms,
blueprint.css and markdown. This worked so well that I created a
django app that encapsulates blueprint.css so that I now have the
ability to manipulate layouts dynamically. Next up is to hook up
"pagelets" (i.e., django-chunks, django-modular, etc.) to create
sublayout units that I call "gridlets" to boost this stuff into the
realm of end user directed (or at least selected) layouts.

On Jan 19, 8:52 am, felix  wrote:
> I've also enjoyed blueprint for its clarity and speed.
>
> ideally I would love to assign more semantic .classes and #ids and then use
> a style sheet that assigns to styles to styles (yo dawg ... )
>
> .detail {
>  {% blueprint 'span-8' %}
>  {% blueprint 'box' %}
>   border: 1px solid {{ui.bordercolor}};
>
> }
>
> and then something like django-compress would render this final css by
> parsing the blueprint CSS, copying the style defs over and into the actual
> style sheet.
>
> note also inserting vars from a ui object
>
> this would be something like django-compress could do.
>
> On Mon, Jan 19, 2009 at 3:02 PM, bruno desthuilliers <
>
> bruno.desthuilli...@gmail.com> wrote:
>
> > On 17 jan, 22:03, ydjango  wrote:
> > > has anyone used Blue Print css?
>
> > Yes. Tried it for a personal project, found it nice at first - and to
> > be true, it really helped me prototyping. But now the design is ok to
> > me, I'm in the process of rewriting all my markup and css to get rid
> > of the "grid.css" part. There was too much markup that was just here
> > to make blueprint work, and I don't like the kind of "reinventing
> > table layout with css" feeling it had.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cache middleware and middlewareorder

2007-12-21 Thread Rock

On Dec 5, 7:02 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
>
> If you're using CACHE_MIDDLEWARE_ANONYMOUS_ONLY you need a different
> middleware ordering, as the error message says. That setting is a real
> hack and I'd love to implement it in a better way some day. At the
> moment, though, where you place thecachemiddleware depends on whether
> you're using that setting or not.
>

I am thinking about customizing a version of CacheMiddleware such that
all
views are cached unless the user is a staff member. If I were in
charge, I
would implement CacheMiddleware without the ANONYMOUS_ONLY hack and
then also
supply AnonOnlyCacheMiddleware and my own NonStaffCacheMiddleware as
alternatives.
This approach would be less hacky and the instructions about ordering
Middleware
would also be more straightforward to communicate.

Anyone think thst the NonStaffCacherMiddleware will run into problems?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: An easier way to do this Pagination in a template?

2008-01-09 Thread Rock

I would move the logic into a custom filter. This keeps it out of the
view and radically simplifies the template logic. It is easy to create
a filter that takes an argument, so the fact that you have two
inputs (page_number and current_page) is no problem.

On Jan 9, 11:02 am, "Prof. William Battersea"
<[EMAIL PROTECTED]> wrote:
> Hello,
>
> On nearly every page of the website I'm creating, I have a list of recent
> articles in the sidebar that works as a complete archive. You can sort them
> by newest/oldest, and page through the entire archive. The template code for
> the pagination looks like this
>
> {% for page_number in page_list %}
>
>     {% ifnotequal page_number current_page %}
>
>         {{page_number}}
>
>     {% else %}
>
>          {{ page_number }}
>
>      {% endifnotequal %}
>
> {% endfor %}
>
> As a result, as soon as you sort, or page through, the url gets a
> querystring appended to it. I'd like to keep them as clean as possible, so I
> was thinking of only adding the sort_order to the pagination hrefs if it's
> not the default. Something like:
>
> {% for page_number in page_list %}
>
>     {% ifnotequal page_number current_page %}
>
>          {{page_number}}
>
>     {% else %}
>
>          {{ page_number }}
>
>      {% endifnotequal %}
>
> {% endfor %}
>
> But I'm unhappy that there's so much logic in the template, and it's getting
> hard to read. I understand that maybe every page shouldn't have this list
> with ordering and pagination, but it's something I'm experimenting with, and
> I'd like to get it working in the best order I can.
>
> I thought about doing most of the processing in the view and outputting the
> pagination as a single string, but then I've moved at least a small bit of
> HTML into my view. I feel like there should be a cleaner way. Am I doing
> something wrong, or is this an acceptable level of logic in the template?
>
> I hope that's clear.
> 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 Tutorial02 / TEMPLATE_DIRS

2008-01-17 Thread Rock


The templates have to be within a directory named "templates" found in
the /var/www/ directory.
BUT DON'T PUT TEMPLATES THERE! Put the templates dir in the same
directory as your settings.py
file and set the path accordingly in the settings.py file.


Here is another good alternative:

Comment out the filesystem loading option. This means that the second
loader (which is the
app_directories template loader) will be used exclusively. Now put
your templates file within
your application directory, i.e., myapp/templates/ and put the
templates in there. Now you
don't have to specify an absolute path in the settings.py file for
template loading.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problem with manage.py and shared app/project structure

2008-01-17 Thread Rock


Put shared in site-packages right alongside django. Problem solved.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Template Macros Like In Jinja

2008-01-22 Thread Rock

You can create an intermediate base class that extends your base class
and includes elements like:

{% if actions %}
... show action table ...
{% endif %}

{% if element %}
... show edit element form ...
{% else %}
... show add element form ...
{% endif %}

and so forth and so on. Now your page appearance is controlled by
whether or not you pass in corresponding data elements.

This is not a true replacement for templates, but it does allow
for consolidation of repeating visual elements across a set of pages.


On Jan 21, 8:30 pm, "Papalagi Pakeha" <[EMAIL PROTECTED]>
wrote:
> hi there!
>
> i wonder if there is any way to have Macros in django templates
> similar to what Jinja has (http://jinja.pocoo.org/)?
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Unittest test-database not empty

2008-01-28 Thread rock

I'm using the unittesting-environment for test-driven-development in
Django. It works excellent, but one matter is puzzling. The Django
documentation tells me this:

"The test database
Tests that require a database (namely, model tests) will not use your
"real" (production) database. A separate, blank database is created
for the tests."

However, the test database is not empty after creation, it has two
users, which makes my test fail:

class MyselfTest(unittest.TestCase):
def testNoInitialUsers(self):
all_users = User.objects.all()
self.assertEqual(0, len(all_users))

The test fails with the message:

AssertionError: 0 != 2

When I print the usernames of these users, they are "testuser" and
"testuser2". I expect one of two explanations; either I am doing
something strange, or the Django-documentation for "Testing Django
Applications" is not correct.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unittest test-database not empty

2008-01-29 Thread rock

Thanks Russ, for your helpful comments!

I'm now searching for the initial_data fixture. I have looked through
all files in this project without success.  When I run

python manage.py test

there is no such sentence as "Loading 'initial_data' fixtures", but
maybe there shouldn't be one? I've also looked in all files named
initial_data.* on my system without luck.

I have a vague memory of creating these users (testuser and testuser2)
a long time ago, possibly under another project. Does anybody know how
to find (or delete) this fixture that is hiding somewhere?

Best regards,
Stein

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Unittest test-database not empty

2008-01-30 Thread rock

I have no fixtures/initial_data-files anywhere in my project tree!
Actually, the only file named "initial_data" on my system is djtrunk/
tests/modeltests/fixtures/fixtures/initial_data.json. And that file
doesn't contain much.

The "ghost-users" only show up when I'm running "./manage.py test".
When I delete the project database and run "./manage.py syncdb" and "./
manage.py runserver" an empty database is created. So I guess my
problem has something to do with the unittesting, but it is still
magic to me how and when these users are created.

Best regards,
Stein
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Google App Engine & Django

2008-04-08 Thread Rock


Brox ... Nice writeup! Many thanks!


Now for my thoughts...

I have been using PyTables as an adjunct datastore along with
the Django ORM for almost a year. To me, BigTable looks a lot
like PyTables and, as such, I know that it can be be a great
supplement to the Django ORM in certain scenarios. GQL may or
may not be a great idea, but I certainly don't think that it
is a bad idea as I have had similar thoughts when contemplating
improving the integration of PyTables and Django.

The key to me is multiple database support. Then we can keep
the ORM and also develop a OTM (ObjectTableMapper) perhaps
targeting GQL and take advantage of both datastorage models.
Plug in a GQL front-end to PyTables and much of the anguish
of being tied to the GoogleAppEngine starts to disapate.

I guess I will have to review the work that has been going on
for multiple DB support and see if it needs to be extended to
also include support for multiple model mappers.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Has anyone made an MS excel exporter in a django site yet?

2008-04-11 Thread Rock


I can't believe that no one has mentioned the xlrd package:

http://scienceoss.com/read-excel-files-from-python/

http://pypi.python.org/pypi/xlrd/0.5.2


Then again I haven't used this one yet, much less tried to incorporate
it with Django.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Has anyone made an MS excel exporter in a django site yet?

2008-04-11 Thread Rock


While I have used Django to emit csv files, I have also found
that my users are quite happy at times with simply cutting and
pasting data that I display in HTML tables via Django directly
into their spreadsheats. You might want to see if this is an
adequate option for some of your use cases. It has worked out
suprisingly well for some of my users.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Suggestion: Aggregate/Grouping/Calculated methods in Django ORM

2006-11-29 Thread Rock


I created such a patch last spring during the Django sprint at PyCon.
The basic interface was very straightforward but there was also a
slightly less straightforward interface option that allowed for
grouping and so forth. The patch was discarded, however, since some of
the core Django developers wanted to chime in on the interface design
for aggregate functions, but felt they didn't have time to do so until
after 0.95 was complete.

Rather than fight for my design (which I was not particularly
passionate about anyway), I just went home and used plain old SQL when
I needed aggregates. (I also learned about data bubbles and redesigned
my tables to include them as necessary. This redesign eliminated almost
all of my needs for an aggregate function interface.)

I am still interested in this topic, but I haven't had the personal
bandwidth to stay on top of the Django Developer's group. It would be
nice to know what, if anything, is happening along these lines. I might
even be willing to spend some time on this during the holidays.

Rock Howard


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google 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: Suggestion: Aggregate/Grouping/Calculated methods in Django ORM

2006-11-29 Thread Rock



On Nov 29, 2:30 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> > I needed aggregates. (I also learned about data bubbles and redesigned
> > my tables to include them as necessary. This redesign eliminated almost
> > all of my needs for an aggregate function interface.)Whatsa data bubble?  
> > Google and Wikipedia don't seem to know...

google search:
  "data bubble" database


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google 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: Suggestion: Aggregate/Grouping/Calculated methods in Django ORM

2006-11-30 Thread Rock

Yeah it is all coming back to me. I was unwilling to answer all of
these questions and create the perfect solution (which may not exist)
and therefore we don't have aggregates in Django even though I
demonstrated that a straightforward implementation was possible way
back when. Thanks for backing me up on that Russ. ;)

What I am pondering in the meantime is whether or not to do a fork of
Django someday that concentrates more on scientific presentations
rather than newspapers. In DjangoSci (or perhaps TechnoDjango) there
would be a lot of attention to data reduction, statistical processing,
queries oriented towards returning graphable data sets and, of course,
true floating point data representations in the database. I am willing
to wait for Malcom to finish his work before making this monumental
move. I will also look over SQLAlchemy.

The desire to mold a version of Django (or Django itself) to better
handle the needs of the technical/scientific market does not in any way
represent a slap at Django itself or its' many paid and volunteer
developers. Django rocks! It has become a core capability in my
development group. We already have 3 elaborate and highly visible
internal applications based on Django and our ability to quickly
respond to requests for improvements has changed the dynamics of how
our entire division does much of its work.


Rock


On Nov 29, 11:51 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 11/30/06, Rob Hudson <[EMAIL PROTECTED]> wrote:
>
> > I think for those who need aggregate data these would cover a lot of
> > ground.  I'd be willing to work on a patch if this is considered
> > generally useful and we can work out what the API should look like.1 - I'm 
> > agreed on the need for easier access to aggregates. Truth be told,
> aggregates are the reason I got involved with Django in the first place.
> However, other priorities have arisen in the meantime, so I haven't got
> around to doing anything about them.
>
> 2 - Keep in mind that Malcolm has been working on refactoring
> django.db.models.query. Until this refactor is committed, we are trying to
> minimize the number of large changes to query.py.
>
> 3 - Also keep in mind that one of the goals of the SQLAlchemy branch is to
> make complex aggregates (such as those requiring group_by and having) easier
> to represent. That said, there doesn't appear to have been a lot of progress
> on this branch (at least, not in public commits, anyway).
>
> 4 - If you search the archives (user and developer), you will find several
> discussions on aggregate functions. group_by() and having() (or
> pre-magic-removal analogs thereof) have been rejected previously on the
> grounds that the Django ORM is not intended to be 'SQL with a different
> syntax'. Any proposal for group_by/having will have to be logical from a
> Django ORM point of view, and not presuppose/require knowledge of how SQL
> formulates queries.
>
> 5 - The aggregates you suggest are the quick and obvious method for getting
> aggregates into the query language. However, here are some issues to
> consider:
>
> Article.objects.count() return an integer that is the count of all author
> objects. This makes sense, and syntactically parses the same way that it
> operates.
>
> However, what does Article.objects.max('pagecount') return? The integer that
> is the largest page count, or the Article that has the largest pagecount?
>
> If it is the former, how do you use the maximum value to get the Article
> with that maximum value in a single query?
>
> If it is the latter, does it return a single object, or a queryset that
> evaluates to an object?
>
> What happens if there are two objects with the same maximum pagecount?
>
> How do you get multiple aggregates for a value in a single query (efficiency
> matters)?
>
> How does the simple case fit into the big picture? Ideally, the simple min()
> would be a degenerate case of the min-with-group by-and-having. Prove to me
> that adding min(), max(), etc isn't going to become a wart that we have to
> support into the future when 'aggregate clauses 3000' is added to Django's
> query syntax.
>
> So, as you can see - it's not as simple as 'just add a min() where count()
> is already'.
>
> Like I said at the beginning, I'm keen to see aggregates implemented - I
> just want to see them done right. There are many things that _could_ be done
> to implement aggregates; whether they are the _right_ thing to do is another
> matter entirely. I'm open to any discussion on this issue, and would be
> happy to help shepard any patches resulting from the discussion into the
> trunk.
> 
> Yours,
> Russ Magee %-

Re: Why not Django

2006-11-30 Thread Rock


If you want to take advantage of GPU processors for number crunching,
then float is the ticket. In fact this is the way to go for most
serious scientific applications as well as image processing. Money
roundoff concerns are not part of the scientific application domain.


On Nov 30, 11:13 am, "Victor Ng" <[EMAIL PROTECTED]> wrote:
>
> I'm frankly surprised that a scientific computing app is using float
> with any degree of success.
>


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google 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: Suggestion: Aggregate/Grouping/Calculated methods in Django ORM

2006-12-04 Thread Rock


>
> > Talking through my hat?No, I think not -- I think that syntax 
> > (``queryset.groupby(field).max()``)
> actually looks like the best proposal for aggregates I've seen thus far...
>

Sounds pretty good to me. Besides the usual min, max and such, I also
like:
queryset.groupby(field).stats()
which would return a tuple with (min, max, average, stddev) for the
specified field.

> I'm taking this to django-dev for more discussion; it'll get seen by more the
> right people there.
>
> Thoughts, anyone?
>

Add "improving aggregate support" to the Django Sprint planning for
PyCon. I plan to participate and am willing to coordinate a team to do
that. Hopefully that will encourage people to spend some time on the
design ahead of time. I also promise to spend a day or two over the
holidays looking over the design proposals and adding my thoughts.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google 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: Random Data

2006-12-06 Thread Rock


I wrote a utility to parse a model files as well as embedded comments
that provided data loading hints. It was trivial to do.
The utility used "cog" to generate a data loading program. That worked
like a charm even as the underlying models evolved. (This approach was
a "win" since the data loading program was quite complex. We have
sinced rewritten the loading utility with python and simplified it to
the point where the need to automatically generate the code for the
data loader is overkill.)

Combining that idea with techniques for generating random data should
be easy. The http://agiletesting.blogspot.com/";>Agile Testing
Blog" has a recent post about Python Fuzz testing Tools that has
some good links regarding the generation and use of random data.

On Dec 6, 3:34 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I was wondering if anybody has any ideas on random generation of data.
> I want to fill some of my models with random data with random users and
> such. So that I can see how my UI is doing and some other tests. I
> figured that becuase there is alot of data defenition in the models
> there is probably away to do auto random data generation.
> 
> 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: Splitting the databases

2006-06-23 Thread Rock

This is not quite precise. I use two different databases on a single
installation. In fact, using the virtual hosting capability of apache
and modpython, I have one set of Django applications uses a PostgreSQL
database and an entirely different set of Django applications that use
a MySQL database. I am doing this to allow the two sets of applications
to use independent processes for backup and restore operations. (The
quickest way to backup and restore postgreSQL is to copy the whole
"data" area, but using this approach you cannot separately backup and
restore two different postgreSQL databases that share that data area.)

Fortunately I have no requirement that the two applications share data,
user authintification or anything else, but theoreticaly I could do
this by writing raw SQL code to get at the "non-settings" database in
either of the applications. (Painful, but possible.)

Perhaps more accurate would be to say that Django does not allow for
easy data access or data management of multiple databases in a single
installation.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Caching in Django admin

2006-07-19 Thread Rock


I can confirm that the odd behavior that you are seeing comes from
setting up the global caching for a site. I see the same thing on a
site under 0.91 that uses global caching, but not at all on other
non-caching sites. (BTW, the work around is to periodically blow away
the files *admin* in the cache directory.)

It looks like the right way to deal with this is to implement per page
caching, but that doesn't look too simple to me. I hope that someone
will prove me wrong by posting some simple instructions for implemeting
per page caching. Alternatively please post a mechanism for disabling
global caching for selected pages (even though I doubt that that is
possible without creating some custom middleware.)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Caching in Django admin

2006-07-20 Thread Rock

Well I switched to per view caching and it went off quite easily.
Thanks for the encouragement.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Strange 'caching' issue

2006-08-14 Thread Rock

I forget the details, but this has something to do with your time
and/or timezone setup. The default blog app doesn't post items that are
set "in the future". The time you set by seleting "now" in the admin
may or may not be the time that you think it should be because of the
server clock and timezone settings.

Something like that anyway. Probably not caching (unless you have
enabled site-wide caching, then perhaps that is the problem.)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



how to add content of the page's textarea in django ?

2006-08-20 Thread rock

how to upload a picture ,then add the url link of the picture to the
page's textarea content. Some bbs can do this . But how can I do like
this in django, any advice would be 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
-~--~~~~--~~--~--~---



Re: Database Migration

2006-08-24 Thread Rock

One of my django apps contains testing data about every item our
company has manufactured over the last year or so. The database has
over 50 million rows of data. Despite this I have successfully migrated
the database several times. Sometimes it is trivial. Back up the data
for safety and then just add a column or columns in a table while
making the same change in the models. Viola! (Renaming or retyping a
column can be similarly easy at times.)

I have even done a more massive migration. Here I backed up the data.
Cleared out all the tables. Made the model changes and recreated
database tables. Then I used sed to edit a copy of the backed up data
such that I could reload into the new tables.

Django does nothing to make it easier or harder to migrate a database
that any other database app (although I hear persistence rumors of some
eventual tool support for some of the more trivial migration
oeprations.)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Server Error pages

2005-11-21 Thread Rock

My view code for my calendar app can detect when a user supplies a bad
year, month or day, but I have no idea how to get Django to display an
application specific "500" page. I put a 500.html in my templates
subdir for the calendar app, but it is not found when a raise an
exception. It does look elsewhere for a 500 template, but that file
doesn't exist in my setup.

(In case you are wondering, I set DEBUG = False in my settings.py
file.)

How is this supposed to work? I saw a mention suggesting changing
urls.py and also noticed HTTPResponseServerError, but I haven't found
an actual example of application specific error handling.

Once I have this working, is there any way for my application to
override or bypass the global DEBUG setting so that these handled cases
do not yield a traceback?



Re: Django screencast

2005-12-13 Thread Rock


Nicely done. Really nice actually.

Now since you asked for feedback:

Perhaps 8 1/2 minutes would have been better as some of the operations
toward the end flew by too quickly to easily comprehend. (I know the
show seems slow to the producer who knows the content well, but the
first time viewer is your key customer and you don't want to leave them
in the dust.) Just a few more pauses at key junctures would have been
nice.

At the very beginning it would be nice to know the precise state of
things. (I presume that Django was installed but completely
uninitialized, but it would have been nice to be more explicit about
that and perhaps to point out which operations were "one time only".)

But those are really small nits and the latter could be solved by
supplying some accompanying notes to the screencast.

Quite impressive really.

Rock



Re: Django screencast

2005-12-13 Thread Rock

"Django" is pronounced correctly in the screencast.



Re: is Django too powerful?

2005-12-13 Thread Rock

Wrong I think. There are already several Djangoids looking at making a
discussion forum together as an open project. I expect there will be
plenty of similar activities.

The problem is that Django is changing fast right now without regards
to backwards compatability. Wait until 1.0 hits and soon thereafter I
expect that we will see more app sharing and cooperative development
beginning to take place.

I should also add that I don't really like many of the stated
conventions for creating sharable apps. The insiders at LJO don't
follow those conventions and I doubt many others will bother. IMO the
area of app deployment needs more attention and perhaps some additional
automation support.



forward references

2006-02-18 Thread Rock

Well this is more of a python question I guess, but here goes.
Let's say that I am using the example model from
http://www.djangoproject.com/documentation/models/many_to_one/";>this
page in the documentation.

I decide to add a _pre_delete function to class Reporter that will
delete any articles for that Reporter before the Reporter is deleted.
Something like this...

def _pre_delete( self ):
articles = articles.get_list(reporter_id__exact=self.id)
for article in articles:
article.delete()

The problem is that this won't compile since articles is undefined.
What is the preferred way to deal with this type of forward reference
where the functions in a given class need to call functions defined for
a class that is itself defined later on in the same file?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: forward references

2006-02-18 Thread Rock

You would think so, but somehow that didn't work...

Precisely what import statement would you use.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: forward references

2006-02-18 Thread Rock

Ahhh. That makes sense. 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
-~--~~~~--~~--~--~---



Re: forward references

2006-02-18 Thread Rock

Good catch, but this was just an example to show the poblem I was
facing.

FWIW, if someone really wanted to implement _pre_delete for Reporter as
discussed, they should add this version of the function to class
Reporter:

def _pre_delete( self ):
for article in self.get_article_list():
article.delete()


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: adding page

2006-02-21 Thread Rock

Mary,

In your templates directory you need a template named default.html.
Here is what mine looks like:

http://www.w3.org/TR/REC-html40/loose.dtd";>


{{ flatpage.title }}


{{ flatpage.content }}




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: models and forward declarations

2006-03-09 Thread Rock

Search for "forward reference" in this group. (Basically you cleverly
locate your import statement inside a function call.)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Need help for query, how could i do this with django ? or a raw SQL.

2006-03-24 Thread Rock


Dropping down to the raw SQL level is easy...

Assuming my_sql_command is a string with your select statement...


from django.core.db import db

cursor = db.cursor()
cursor.execute( my_sql_command )
row = cursor.fetchone()
result = row[0]

You might prefer fetchall(), but I leave the data gathering details to
you.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



numeric formatting

2006-03-24 Thread Rock

Is there a template filter for turning a large integer into a human
readable number?

1234567 --> 1,234,567
12345   --> 12,345

I don't think that python built-in formatting can do this. (Am I
wrong?)

Assuming there isn't already a simple filter that will do this, what do
I need to learn about in order to create my own filter?

Rock


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



urls.py changes ignored

2006-03-30 Thread Rock


I have a development site where I can update myproject.urls.py and the
changes are acted upon immediately by my server. I just cloned this
site onto another computer and everything seems to be in order except
that on this new system, changes to urls.py are entirely ignored.
Nothing I do seems to be able to convince the system that I have
changed the urls.py file.

Both systems are running with Apache2 and mod_python on Linux.

Things I have tried:

Adding NO_CACHE = True to settings.py.

touch myproject/urls.py

checked the permissions of myproject/urls.py

Even removing myproject/urls.py makes no difference in the operation of
the clone system.

I am using 0.91 for this project.

What else should I be looking at?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: urls.py changes ignored

2006-03-30 Thread Rock

Yes I did. No help.

Then I forced the creation of a new urls.pyc by importing urls.py in
"python manage.py shell" and importing urls.py and explicitly checking
that the correct number of urlpatterns were defined. Still no joy in
the browser though.

Note that the access_log shows my request but the error_log logs no
associated errors.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: urls.py changes ignored

2006-03-30 Thread Rock

On my development machine I do not have to restart the webserver to
have the changes enforced.

In any event, I have tried restarting the webserver and also dumping
the cache in my browsers without effect.

There is no reason to suspect an error with the cloned urls.py file as
it is an exact copy of the version on the development machine.

Another thing that I have checked is the timezone and tod settings on
the two machines and the timezone setting in the settings.py file.

I am going to take a deeper dive into the http configurations now.

Rock


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: urls.py changes ignored

2006-03-30 Thread Rock

I found a tiny difference in the http.conf files (AllowOveride was set
to "FileInfo" instead of "None".) I made that change, even though I
seriously doubted that it would make a difference. Then I bounced
apache and amazingly enough the new urls.py showed up.

I set the AllowOverride setting back to FileInfo and changed the
urls.py again and so forth and proved to myself that the AllowOveride
setting had nothing to do with anythng. It was all about the bounce.
(Apparently I thought I had bounced the server previously, but had not.
Perhaps I was not su when I did the previous bounces.)

So now I can force the urls.py changes to be respected by bouncing the
server. (Whew!) But that still begs the question -- why is my
development server picking up urls.py changes right away while my clone
machine requires a server bounce. Hmmm.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: create models from the admin page?

2006-05-03 Thread Rock


falcon wrote:
>  I still believe that
> many 'developers' could benefit from defining simple to moderately
> complex models on the web.  If code needs to get more complex,
> developers can just switch back to using models.py.
>

I have gone in a different direction. I have written a tool to parse
the models file and use that info (along with some hints that I embed
in comments) to generate rules to drive pre-existing data extraction
software. I then use the same info to generate code that takes the
results of the data extraction process and loads it into the Django
database. (The loader runs continuously as I manage data coming in from
factories that run 24/7/365 at several locations around the globe.)

I am still proving this stuff out and tuning performance, but the early
experiements have worked out well. I am contemplating the possibility
of recasting this code into a mini-framework that could conceivably be
contributed to the Django project in the future.

My other challenge, which is only partially implemented at this moment,
is automating the cloning process. Before I change my models using the
tools above, I want to clone my existing Django system to another
server (database and all) so that my users can keep using a static
snapshot of my system even as I reload the factory data and create new
views for the newly added model fields. Ideally I would also configure
Apache to send the user to the right server depending on the state of
the main system.

Fun stuff, eh? Hard to believe I get paid to do this 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
-~--~~~~--~~--~--~---



Unable to view results page of polls tutorial

2012-05-18 Thread First Rock
hi al
almost done with the django tutorial#4.. But my app doesnt use the
html pages, n doesnt load the radio buttons and results page.. Other
than those the app is displayed in the default template and shows al
the pages of groups users n polls.. i have placed the html templates
in templates directory which is in my app polls directory.. here is my
views file..

pls help..
thnx in advance..


# Create your views here.
from django.template import Context, loader
#from polls.models import Poll
from django.http import Http404
from django.http import HttpResponse
from django.template import RequestContext
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from polls.models import Choice, Poll
#def index(request):
#latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
#return render_to_response('polls/index.html', {'latest_poll_list':
latest_poll_list})
def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
t = loader.get_template('/home/hdp/mysite/polls/templates/polls/
index.html')
c = Context({
'latest_poll_list': latest_poll_list,
})
return HttpResponse(t.render(c))
#def detail(request, poll_id):
#try:
#p = Poll.objects.get(pk=poll_id)
#except Poll.DoesNotExist:
#raise Http404
#return render_to_response('polls/detail.html', {'poll': p})
#def detail(request, poll_id):
#return HttpResponse("You're looking at poll %s." % poll_id)
#def detail(request, poll_id):
#p = get_object_or_404(Poll, pk=poll_id)
#return render_to_response('polls/detail.html', {'poll': p})
def detail(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/detail.html', {'poll': p},
 
context_instance=RequestContext(request))
def results(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/results.html', {'poll': p})
#def vote(request, poll_id):
#return HttpResponseRedirect(reverse('poll_results',
args=(p.id,)))
 #return HttpResponse("You're voting on poll %s." % poll_id)
def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the poll voting form.

return render_to_response('polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
}, context_instance=RequestContext(request))
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully
dealing
# with POST data. This prevents data from being posted twice
if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls.views.results',
args=(p.id,)))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Integrating Admin and Polls Applications

2012-05-24 Thread First Rock
I want to take forward the application creating experience  with
django, by integrating the polls and admin applications. As far as my
knowledge is concerned in the polls appl we developed anyone could
enter the url and cast their vote. I wish if we could integrate the
admin apppl, and allow only registered users to cast thier vote.
Please let me know if anyone has tried this thing before. Would be
encouraging for me to get started.
Thanks..

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Libraries for generating URL of uploading files in Django

2012-06-01 Thread First Rock
Need to develop a project for file uploading and generating
its(files's) URL, which could be shared. Are there any particular
libraries or simple means in Python,(Django) that would be handy and
efficient.? ~ Newbie trying a Herculean Task~ Thanks in Advance :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django model complex query ( use table A.column1 as parameter to query result from table B)

2014-10-21 Thread zhang rock
Hi All,

I have a question: how to use table A.column1 as parameter to query result 
from table B?

I have two tables : 
 
1. UserStay
idcandidatePoiIdsselectedPoiId
1101,102,103  100


2. POIs
id  name  address
100   starbuck 100 main st, 
101   mcdonalds  101 main st, 

i want to get all candiate POI's name and address when i fetch User stays, 
the following code does not work , i also tried Manager with raw SQL, but i 
dont' know how to pass the candidatePois to manager, can i get the string 
value of "candidatePois"  in model ?

class UserStays(models.Model): 
startTime = models.IntegerField('startTime', max_length=255)
candidatePois = models.CharField('CharField', max_length=255)
poiRes = POIS.objects.filter(id in F('*candidatePois*') )
// poiRes = POIS.objects.filter(id = 100 )
//print poiRes.name + poiRes.address


Thanks
Rock

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/722f80db-4069-4e30-a94a-c7d58a9c6c3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Newbie questions

2005-10-24 Thread Howard, Rock



I have installed django on dreamhost using fcgi. The posted instructions
needed updating due to the improved handlings of settings.py, but I
think I nailed the changes as the admin app comes up fine. My questions:

1) The url '' leads to a 404 error. Is that expected? It is unclear from
the docs what to expect for this case.

(Note that before I modified the rewrite rules, the url of '' was
causing a django crash in the line of code that attempted to add a slash
('/') to the url. This is not a good thing for a newbie to experience!
Perhaps that code should check for and handle len(url) == 0 explicitly?)

2) The admin page has a link to "example.com" which apparently is coming
from the site table. The admin app apparently supports no capability to
update that row. What are the ramifications of directly updating that
row in the site table?
What should I have done during installation to have the correct site
info placed in the db?




Re: Error during template rendering

2019-05-23 Thread Rock N Roll Mühlbacher
Am Donnerstag, 23. Mai 2019 20:06:31 UTC+2 schrieb cixtus anyanwu:
> Guys am following the django girls pdf tutoril but am stuck here. Its saying:
> 
> 
> 
> django.urls.exceptions.NoReverseMatch: Reverse for 'post_details' with 
> keyword arguments '{'pk': 3}' not found. 1 pattern(s) tried: ['posts/ pk>/$']
> [23/May/2019 18:13:22] "GET / HTTP/1.1" 500 153773 
> my views.py is below:
> 
> 
> 
> 
> from django.shortcuts import render, get_object_or_404
> from django.utils import timezone
> from .models import Post
> 
> 
> # Create your views here.
> def post_list(request):
>  posts = Post.objects.filter(title__contains='post')
>  return render(request, 'blog/post_list.html', {'posts':posts})
> def post_details(request, pk):
>  posts = get_object_or_404(Post, pk)
>  return render(request, 'blog/post_details.html', {'posts': posts})
> 
> 
> 
> 
> urls.py
> 
> 
> 
> 
> from django.urls import path
> from . import views
> 
> 
> urlpatterns = [
>  path('', views.post_list, name='post_list'),
>  path('posts//', views.post_details, name='post_details')
> ]
> 
> 
> 
> 
> base.html
> 
> 
> 
> 
> {% load static %}
> 
> 
>  Django reloaded
>  
> 
> 
>  Django Girls Blog 
>  {% block content %}
>  {% endblock %}
> 
> 
> 
> 
> 
> 
> post_details.html
> 
> 
> 
> 
> {% extends 'blog/base.html' %}
> {% block content %}
>  {% if post.published_date %}
>  {{post.title}}
>  {% endif %}
>  
>  {{post.body}}
>  {{post.published_date}}
>  
>  }
> {% endblock %}
> 
> 
> 
> 
> I have tried everything i can. Pls help me out guys.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/92d0fe6d-dc88-4423-9645-402284ac9877%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.