Re: Deleting and creating a model

2008-09-13 Thread Ross

I think you would either have to assign the antenna's phone:

antenna.phone = phone

or refetch the antenna from the database so Django creates the object
with the newly-created reference. The antenna you are looking at is
only coming from memory when you do antenna.phone, not from the
database. You could do it all at once like this:

antenna.phone = Phone()
antenna.save()

On Sep 14, 12:13 am, Karish <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have two models in a one-to-one relationship: Phone and Antenna.
>
> In other words, within the Phone class I have this field:
> antenna = models.OneToOneField(Antenna, related_name='phone')
>
> What I want to do, given a specific antenna, is to delete its phone
> and add a different phone:
>
> antenna.phone.delete()
> phone = Phone()
> phone.antenna = antenna
> phone.save()
>
> Problem: after these statements, antenna.phone.id is None. I was
> expecting antenna.phone to reflect the new phone, which definitely has
> an id assigned to it after the save().
>
> 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
-~--~~~~--~~--~--~---



Deleting and creating a model

2008-09-13 Thread Karish

Hi,

I have two models in a one-to-one relationship: Phone and Antenna.

In other words, within the Phone class I have this field:
antenna = models.OneToOneField(Antenna, related_name='phone')

What I want to do, given a specific antenna, is to delete its phone
and add a different phone:

antenna.phone.delete()
phone = Phone()
phone.antenna = antenna
phone.save()

Problem: after these statements, antenna.phone.id is None. I was
expecting antenna.phone to reflect the new phone, which definitely has
an id assigned to it after the save().

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: Admin: design question

2008-09-13 Thread Marc Boivin
Keith Eberle wrote:

>Maybe you can do something similar to what's in this post (using queryset):
>http://groups.google.com/
>
>
> group/django-users/browse_thread/thread/c59b3807631d2914/a07cabfb4725447d?lnk=gst=restrict+users+to+their+own+data#a07cabfb4725447d


It is valid, tested and working on Django 1.0. I have it working. It is not
documented, you need to search in the source code to get around it.

If you are to try this method, only consider this. The query set method
should look like this:

def queryset(self, request):
qs= super(Admin_Class_Of_Your_Model, self).queryset(request)
return qs.filter(user = request.user)




On 9/13/08, Gertjan Klein <[EMAIL PROTECTED]> wrote:
>
>
> Keith Eberle wrote:
>
> >Maybe you can do something similar to what's in this post (using
> queryset):
> >
> http://groups.google.com/group/django-users/browse_thread/thread/c59b3807631d2914/a07cabfb4725447d?lnk=gst=restrict+users+to+their+own+data#a07cabfb4725447d
>
>
> Is that still valid? I can find no documentation for a queryset method
> on the ModelAdmin class here:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/
>
> I added one regardless to my ProjectCodeAdmin class:
>
> class ProjectCodeAdmin(admin.ModelAdmin):
> def queryset(self, request):
> return super(ProjectCodeAdmin, self).filter(
> Customer= request.Customer)
>
> but it seems to be ignored. (I also wonder -- is this supposed to get
> called *everywhere* I need a ProjectCode dropdown? Even if there is no
> Customer on that page, and hence the request? ...)
>
> That said, placing it there feels wrong. IIUC, a site-specific admin.py
> and ModelAdmin instances are ment to tweak the admin interface. Limiting
> the list of ProjectCodes in the dropdown can be done there, but
> resticting the allowed ProjectCodes should be done in the model. Doesn't
> that mean the code now has to be written twice?
>
> My biggest worry, though, is updating the user interface if a new or
> different Customer is selected. I have seen no suggestions yet that
> admin is able to cope with that without too much intervention on my
> part... Hopefully that's because people knowing it can, and how, are
> currently busy with more important stuff like going out and having fun.
> ;)
>
>
> Regards,
> Gertjan.
>
> --
> Gertjan Klein <[EMAIL PROTECTED]>
>
>
> >
>

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



Re: 3 models need to access 1 model

2008-09-13 Thread Steve Holden

[EMAIL PROTECTED] wrote:
> OK, I'm new to Django and this is probably making a silly mistake but,
> to me the admin.site.register(Tag) line should appear at the bottom of
> the Tags model. If this is done Django will not syncdb or runserver
> because it thinks "Tag" has been registered more than once. However,
> if you put the admin.site.register(Tag) line in any of the models that
> are importing the Tags model it works fine - shows up in the admin
> correctly, and the relationship works.
> 
> Is this how it should work ?
> 
No. Your app directory should contain an admin.py module. In that you
import your models, create your admin.ModelAdmin subclasses and register
your models (with the admin.ModelAdmin subclasses as required).

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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: 3 models need to access 1 model

2008-09-13 Thread [EMAIL PROTECTED]

OK, I'm new to Django and this is probably making a silly mistake but,
to me the admin.site.register(Tag) line should appear at the bottom of
the Tags model. If this is done Django will not syncdb or runserver
because it thinks "Tag" has been registered more than once. However,
if you put the admin.site.register(Tag) line in any of the models that
are importing the Tags model it works fine - shows up in the admin
correctly, and the relationship works.

Is this how it should work ?

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: 3 models need to access 1 model

2008-09-13 Thread [EMAIL PROTECTED]

Hrm I have this working now, got lucky with a google and found a
django bug that had the info I needed to start. So am now using:

appt4.models import Tag

But am now actually experiencing the bug which is thought to be fixed.
I'm using Django 1.0: http://code.djangoproject.com/ticket/6776

Whilst on the subject of the admin interface, should
admin.autodiscover() make all models visible in the admin panel
without needing to admin.site.register ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



3 models need to access 1 model

2008-09-13 Thread [EMAIL PROTECTED]

Hello,

I have 3 apps. When records are saved to each app I want to associate
tags to the records. In order for each app to access the same tags I
think I would need a Tag app. Is it possible for models in different
apps to access models in another ?

So..

App1
class m1(models.Model):
tag = models.ManyToMany(Tag) # app4

App2
class m2(models.Model):
tag = models.ManyToMany(Tag) # app4

App3
class m3(models.Model):
tag = models.ManyToMany(Tag) # app4

App4
class Tag(models.Model):
name = models.CharField(max_length=50)

Is it possible for models to access the models in other apps ? If this
is possible, do you have any links to relevent docs or howto's on this
topic. I have been searching but couldn't find the right term to
search for.

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



Re: ORM vs SQL vs HBase

2008-09-13 Thread Russell Keith-Magee

On Sun, Sep 14, 2008 at 7:24 AM, Martin Diers <[EMAIL PROTECTED]> wrote:
>
> On Sep 6, 2008, at 11:36 AM, Posi wrote:
>>
>> Still though, how tied are we to a true relational model and how does
>> that tie to a column based DB.
>
> So utterly and completely, that if you wished to use HBase, there
> would be no possible way to integrate in into the current ORM.

This answer is utterly and completely untrue.

One of the outcomes of the recent queryset-refactor was to decouple
the SQL specific parts of the ORM from the queryset itself. Writing a
non-SQL backend for queries is now in the realm of possibility (and
during DjangoCon, I heard at least one mention of a prototype CouchDB
backend). Obviously, there will always be limitations - the concept of
'joins' on CouchDB is a little vague, for example - but basic data
queries can definitely be integrated.

To be clear - this doesn't mean "writing a CouchDB backed is a 30
minute job for a newcomer", and there aren't any tutorials on how to
do this, and if you try and it breaks you get to keep every single one
of the shiny pieces. However, it is _possible_, and I for one am
interested in seeing support for non-SQL databases in the Django
world.

Yours
Russ Magee %-)

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



Re: ORM vs SQL vs HBase

2008-09-13 Thread Martin Diers

On Sep 6, 2008, at 11:36 AM, Posi wrote:

>
> Still though, how tied are we to a true relational model and how does
> that tie to a column based DB.

So utterly and completely, that if you wished to use HBase, there  
would be no possible way to integrate in into the current ORM. In  
fact, the only logical thing to do is to use a completely different  
ORM - like Dumbo. But you would then have to write your own Admin, and  
roll your own equivalent to ModelForms.

I could see something like this happening in the context of GAE, which  
might be more analogous to HBase.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: specifying MEDIA_URL in CSS files

2008-09-13 Thread Tim Chase

> What's the best way to use MEDIA_URL in a CSS file. For example, right
> now my CSS file has something like:
> 
> body {
>   background: transparent url('/media/images/bg.gif') repeat;
> }
> 
> I would like to use MEDIA_URL instead of /media/ (in a number of
> places), but other than that the file is static. What's the best way
> to do this? Should I templatize the whole thing? What type of a
> performance change will I see (approximately)?

This changes your CSS file from being static to being dynamic. 
As such, Django should serve the file.  However, as it's not 
something you'd expect to change often, Django's caching 
framework (making use of, say, memcached) may prove enormously 
helpful.  Alternatively, you might be able to hook into the 
post_syncdb signal, and use it to write/put the render the 
dynamic CSS file into a static CSS file on the static-media server.

Just a few ideas,

-tim







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



Re: specifying MEDIA_URL in CSS files

2008-09-13 Thread Erik Allik

You should instead simply use relative URLs to images in CSS files.  
Style sheets and images are (normally) always at the same location  
relative to each other so nothing will break if you change their  
location. Of course if your images are in a different domain than your  
style sheets, that's another case.

Erik


On 14.09.2008, at 1:56, MrJogo wrote:

>
> What's the best way to use MEDIA_URL in a CSS file. For example, right
> now my CSS file has something like:
>
> body {
>  background: transparent url('/media/images/bg.gif') repeat;
> }
>
> I would like to use MEDIA_URL instead of /media/ (in a number of
> places), but other than that the file is static. What's the best way
> to do this? Should I templatize the whole thing? What type of a
> performance change will I see (approximately)?
>
> 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
-~--~~~~--~~--~--~---



specifying MEDIA_URL in CSS files

2008-09-13 Thread MrJogo

What's the best way to use MEDIA_URL in a CSS file. For example, right
now my CSS file has something like:

body {
  background: transparent url('/media/images/bg.gif') repeat;
}

I would like to use MEDIA_URL instead of /media/ (in a number of
places), but other than that the file is static. What's the best way
to do this? Should I templatize the whole thing? What type of a
performance change will I see (approximately)?

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: Template problem with dates(field, kind, order='ASC')

2008-09-13 Thread djandrow

Sorry, must have forgotton that part, it just wasn't displaying
anything,
its was cos I was archive.datetime, when archive was already a dateime
object.

Now I've changed it to {{ archive }} its fine.

Thanks guys,

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



Re: Problems with tutorial part 2

2008-09-13 Thread Neil

Thanks for the quick reply.

I reinstalled Django using 'python setup.py install' and the problem
has disappeared.  Previously I installed Django by running 'python
setup.py build' and then manually copying the Django directory created
under the build/ directory to another directory in my Python path (not
the usual site-packages/). That must have been causing the problem.

On Sep 9, 12:17 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 8, 2008 at 6:29 PM, Neil Crighton <[EMAIL PROTECTED]>wrote:
>
>
>
>
>
> > Hi,
>
> > I'm working my way through the tutorial with version 1.0. I've just
> > started on part 2.  When I try to visit the admin site, I get a huge
> > page of text starting with:
>
> > TemplateDoesNotExist at /admin/
>
> > admin/login.html
>
> > Request Method:         GET
> > Request URL:    http://127.0.0.1:8000/admin/
> > Exception Type:         TemplateDoesNotExist
>
> > What am I doing wrong?  I've done everything I was told to do i the
> > tutorial before visitinghttp://127.0.0.1:8000/admin/.
>
> A little more of the error would have been helpful, specifically the
> template loader post-mortem that showed where the template loader had looked
> for the file.  Without that I do not know if you are hitting an old
> installation problem I thought had been fixed (template files not
> installed), or missed doing part of the tutorial (including admin in
> installed apps?). If it's the former details on what OS you are running on
> and how, exactly, you installed Django would be helpful.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template problem with dates(field, kind, order='ASC')

2008-09-13 Thread Daniel Roseman

On Sep 13, 10:49 pm, djandrow <[EMAIL PROTECTED]> wrote:
> This is probably really really obvious. I have the following statement
> in my views.py:
>
> archive_list = Entry.objects.dates('entry_date', 'month',
> order='DESC')
>
> then I have;
>
> {% for archive in archive_list %}
>
> {{ archive.datetime }}
>
> {% endfor %}
>
> in my template, i am 99.9% my problem is with {{ archive.datetime }}.
>
> Any help would be much appreciated,
>
> Andrew

You don't state what the actual problem is. One thing I can see is
that each value for 'archive' will be an instance of
datetime.datetime, so calling datetime on it again doesn't make any
sense. Are you trying to format the output? If so, use the 'date'
filter.

For example:
{% for archive in archive_list %}
{{ archive|date:"m Y" }}
{% endfor %}
... which will give you a list in the format "Jan 2008 Feb 2008 Mar
2008" etc.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template problem with dates(field, kind, order='ASC')

2008-09-13 Thread Matthias Kestenholz

On Sat, Sep 13, 2008 at 11:49 PM, djandrow <[EMAIL PROTECTED]> wrote:
>
> This is probably really really obvious. I have the following statement
> in my views.py:
>
> archive_list = Entry.objects.dates('entry_date', 'month',
> order='DESC')
>
> then I have;
>
> {% for archive in archive_list %}
>
> {{ archive.datetime }}
>
> {% endfor %}
>
> in my template, i am 99.9% my problem is with {{ archive.datetime }}.
>
> Any help would be much appreciated,
>

It would be helpful if you'd include what went wrong or what did not
match your expectations.

Matthias

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



Template problem with dates(field, kind, order='ASC')

2008-09-13 Thread djandrow

This is probably really really obvious. I have the following statement
in my views.py:

archive_list = Entry.objects.dates('entry_date', 'month',
order='DESC')

then I have;

{% for archive in archive_list %}

{{ archive.datetime }}

{% endfor %}

in my template, i am 99.9% my problem is with {{ archive.datetime }}.

Any help would be much appreciated,

Andrew
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Import error: Model based on another model

2008-09-13 Thread Daniel Roseman

On Sep 13, 10:56 am, Gerard Petersen <[EMAIL PROTECTED]> wrote:
> Daniel,
>
> > If you want a field that's populated with values from another model,
> > you should use a ForeignKey.
>
> Is it then still possible to use filters and such, and keep it in the model 
> logic?
>
> Because the Meta model has these fields: 'attribute', 'value', 'display', 
> 'description'
>
> And it's more like a lookup then a real relation between the models Order and 
> Meta.


I can't really understand what you're asking here, I'm afraid. Maybe
you could post your models code (preferably on dpaste.com) along with
some indication of what you're trying to do.
--
DR.

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



Re: Database Security

2008-09-13 Thread Sander Steffann

Hi Mario,

> DATABASE_HOST ="http://192.168.1.128;

DATABASE_HOST must contain a hostname or IP address, not an URL. You  
should remove the "http://; part and check that the IP address is  
correct and reachable.

- Sander


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: flatpage -- content type?

2008-09-13 Thread Matthias Kestenholz

On Sat, Sep 13, 2008 at 11:12 PM, shaunc <[EMAIL PROTECTED]> wrote:
>
> umm... but that's not exactly according to "D.R.Y." :) -- but thanks.
>

It's good to try to follow DRY, but it's not the solution for everything. Django
is a tool box, not a CMS with everything included. Sometimes it's better to
write a few lines of code instead of trying to add more knobs and configurables
to existing code... remember, "Do one thing, and do it well" instead of "Try
doing 1000 things, but still fail at most of them."


Matthias

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: flatpage -- content type?

2008-09-13 Thread shaunc

umm... but that's not exactly according to "D.R.Y." :) -- but thanks.

On Sep 13, 3:36 pm, "Matthias Kestenholz" <[EMAIL PROTECTED]> wrote:
> On Sat, Sep 13, 2008 at 9:33 PM, shaunc <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > Does anyone know how to set the content type when serving a page via
> > FlatPages?
>
> You have to write your own middleware or view function. This is
> easy enough since you can copy the flatpages view and middleware
> code and modify it for your needs.
>
> Matthias
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Making sure published date is respected in views

2008-09-13 Thread Keith Eberle
Building on Marcelo's response, and an example from James Bennett's book (Ch
5), you could also add a custom manager.  It'd go something like this:

class PublishedEntryManager(models.Manager):
  def get_query_set(self):
return super(PublishedEntryManager,
self).get_query_set().filter(pub_date__lte=datetime.now())

class Entry(models.Model)
  title = ...etc...
  content = ...etc...
  objects = models.Manager()
  published = PublishedEntryManager

Entry.published.all() will return a queryset of all published Entries.

keith


On Fri, Sep 12, 2008 at 3:12 AM, Marcelo Ramos <[EMAIL PROTECTED]> wrote:

>
> 2008/9/12 Dana <[EMAIL PROTECTED]>:
> >
> > Hey all,
> >
> > Wondering what the best technique would be to make sure that an entry
> > (such as a blog entry/story/etc...) with a datetime object 'pub_date'
> > does not show up on the front end if the pub_date is in the future. I
> > would assume using ".filter(...something...)" is the way to go but
> > what would be the best filter to apply? Any other ways to achieve
> > this?
>
> Yes, a filter is a good option. For example:
>
> from datetime import datetime
>
> .objects.filter(pub_date__lte=datetime.now())
>
> Regards.
>
> --
> Marcelo Ramos
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: flatpage -- content type?

2008-09-13 Thread Matthias Kestenholz

On Sat, Sep 13, 2008 at 9:33 PM, shaunc <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> Does anyone know how to set the content type when serving a page via
> FlatPages?
>

You have to write your own middleware or view function. This is
easy enough since you can copy the flatpages view and middleware
code and modify it for your needs.

Matthias

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



flatpage -- content type?

2008-09-13 Thread shaunc

Hello,

Does anyone know how to set the content type when serving a page via
FlatPages?

Thanks,

- Shaun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: akismet and the new comments app

2008-09-13 Thread Eric Abrahamsen

On Sep 13, 2008, at 12:46 PM, Thejaswi Puthraya wrote:

>
> On Sep 12, 7:09 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>> Has anyone tried using akismet with the new comments contrib app?  
>> I've
>> set up a signal handler to run on 'comment_will_be_posted' and check
>> the comment with akismet, and the service is insisting my test
>> comments are spam no matter what. I'm using the voidspace python
>> akismet API, and largely copying out of the comment_utils app.
>
> http://www.djangosnippets.org/snippets/1006/

Excellent! I should have known/googled. Thanks for the pointer, that  
implementation works nicely.

Eric

>
>
>>
>> I've noticed that setting build_data=True in the comment_check call
>> doesn't seem to work: that's supposed to draw values out of
>> os.environ, but it looks like those values aren't available (it
>> complains if I don't explicitly pass them in). I'm adding them
>> manually out of request.META, but the test is still coming back
>> negative. You don't get much more than 'bad!' out of Akismet, so  
>> I'm a
>> little stumped.
>>
>> Has anyone done this yet? Is there any reason why the appropriate
>> environment values would not be available during the
>> 'comment_will_be_posted' signal stage, or there might be some other
>> settings floating around that are poisoning the whole thing? Sorry if
>> this is an unhelpful request for help, mostly I want to know if
>> anyone's been down this road yet.
>>
>> Thanks,
>> Eric
>
> --
> Cheers
> Thejaswi Puthraya
> >


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



Re: Database Security

2008-09-13 Thread Steve Holden

Mario wrote:
[some stuff which I have again moved to the bottom where it belongs]
> On Sep 13, 12:46 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>> Ross wrote:
>> [some stuff you can now find after the question]
>>> On Sep 13, 9:37 am, Mario <[EMAIL PROTECTED]> wrote:
 Hello,
 I would like to move off the existing database server off Django.
 Currently, my settings.py file include the following configuration:
>> DATABASE_USER = 'dbadmin'
 DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
 DATABASE_NAME = 'golf_prod'   # Or path to database
 file if using sqlite3.
 DATABASE_USER = 'dbadmin'   # Not used with sqlite3.
 DATABASE_PASSWORD = 'x' # Not used with sqlite3.
 DATABASE_HOST = '' # Set to empty string
 for localhost. Not used with sqlite3.
 DATABASE_PORT = '' # Set to empty string
 for default. Not used with sqlite3.
 Question – I need to move the Mysql Server off our  DMZ and into our
 protected internal network. Can I simply point the URL in the
 DATABASE_HOST . Any suggestions or recommendations?
>> and Ross said
>>
>> http://docs.djangoproject.com/en/dev/ref/databases/#connecting-to-the...
>>
>>
>>
>>> Putting your database in the DMZ is probably a very bad idea... You
>>> don't want to give the entire internet access to your database. The
>>> standard Django setup expects your database to be accessible on the
>>> same local network as your Django app. Other than that, there is no
>>> special setup.
>> While putting your database in the DMZ *is* a bad idea, there's nothing
>> in the standard Django setup that requires it to *be* anywhere special.
>> As Ross points out, as long as it can be contacted by name, or by IP
>> address, it's perfectly OK for it to be the other side of a firewall,
>> for example.
>>
>> I sometimes run Django code on my laptop against the database I use to
>> support my public web site, though in that case I have taken the
>> additional precaution of having the database require a digital
>> certificate before it allows access. That's PostgreSQL, so I couldn't
>> quote you the mechanics you'd need to do the same on MySQL.
>>
and Mario replied:
> Thank you for responding so quickly, but the question hasn't been
> answered.
> Assuming there are firewalls layered between the DMZ and the private
> network and the routing table has been setup correctly;
> what do I need to do to forward the http request to my remote
> database.
>
The Django server handles the HTTP request. No HTTP goes to the MySQL
server - an entirely separate protocol is used between the web server
and the database server.

So, if you have firewalls between the two, you need to ensure that the
web (Django) server host can make a connection to the MySQL port on the
database server (which is 3306 by default).

> Do I modify my settings.py to include the following:
>
> FROMTO:
>
> DATABASE_ENGINE = 'mysql' ---> DATABASE_ENGINE = 'mysql'
> DATABASE_NAME = 'golf_prod'  >DATABASE_NAME = 'golf_prod'
> DATABASE_USER = 'dbadmin'   ->DATABASE_USER = 'dbadmin'
> DATABASE_PASSWORD = ''  -->DATABASE_PASSWORD = ''
> DATABASE_HOST = ''  >DATABASE_HOST ="http://
> 192.168.1.128"
> DATABASE_PORT = ''  >DATABASE_PORT = "3306"
>
You will need to change the DATABASE_HOST setting if the new database it
at a different IP address fro the one you are using now (which it almost
certainly will be).

The other settings should be perfectly OK as they are.

> What I am looking for is the appropriate configurations/syntax to
> connect to a remote database. Do I assume the MySQL driver and APIS
> for Django will take care of the database connectivity or do I need to
> modify the my.cnf file in MySQL. Also, do  I need to make changes in
> my Apache httpd.conf file as well?
>
Obviously there'll be an entirely different my.cnf file on the new
database server, so I can't give you any advice on that. The Apache
server has nothing to do with communications between Django and MySQl,
so if it's working now just leave it as it is.

Unless Apache has been configures to use other MySQL services, of
course, which you *can* do, but presumably you would know if that were
the case.

regards
 Steve

A: Because it puts information in the wrong order
Q: What's wrong with top-posting?
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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 

Re: When to start an app?

2008-09-13 Thread barbara shaurette

Yep, you'll have some overlap, but I think it makes sense to create a
separate app wherever the data model/views could logically stand
alone.   So, user registration would be one app.  I'm working on a
project that does a lot with demographic data based on user profiles,
so profiles is another separate app, but both import the User object.
And then your survey mechanism would be yet another app, and so on and
so on.

On Sep 13, 10:39 am, mickeyckm <[EMAIL PROTECTED]> wrote:
> I'm a little confuse as to when to create an app.
>
> I'm trying to create a survey project. Is user registration an app on
> its own, the part where the person login/register?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database Security

2008-09-13 Thread Mario

Thank you for responding so quickly, but the question hasn't been
answered.
Assuming there are firewalls layered between the DMZ and the private
network and the routing table has been setup correctly;
what do I need to do to forward the http request to my remote
database.

Do I modify my settings.py to include the following:

FROMTO:

DATABASE_ENGINE = 'mysql' ---> DATABASE_ENGINE = 'mysql'
DATABASE_NAME = 'golf_prod'  >DATABASE_NAME = 'golf_prod'
DATABASE_USER = 'dbadmin'   ->DATABASE_USER = 'dbadmin'
DATABASE_PASSWORD = ''  -->DATABASE_PASSWORD = ''
DATABASE_HOST = ''  >DATABASE_HOST ="http://
192.168.1.128"
DATABASE_PORT = ''  >DATABASE_PORT = "3306"

What I am looking for is the appropriate configurations/syntax to
connect to a remote database. Do I assume the MySQL driver and APIS
for Django will take care of the database connectivity or do I need to
modify the my.cnf file in MySQL. Also, do  I need to make changes in
my Apache httpd.conf file as well?

Thank you again.

_Mario



On Sep 13, 12:46 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Ross wrote:
>
> [some stuff you can now find after the question]
>
>
>
> > On Sep 13, 9:37 am, Mario <[EMAIL PROTECTED]> wrote:
> >> Hello,
>
> >> I would like to move off the existing database server off Django.
> >> Currently, my settings.py file include the following configuration:
> DATABASE_USER = 'dbadmin'
> >> DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
> >> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>
> >> DATABASE_NAME = 'golf_prod'   # Or path to database
> >> file if using sqlite3.
>
> >> DATABASE_USER = 'dbadmin'   # Not used with sqlite3.
>
> >> DATABASE_PASSWORD = 'x' # Not used with sqlite3.
>
> >> DATABASE_HOST = '' # Set to empty string
> >> for localhost. Not used with sqlite3.
>
> >> DATABASE_PORT = '' # Set to empty string
> >> for default. Not used with sqlite3.
>
> >> Question – I need to move the Mysql Server off our  DMZ and into our
> >> protected internal network. Can I simply point the URL in the
> >> DATABASE_HOST . Any suggestions or recommendations?
>
> and Ross said
>
> http://docs.djangoproject.com/en/dev/ref/databases/#connecting-to-the...
>
>
>
> > Putting your database in the DMZ is probably a very bad idea... You
> > don't want to give the entire internet access to your database. The
> > standard Django setup expects your database to be accessible on the
> > same local network as your Django app. Other than that, there is no
> > special setup.
>
> While putting your database in the DMZ *is* a bad idea, there's nothing
> in the standard Django setup that requires it to *be* anywhere special.
> As Ross points out, as long as it can be contacted by name, or by IP
> address, it's perfectly OK for it to be the other side of a firewall,
> for example.
>
> I sometimes run Django code on my laptop against the database I use to
> support my public web site, though in that case I have taken the
> additional precaution of having the database require a digital
> certificate before it allows access. That's PostgreSQL, so I couldn't
> quote you the mechanics you'd need to do the same on MySQL.
>
> regards
>  Steve
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC  http://www.holdenweb.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
-~--~~~~--~~--~--~---



When to start an app?

2008-09-13 Thread mickeyckm

I'm a little confuse as to when to create an app.

I'm trying to create a survey project. Is user registration an app on
its own, the part where the person login/register?




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



Re: Admin: design question

2008-09-13 Thread Gertjan Klein

Keith Eberle wrote:

>Maybe you can do something similar to what's in this post (using queryset):
>http://groups.google.com/group/django-users/browse_thread/thread/c59b3807631d2914/a07cabfb4725447d?lnk=gst=restrict+users+to+their+own+data#a07cabfb4725447d

Is that still valid? I can find no documentation for a queryset method
on the ModelAdmin class here:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/

I added one regardless to my ProjectCodeAdmin class:

class ProjectCodeAdmin(admin.ModelAdmin):
def queryset(self, request):
return super(ProjectCodeAdmin, self).filter(
Customer= request.Customer) 

but it seems to be ignored. (I also wonder -- is this supposed to get
called *everywhere* I need a ProjectCode dropdown? Even if there is no
Customer on that page, and hence the request? ...)

That said, placing it there feels wrong. IIUC, a site-specific admin.py
and ModelAdmin instances are ment to tweak the admin interface. Limiting
the list of ProjectCodes in the dropdown can be done there, but
resticting the allowed ProjectCodes should be done in the model. Doesn't
that mean the code now has to be written twice?

My biggest worry, though, is updating the user interface if a new or
different Customer is selected. I have seen no suggestions yet that
admin is able to cope with that without too much intervention on my
part... Hopefully that's because people knowing it can, and how, are
currently busy with more important stuff like going out and having fun.
;)

Regards,
Gertjan.

-- 
Gertjan Klein <[EMAIL PROTECTED]>


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



Re: Database Security

2008-09-13 Thread Steve Holden

Ross wrote:
[some stuff you can now find after the question]
> On Sep 13, 9:37 am, Mario <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> I would like to move off the existing database server off Django.
>> Currently, my settings.py file include the following configuration:
>>
>> DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
>> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>>
>> DATABASE_NAME = 'golf_prod'   # Or path to database
>> file if using sqlite3.
>>
>> DATABASE_USER = 'dbadmin'   # Not used with sqlite3.
>>
>> DATABASE_PASSWORD = 'x' # Not used with sqlite3.
>>
>> DATABASE_HOST = '' # Set to empty string
>> for localhost. Not used with sqlite3.
>>
>> DATABASE_PORT = '' # Set to empty string
>> for default. Not used with sqlite3.
>>
>> Question – I need to move the Mysql Server off our  DMZ and into our
>> protected internal network. Can I simply point the URL in the
>> DATABASE_HOST . Any suggestions or recommendations?

and Ross said
>
http://docs.djangoproject.com/en/dev/ref/databases/#connecting-to-the-database
>
> Putting your database in the DMZ is probably a very bad idea... You
> don't want to give the entire internet access to your database. The
> standard Django setup expects your database to be accessible on the
> same local network as your Django app. Other than that, there is no
> special setup.
>

While putting your database in the DMZ *is* a bad idea, there's nothing
in the standard Django setup that requires it to *be* anywhere special.
As Ross points out, as long as it can be contacted by name, or by IP
address, it's perfectly OK for it to be the other side of a firewall,
for example.

I sometimes run Django code on my laptop against the database I use to
support my public web site, though in that case I have taken the
additional precaution of having the database require a digital
certificate before it allows access. That's PostgreSQL, so I couldn't
quote you the mechanics you'd need to do the same on MySQL.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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: Database Security

2008-09-13 Thread Ross

http://docs.djangoproject.com/en/dev/ref/databases/#connecting-to-the-database

Putting your database in the DMZ is probably a very bad idea... You
don't want to give the entire internet access to your database. The
standard Django setup expects your database to be accessible on the
same local network as your Django app. Other than that, there is no
special setup.

On Sep 13, 9:37 am, Mario <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I would like to move off the existing database server off Django.
> Currently, my settings.py file include the following configuration:
>
> DATABASE_ENGINE = 'mysql'               # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>
> DATABASE_NAME = 'golf_prod'                   # Or path to database
> file if using sqlite3.
>
> DATABASE_USER = 'dbadmin'               # Not used with sqlite3.
>
> DATABASE_PASSWORD = 'x'         # Not used with sqlite3.
>
> DATABASE_HOST = ''                             # Set to empty string
> for localhost. Not used with sqlite3.
>
> DATABASE_PORT = ''                             # Set to empty string
> for default. Not used with sqlite3.
>
> Question – I need to move the Mysql Server off our  DMZ and into our
> protected internal network. Can I simply point the URL in the
> DATABASE_HOST . Any suggestions or recommendations?
>
> V/R
>
> _Mario
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



presenting my new blog

2008-09-13 Thread Vikti
Hi,

finally I decided to (re)start blogging. As it's django based (actually runs
on byteflow) I thought I will present it here.

Besides django - as it was already told - I use byteflow [1], plus
django-contact-form [2] and my own postimage [1] app.

If you are interested in posts on standard setting, economics and my django
experiences you can meet me at http://viktornagy.com

Hope you will like it!
V

[1] http://byteflow.su/
[2] http://code.google.com/p/django-contact-form/
[2] http://code.google.com/p/django-postimage/

-- 
Viktor Nagy - viktornagy.com
Phd Student
Toulouse School of Economics

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 prevent URL HTML encoding?

2008-09-13 Thread Ross

That will definitely do the trick, but the idea of APPEND_SLASH from
what I understand is 'http://www.last.fm/music/Goo+Goo+Dolls/' and
'http://www.last.fm/music/Goo+Goo+Dolls' (with and without the
trailing slash) are considered different URLs. Appending the slash
normalizes all your URLs to always include a trailing slash, which
correctly routes search engines to the same page.

I am only writing a small internal app, so search engine optimization
is not a concern. However, if my app were public, I would want to make
APPEND_SLASH work for me.

Karen, thanks for all the help by the way! I am going to go with the
optional slash in my regexs to get around APPEND_SLASH.

On  Sep 13, 1:25 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sat, Sep 13, 2008 at 1:36 AM, Ross <[EMAIL PROTECTED]> wrote:
>
> > The URL encoding is not causing any problems in my code. Splitting the
> > parameter on '+' works the same whether the address is 'Goo+Goo+Dolls'
> > or 'Goo%2BGoo%2BDolls'.
>
> > I can certainly add additional expressions to catch URLs with and
> > without the trailing slash, I was just hoping there was an option to
> > do just that.
>
> Change your pattern from:
>
> r'^djangoproject/search/(?P[\w\+]+)/$'
>
> to:
>
> r'^djangoproject/search/(?P[\w\+]+)/?$'
>
> The question mark makes the trailing slash optional -- pattern will match a
> url with 0 or 1 trailing slashes.
>
> Karen
>
>
>
> > On Sep 12, 10:15 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > On Fri, Sep 12, 2008 at 6:06 PM, Ross <[EMAIL PROTECTED]> wrote:
>
> > > > The problem is it looks bad! It makes the URL unreadable, which is
> > > > what I want to prevent. For example, last.fm uses '+' symbols to
> > > > separate band names.
>
> > > >http://www.last.fm/music/Goo+Goo+Dollsprettyobviously takes you to
> > > > the page for the band "Goo Goo Dolls".
>
> > > >http://www.last.fm/music/Goo%2BGoo%2BDolls, however, is far tougher to
> > > > pick apart by a human reader.
>
> > > > My short answer is I want to keep my URLs human readable.
>
> > > OK, so you are not actually seeing a code problem in your
> > dispatching/views
> > > resulting from this?  That is what I was trying to determine: whether
> > your
> > > code had to adapt to things coming in percent-encoded, because I didn't
> > > think it should, and if it did, I'd want to track down why.
>
> > > If you just don't like how it looks in the browser address bar, then
> > simply
> > > avoid having it happen.  Specify your url regex expressions so that the
> > > trailing slash is optional, that way APPEND_SLASH never has to get
> > involved
> > > and issue the redirect. Wouldn't that be easier than trying to change how
> > > APPEND_SLASH works?
>
> > > Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template.render and custom tags

2008-09-13 Thread Julien Phalip

You might want to give a shot with 'add_to_builtins':
http://blog.michaeltrier.com/2007/8/7/common-template-tags

On Sep 13, 11:05 am, akonsu <[EMAIL PROTECTED]> wrote:
> hello,
>
> is there a way to make my custom tags and filters available to a
> template that i create from a string like this:
>
> template = Template(string)
> template.render(context)
>
> i know that i can use the "load" tag in the template, but suppose that
> the strings that i create templates from do not have the load tag and
> i have no way to change that. i can of course do
>
> template = Template('{% load mytags %}' + string)
>
> but is there a better way?
>
> thanks
> konstantin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin: design question

2008-09-13 Thread Keith Eberle
Maybe you can do something similar to what's in this post (using queryset):
http://groups.google.com/group/django-users/browse_thread/thread/c59b3807631d2914/a07cabfb4725447d?lnk=gst=restrict+users+to+their+own+data#a07cabfb4725447d

keith


On Sat, Sep 13, 2008 at 10:30 AM, Gertjan Klein <[EMAIL PROTECTED]> wrote:

>
> Steve Holden wrote:
>
> >Gertjan Klein wrote:
> >> However, there is one obvious problem
> >> here: when editing an Hours instance, the ProjectCode dropdown lists
> >> *all* project codes, not just those related to the selected customer.
>
> >As long as you only want this in th admin, check out the
> >"ForeignKey.limit_choices_to" attribute. However, I don't know whether
> >this would give you the correct results where no project code was
> >specified, and I'm not sure how to do this in general applications yet.
>
> Thanks. I have just tried that, but failed. In the model, I don't know
> how to specify that the result should be limited to an attribute of the
> instance (e.g., something like self.Customer.id), as there is no self at
> that point. This may very well be my lack of understanding, I'm just
> starting with Django.
>
> However, that would still only help with saved instances; when creating
> a new Hours entry, the Customer value will be empty, so the dropdown
> with appropriate ProjectCodes would be too.
>
> So the question remains whether the django admin code helps make this
> possible...
>
> Regards,
> Gertjan.
>
> --
> Gertjan Klein <[EMAIL PROTECTED]>
>
>
> >
>

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



Re: Help: Running 1.0 and 0.96 side by side?

2008-09-13 Thread Matt Conrad

On Fri, Sep 12, 2008 at 1:58 PM, Kevin Teague <[EMAIL PROTECTED]> wrote:

> Finally, you could patch a Python program such as manage.py so that
> you do something like:
>
> import sys
> sys.path[0:0] = [
>  '\somelocation-for-django-1.0\',
>  ]
> import django
>
> This would pick up your Django 1.0 install explicitly without relying
> on setting the PYTHONPATH (since setting the PYTHONPATH can effect
> imports for any Python program run under a user account). Of course,
> hand-patching your Python scripts in this manner is incredibly lame,

I'm a beginner, lame is OK as long as I'm learning.  :)

Matt

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



Re: how to use never_cache?

2008-09-13 Thread V


> > Rather than suspecting caching, I'd suspect you've got code running at
> > import time instead of form instantiation time that is determining the file
> > list.  You did not include the form definition, though, in what you showed
> > us, so it's hard to be sure.

Perfect pointer Karen, with your help I was able to make it working
properly. Thanks!

V

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



Database Security

2008-09-13 Thread Mario

Hello,

I would like to move off the existing database server off Django.
Currently, my settings.py file include the following configuration:

DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.

DATABASE_NAME = 'golf_prod'   # Or path to database
file if using sqlite3.

DATABASE_USER = 'dbadmin'   # Not used with sqlite3.

DATABASE_PASSWORD = 'x' # Not used with sqlite3.

DATABASE_HOST = '' # Set to empty string
for localhost. Not used with sqlite3.

DATABASE_PORT = '' # Set to empty string
for default. Not used with sqlite3.


Question – I need to move the Mysql Server off our  DMZ and into our
protected internal network. Can I simply point the URL in the
DATABASE_HOST . Any suggestions or recommendations?

V/R

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



Re: Admin: design question

2008-09-13 Thread Gertjan Klein

Steve Holden wrote:

>Gertjan Klein wrote:
>> However, there is one obvious problem
>> here: when editing an Hours instance, the ProjectCode dropdown lists
>> *all* project codes, not just those related to the selected customer.

>As long as you only want this in th admin, check out the
>"ForeignKey.limit_choices_to" attribute. However, I don't know whether
>this would give you the correct results where no project code was
>specified, and I'm not sure how to do this in general applications yet.

Thanks. I have just tried that, but failed. In the model, I don't know
how to specify that the result should be limited to an attribute of the
instance (e.g., something like self.Customer.id), as there is no self at
that point. This may very well be my lack of understanding, I'm just
starting with Django.

However, that would still only help with saved instances; when creating
a new Hours entry, the Customer value will be empty, so the dropdown
with appropriate ProjectCodes would be too.

So the question remains whether the django admin code helps make this
possible...

Regards,
Gertjan.

-- 
Gertjan Klein <[EMAIL PROTECTED]>


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



Re: Map API's and Django, preferences?

2008-09-13 Thread TiNo
I wanted to do the same. I decided not to user GIS because of all the new
stuff I needed to install. Two Coordinates are good enough for the google
maps api.
I plan on using geopy (http://exogen.case.edu/projects/geopy/) for
translating addresses to coordinates.

I also found these articles that should help you in the right direction:
http://www.developer.com/java/web/article.php/10935_3528381
http://ajaxian.com/archives/geocoding-with-googles-maps-api
http://www.instantdjango.com/chapter1.html

Good luck, and please backpost when you build a cool app!

TiNo

On Sat, Sep 13, 2008 at 3:02 AM, chiggsy <[EMAIL PROTECTED]> wrote:

>
> I'm working on a little idea.  I need to display data on a map.  Now,
> I have been reading over the gis stuff in django, I've set up
> PostGIS , and now i'm trying to work out how do display the data.
> What are some opinons on Google maps vs yahoo maps, for ease of django
> development ? (I am brand new to this, so if i missed a handy map api
> pls lmk)
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 generic views (monthly archive) and different languages

2008-09-13 Thread Nathan Dabney
URL keyed off of numeric month instead of localized name.
-Nathan


On Sat, Sep 13, 2008 at 6:02 AM, Julian <[EMAIL PROTECTED]> wrote:

>
> hi there,
>
> in my settings.py there is the language specified as "de_de", wich
> works well with things like:
>
> {{{
> blog_entry.timestamp|date:"b"
> }}}
>
> in may, it returns "Mai", wich is german for may.
>
> but i am using the generic views for my blog archive, and monthly
> based i'm doing things like:
>
> {{{
>  month=previous_month|date:"b"|lower %}">Vorheriger Monat
> }}}
>
> but i receiven an url like:
>
> blog/2008/mai/
>
> wich turns into an 404 error page, because in this case it should be
> blog/2008/may
>
> what's a solution for my 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?hl=en
-~--~~~~--~~--~--~---



problem with generic views (monthly archive) and different languages

2008-09-13 Thread Julian

hi there,

in my settings.py there is the language specified as "de_de", wich
works well with things like:

{{{
blog_entry.timestamp|date:"b"
}}}

in may, it returns "Mai", wich is german for may.

but i am using the generic views for my blog archive, and monthly
based i'm doing things like:

{{{
Vorheriger Monat
}}}

but i receiven an url like:

blog/2008/mai/

wich turns into an 404 error page, because in this case it should be
blog/2008/may

what's a solution for my 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?hl=en
-~--~~~~--~~--~--~---



Re: Admin: design question

2008-09-13 Thread Steve Holden

Gertjan Klein wrote:
> Hi,
> 
> I am writing a timekeeping app with Django, and have some design
> questions. Stripped down, I have a model somewhat like this:
> 
> class Customer(models.Model):
> Name = models.CharField(max_length=200)
> 
> class ProjectCode(models.Model):
> Customer = models.ForeignKey('Customer')
> Code = models.CharField(max_length=30)
> 
> class Hours(models.Model):
> Customer = models.ForeignKey('Customer')
> ProjectCode = models.ForeignKey('ProjectCode', blank=True)
> Date = models.DateField()
> Hours = models.FloatField()
> 
> That is, the time registration class (Hours) has both a customer, and
> (optionally) a project code.
> 
> I am currently using the standard admin interface to enter/edit objects,
> and it works to my expectations. However, there is one obvious problem
> here: when editing an Hours instance, the ProjectCode dropdown lists
> *all* project codes, not just those related to the selected customer.
> 
> Obviously, I am going to need either a wizard-like interface or an Ajax
> solution to fix this. My preference here would be Ajax (to populate the
> ProjectCode dropdown based on the selected Customer).
> 
> My question is twofold:
> 
> - Does the standard admin application have provisions for something like
> this?
> 
> - Alternatively, is there a change in my design I can make so the admin
> interface *can* cope with this?
> 
> I'd really prefer to keep using the standard admin for now, focussing on
> adding functionality rather than getting the user interface the way I
> want it.
> 
Gertjan:

As long as you only want this in th admin, check out the
"ForeignKey.limit_choices_to" attribute. However, I don't know whether
this would give you the correct results where no project code was
specified, and I'm not sure how to do this in general applications yet.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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: Using models from another project/site

2008-09-13 Thread Donn

You are some kind of wonderful. Thanks for that, it has really helped me!

\d

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Import error: Model based on another model

2008-09-13 Thread Steve Holden

Gerard Petersen wrote:
> Daniel,
> 
>> If you want a field that's populated with values from another model,
>> you should use a ForeignKey.
> Is it then still possible to use filters and such, and keep it in the model 
> logic?
> 
> Because the Meta model has these fields: 'attribute', 'value', 'display', 
> 'description'
> 
> And it's more like a lookup then a real relation between the models Order and 
> Meta.
> 
>> Also, it's not a good idea to use Meta as the name of a model - that's
>> bound to get confused with the inner Meta class which defines model
>> meta-attributes like ordering.
> Thanx for the tip. I already saw this one coming ... ;-)

I would like to ask a similar but slightly more specific question.

An Oracle database I use keeps lookup data in a Lookups table with three
columns, to avoid many small tables (I assume). A Django model would be
something like (untested pseudo-code):

class Types(model.model):
lktName = models.CharField(max_length=50)

class Lookups(models.Model):
lkpType = models.ForeignKey(Types)
lkpValue = models.CharField(max_length=50)

So I'd like to be able to populate drop-downs with (id, lkpValue) pairs
for a given value of lkpType. The related tables might use a ForeignKey,
but I certainly don't want to see all Lookups in a selection, just those
of the relevant type.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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
-~--~~~~--~~--~--~---



Admin: design question

2008-09-13 Thread Gertjan Klein

Hi,

I am writing a timekeeping app with Django, and have some design
questions. Stripped down, I have a model somewhat like this:

class Customer(models.Model):
Name = models.CharField(max_length=200)

class ProjectCode(models.Model):
Customer = models.ForeignKey('Customer')
Code = models.CharField(max_length=30)

class Hours(models.Model):
Customer = models.ForeignKey('Customer')
ProjectCode = models.ForeignKey('ProjectCode', blank=True)
Date = models.DateField()
Hours = models.FloatField()

That is, the time registration class (Hours) has both a customer, and
(optionally) a project code.

I am currently using the standard admin interface to enter/edit objects,
and it works to my expectations. However, there is one obvious problem
here: when editing an Hours instance, the ProjectCode dropdown lists
*all* project codes, not just those related to the selected customer.

Obviously, I am going to need either a wizard-like interface or an Ajax
solution to fix this. My preference here would be Ajax (to populate the
ProjectCode dropdown based on the selected Customer).

My question is twofold:

- Does the standard admin application have provisions for something like
this?

- Alternatively, is there a change in my design I can make so the admin
interface *can* cope with this?

I'd really prefer to keep using the standard admin for now, focussing on
adding functionality rather than getting the user interface the way I
want it.

Regards,
Gertjan.


-- 
Gertjan Klein <[EMAIL PROTECTED]>


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



Re: migration problem from Django0.96 to Django1.0

2008-09-13 Thread Karen Tracey
On Sat, Sep 13, 2008 at 5:28 AM, vijay <[EMAIL PROTECTED]> wrote:

>
> When i'am trying to migrate my application which is wriiten in 0.96
> version to 1.0, i encountered the following error message.
>
>  File "c:\python25\lib\site-packages\django\utils\dateformat.py",
> line 127, in D
>return WEEKDAYS_ABBR[self.data.weekday()]
> NameError: global name 'WEEKDAYS_ABBR' is not defined
>
>
> Is there any patch available for this? How can i get rid of this
> problem?
>
>
Have you modified that file django\utils\dateformat.py?  The one shipped
with 1.0 does not have the problem you are seeing since it imports
WEEKDAYS_ABBR from where it is defined before using it, see line 14 in:

http://code.djangoproject.com/browser/django/tags/releases/1.0/django/utils/dateformat.py

(Also the line number reported in your error message does not match what is
on that line the shipped version of the file, so something seems to have
happened to alter your 1.0 Django files, or at least this one.)

Karen

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



Re: Using models from another project/site

2008-09-13 Thread Karen Tracey
On Sat, Sep 13, 2008 at 8:00 AM, Donn <[EMAIL PROTECTED]> wrote:

>
> Extra info:
>
> I have many Projects that equate to 'websites'.
> Each has it's own database in Mysql.
>
> I want one Project to be our Admin that let's us set some stuff that the
> other
> websites (projects) read and act upon. (Hence OP needing to access a model
> from another Project)
>
> If I setup each "website" as an Application (under our Admin Project) then
> they will all use the same Mysql database. I need a database per client.
>
> So, any clues ?
>

So you want multiple database support, which in general Django doesn't yet
have.  There's a big thread over on the developer's list on this topic right
now.  If all your databases are on the same server, though, it might be that
Django will already do what you are looking for, see this message:

http://groups.google.com/group/django-developers/msg/05420313676f4693

Karen

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



Re: Using models from another project/site

2008-09-13 Thread Donn

Extra info:

I have many Projects that equate to 'websites'.
Each has it's own database in Mysql.

I want one Project to be our Admin that let's us set some stuff that the other 
websites (projects) read and act upon. (Hence OP needing to access a model 
from another Project)

If I setup each "website" as an Application (under our Admin Project) then 
they will all use the same Mysql database. I need a database per client.

So, any clues ?

\d

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



Re: Using slug in comments urls

2008-09-13 Thread Karen Tracey
On Sat, Sep 13, 2008 at 4:14 AM, Shantp <[EMAIL PROTECTED]> wrote:

>
>
> Just to clear up some confusion, I posted only the relevant part of my
> urls.py file. I have all the other necessary stuff in it but i'm still
> getting this error.
>

So if your root urlconf file does have urlpatterns specified, it must be
that one of the ones pulled in via include('...') does not.  Comment out
everything in urlpatters and verify that the dev server brings up the "It
worked" page when you try to access any url on its port.  If it doesn't,
verify that the urls file you think you are using is really the one
specified in ROOT_URLCONF in settings.py, that you have spelled
'urlpatterns' correctly, etc..  If you do get "It worked", then start
un-commenting lines  individually in urlpatterns until you find the one that
is specified wrong somehow.

Karen


>
>
> On Sep 12, 8:14 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> > On Sep 13, 2008, at 8:32 AM, Shantp wrote:
> >
> >
> >
> > > Hi,
> >
> > > I did a lot of searching on this and can't figure out what I'm doing
> > > wrong. Here's what's in my urls.py:
> >
> > > share_detail = {
> > >'queryset': Share.objects.all(),
> > > }
> >
> > > (r'^comments/', include('django.contrib.comments.urls')),
> > > (r'^comments/(?P[-\w]+)/?$',
> > > 'django.views.generic.list_detail.object_detail',
> > >dict(share_detail, slug_field='slug',
> > > template_object_name='share', template_name='share_page.html')),
> >
> > This looks like you're putting your urlconf patterns directly at the
> > top level of the file. They need to be encapsulated in a patterns()
> > call, and assigned to a variable called 'urlpatterns'. Right now
> > django's looking for that 'urlpatterns' variable, and not finding it.
> > Take a look at the sample urlconf file:
> >
> > http://docs.djangoproject.com/en/dev/topics/http/urls/#example
> >
> > Yours,
> > Eric
> >
> >
> >
> > > I'm getting this error:
> >
> > > Exception Type:AttributeError
> > > Exception Value:   'module' object has no attribute 'urlpatterns'
> >
> > > Can anyone help me understand what is wrong with my urls?
> >
>

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



Re: status of per-object-level permission

2008-09-13 Thread rca

> Thanks for your answer, Malcolm,
>
> I was refering to the 
> branchhttp://code.djangoproject.com/browser/django/branches/per-object-perm...
> which (according to the wiki) appeared to be almost ready for
> inclusion in the
> main branch of 0.96. To me, this always seemed to be the most official
> of the
> various runs on row-level-permissions.

I am very new to django, I went through the tutorial yesterday and I
was looking for some sort of ACLs now. And indeed, per-object-
permissions has been mentioned in many threads. A lot of people seemed
to be waiting and for a beginner like me, it is quite confusing - so
thank you Malcolm for the answer, it is very clear.

>
> > This is the sort of the thing that will be best done as an external
> > third-party project first and then, possibly, proposed as something for
> > django.contrib once it has an acceptable user base.
>
> agreed. however, with the variety of third-party solutions out there,
> it is unclear to the uninitiated which one to choose, and which one
> works
> best with django1.0. wnay recommendation?

yes please, if you have any recommendations what worked for you, that
would be great

It seems to me that lot of developers are opting for auth backend -
doing things outside Django. I was looking into phpGACL then I found
http://code.google.com/p/spiff-guard/ which is a sort of a similar
project in python.

I also came across this http://www.djangosnippets.org/snippets/414/
(field level permissions)

All the best,

--roman

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



migration problem from Django0.96 to Django1.0

2008-09-13 Thread vijay

When i'am trying to migrate my application which is wriiten in 0.96
version to 1.0, i encountered the following error message.

  File "c:\python25\lib\site-packages\django\utils\dateformat.py",
line 127, in D
return WEEKDAYS_ABBR[self.data.weekday()]
NameError: global name 'WEEKDAYS_ABBR' is not defined


Is there any patch available for this? How can i get rid of this
problem?

Thanks & regards,
Vijay

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



Logging exceptions using mod_python

2008-09-13 Thread mcordes

Hello,

The mod_python deployment doc says:  "When you use Apache/mod_python,
errors will be caught by Django -- in other words, they won't
propagate to the Apache level and won't appear in the Apache
error_log". Is there a way to force errors to be recorded in the
error_log? Failing that is there a way to get django to log errors to
a file directly?

-Matt


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



Using models from another project/site

2008-09-13 Thread Donn

I am getting confused by terms, but this is the basic need:

1. In a base dir I have site1 and site2
2. I am in site2 (views) and I want to use the models defined in site1
3. from site1.models import Blah -- seems to work without error.
4. I get an error on stuff like this:
p = Blah.objects.all()
for i in p <--- error here is: "Table 'site2.site1_blah' doesn't exist")

BTW: I have this kind of thing in Apache:

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE site2.settings
PythonOption django.root /site2
PythonDebug On
PythonInterpreter site2
PythonPath "['/path/to/base'] + sys.path"



How do I set things up so I can use 'foreign' models?

\d

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Import error: Model based on another model

2008-09-13 Thread Gerard Petersen

Daniel,

> If you want a field that's populated with values from another model,
> you should use a ForeignKey.
Is it then still possible to use filters and such, and keep it in the model 
logic?

Because the Meta model has these fields: 'attribute', 'value', 'display', 
'description'

And it's more like a lookup then a real relation between the models Order and 
Meta.

> Also, it's not a good idea to use Meta as the name of a model - that's
> bound to get confused with the inner Meta class which defines model
> meta-attributes like ordering.
Thanx for the tip. I already saw this one coming ... ;-)

Regards,

Gerard.

> 
> --
> DR.
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Import error: Model based on another model

2008-09-13 Thread Daniel Roseman

On Sep 13, 9:25 am, Gerard Petersen <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I need to create a field with a choice set that looks like this:
>
>     BTW_CHOICES = (
>         ('0.0', '0%'),
>         ('6.0', '6%'),
>         ('19.0', '19%'),
>     )
>
> This works as expected when using dropdown lists in a form. But it needs to 
> be build from data in another model. When needed in a view I can retrieve the 
> raw data like this:
>
>     btwchoices = Meta.objects.values_list('value', 
> 'display').filter(attribute__startswith='BTW')
>
> When I put a similar line in the model class Meta is unknown. And doing a 
> 'from models import...' seems very weird when I'm IN the models module. when 
> I move it to a myfunctions.py I get import errors.
>
> from models import Meta
> ImportError: cannot import name Meta
>
> Can anybody give me some insights on how, and more importantly where, to 
> dynamically fill this BTW_CHOICES thingy.
>
> Thanx!
>
> Regards,
>
> Gerard.


If you want a field that's populated with values from another model,
you should use a ForeignKey.

Also, it's not a good idea to use Meta as the name of a model - that's
bound to get confused with the inner Meta class which defines model
meta-attributes like ordering.

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



Import error: Model based on another model

2008-09-13 Thread Gerard Petersen

Hi All,

I need to create a field with a choice set that looks like this:

BTW_CHOICES = (
('0.0', '0%'),
('6.0', '6%'),
('19.0', '19%'),
)

This works as expected when using dropdown lists in a form. But it needs to be 
build from data in another model. When needed in a view I can retrieve the raw 
data like this:

btwchoices = Meta.objects.values_list('value', 
'display').filter(attribute__startswith='BTW')

When I put a similar line in the model class Meta is unknown. And doing a 'from 
models import...' seems very weird when I'm IN the models module. when I move 
it to a myfunctions.py I get import errors.

from models import Meta
ImportError: cannot import name Meta

Can anybody give me some insights on how, and more importantly where, to 
dynamically fill this BTW_CHOICES thingy.

Thanx!

Regards,

Gerard.

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: Using slug in comments urls

2008-09-13 Thread Shantp


Just to clear up some confusion, I posted only the relevant part of my
urls.py file. I have all the other necessary stuff in it but i'm still
getting this error.


On Sep 12, 8:14 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On Sep 13, 2008, at 8:32 AM, Shantp wrote:
>
>
>
> > Hi,
>
> > I did a lot of searching on this and can't figure out what I'm doing
> > wrong. Here's what's in my urls.py:
>
> > share_detail = {
> >    'queryset': Share.objects.all(),
> > }
>
> > (r'^comments/', include('django.contrib.comments.urls')),
> > (r'^comments/(?P[-\w]+)/?$',
> > 'django.views.generic.list_detail.object_detail',
> >        dict(share_detail, slug_field='slug',
> > template_object_name='share', template_name='share_page.html')),
>
> This looks like you're putting your urlconf patterns directly at the  
> top level of the file. They need to be encapsulated in a patterns()  
> call, and assigned to a variable called 'urlpatterns'. Right now  
> django's looking for that 'urlpatterns' variable, and not finding it.  
> Take a look at the sample urlconf file:
>
> http://docs.djangoproject.com/en/dev/topics/http/urls/#example
>
> Yours,
> Eric
>
>
>
> > I'm getting this error:
>
> > Exception Type:    AttributeError
> > Exception Value:   'module' object has no attribute 'urlpatterns'
>
> > Can anyone help me understand what is wrong with my urls?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 prevent URL HTML encoding?

2008-09-13 Thread Karen Tracey
On Sat, Sep 13, 2008 at 1:36 AM, Ross <[EMAIL PROTECTED]> wrote:

>
> The URL encoding is not causing any problems in my code. Splitting the
> parameter on '+' works the same whether the address is 'Goo+Goo+Dolls'
> or 'Goo%2BGoo%2BDolls'.
>
> I can certainly add additional expressions to catch URLs with and
> without the trailing slash, I was just hoping there was an option to
> do just that.
>

Change your pattern from:

r'^djangoproject/search/(?P[\w\+]+)/$'

to:

r'^djangoproject/search/(?P[\w\+]+)/?$'

The question mark makes the trailing slash optional -- pattern will match a
url with 0 or 1 trailing slashes.

Karen



>
> On Sep 12, 10:15 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > On Fri, Sep 12, 2008 at 6:06 PM, Ross <[EMAIL PROTECTED]> wrote:
> >
> > > The problem is it looks bad! It makes the URL unreadable, which is
> > > what I want to prevent. For example, last.fm uses '+' symbols to
> > > separate band names.
> >
> > >http://www.last.fm/music/Goo+Goo+Dollspretty obviously takes you to
> > > the page for the band "Goo Goo Dolls".
> >
> > >http://www.last.fm/music/Goo%2BGoo%2BDolls, however, is far tougher to
> > > pick apart by a human reader.
> >
> > > My short answer is I want to keep my URLs human readable.
> >
> > OK, so you are not actually seeing a code problem in your
> dispatching/views
> > resulting from this?  That is what I was trying to determine: whether
> your
> > code had to adapt to things coming in percent-encoded, because I didn't
> > think it should, and if it did, I'd want to track down why.
> >
> > If you just don't like how it looks in the browser address bar, then
> simply
> > avoid having it happen.  Specify your url regex expressions so that the
> > trailing slash is optional, that way APPEND_SLASH never has to get
> involved
> > and issue the redirect. Wouldn't that be easier than trying to change how
> > APPEND_SLASH works?
> >
> > Karen
> >
>

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