cross-referencing design question

2009-07-23 Thread Mike Dewhirst

I'm new to Django and want to express a self-referencing design
feature to link clients in the same table with each other. Django is
currently objecting to this. Could you please point me to
documentation which will let me figure it out?

This is my models.py in a play project using Django from svn rev ...

- - - - - - - - - - -
from django.db import models

def when():
return datetime.now()

class Client(models.Model):
""" base class for everyone/thing """
surname = models.CharField(max_length=48, blank=False)
client_type = models.CharField(max_length=24, blank=False)
def __unicode__(self):
return self.client_type + ": " + self.surname

class Membership(models.Model):
""" cross (xr) referencing and linking clients """
client_x = models.ForeignKey(Client)
client_r = models.ForeignKey(Client)
def __unicode__(self):
return str(self.client_x + " : " + str(self.client_r)

- - - - - - - - - - -


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

2009-07-27 Thread Mike Dewhirst

Matthias Kestenholz wrote:



> Is this your complete Membership model? Or do you have additional
> fields there? If you've only got these two foreign keys, it might be
> better to use a many to many field that references the same model (
> ManyToManyField('self') )

Thanks Matthias - exactly what I wanted - see below. It isn't the 
complete system but I'm just starting and want to get the beginnings 
more or less correctly working.

> Plus, you should use unicode(), not str() inside __unicode__ -- str()
> will bail if client_type or surname contains non-ASCII-chars.

Thanks again ...

Daniel Roseman wrote:
> On Jul 24, 5:46 am, Mike Dewhirst  wrote:
>> I'm new to Django and want to express a self-referencing design
>> feature to link clients in the same table with each other. 



> You don't say what the error is. I can guess, though, and as always
> the clue is in the error message (why do people never seem to read
> these?)

Thanks also Daniel. You are right of course - my apologies. I did read
the message but did not have the brainspace to understand it at the 
time. Even now I'm relying on assumptions which I hope will become clear 
one day. Which leads me to another question about Django orm ...

Does Django need to create all the tables itself? I have been dropping 
everything and re-syncdb-ing to try and make things happen. Can I make 
my own tables and ask Django to use them?

My new models.py is as you and Matthias advised ...
- - - - - - - -
from django.db import models

class Client(models.Model):
 """ base class for everyone/thing """
 surname = models.CharField(max_length=48, blank=False)
 client_type = models.CharField(max_length=24, blank=True)
 group = models.ManyToManyField('self',
#db_table='foo_membership',
blank=True)

 def __unicode__(self):
 return u'%s : %s' % (self.client_type, self.surname)

class Membership(models.Model):
 """ cross (xr) referencing and linking clients """
 client_x = models.ForeignKey(Client, related_name='x_set')
 client_r = models.ForeignKey(Client, related_name='r_set')
 description = models.CharField(max_length=48, blank=False)

 def __unicode__(self):
 return u'Linked: %s - %s' % (unicode(self.client_x),
  unicode(self.client_r))
- - - - - - - -

If I reverse the position of the above two classes prior to syncdb, 
Django quite reasonably complains that Client (in Membership) does not 
exist. If I leave them in the above sequence it invents its own 
foo_client_group table for the n:m table and then creates my Membership 
table too.

I have tried using db_table='foo_membership' but that causes ...

   File "C:\usr\bin\lib\site-packages\django\db\backends\util.py", line 
19, in execute
 return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "foo_membership" already exists

I could cope with omitting my Membership table and adding a 
'description' column to Django's 'foo_client_group' table - but then how 
do I make a class which knows about the foo_client_group table name?


Is there a trick to it or have I (more likely) missed something obvious?

Sorry to be so opaque. I'm just getting over a month of late nights.

Thanks

Mike



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

2009-07-27 Thread Mike Dewhirst

Please disregard my previous - I've got something happening/hatching

Thanks Matthias and Daniel

Mike

Mike Dewhirst wrote:
> Matthias Kestenholz wrote:
> 
> 
> 
>> Is this your complete Membership model? Or do you have additional
>> fields there? If you've only got these two foreign keys, it might be
>> better to use a many to many field that references the same model (
>> ManyToManyField('self') )
> 
> Thanks Matthias - exactly what I wanted - see below. It isn't the 
> complete system but I'm just starting and want to get the beginnings 
> more or less correctly working.
> 
>> Plus, you should use unicode(), not str() inside __unicode__ -- str()
>> will bail if client_type or surname contains non-ASCII-chars.
> 
> Thanks again ...
> 
> Daniel Roseman wrote:
>> On Jul 24, 5:46 am, Mike Dewhirst  wrote:
>>> I'm new to Django and want to express a self-referencing design
>>> feature to link clients in the same table with each other. 
> 
> 
> 
>> You don't say what the error is. I can guess, though, and as always
>> the clue is in the error message (why do people never seem to read
>> these?)
> 
> Thanks also Daniel. You are right of course - my apologies. I did read
> the message but did not have the brainspace to understand it at the 
> time. Even now I'm relying on assumptions which I hope will become clear 
> one day. Which leads me to another question about Django orm ...
> 
> Does Django need to create all the tables itself? I have been dropping 
> everything and re-syncdb-ing to try and make things happen. Can I make 
> my own tables and ask Django to use them?
> 
> My new models.py is as you and Matthias advised ...
> - - - - - - - -
> from django.db import models
> 
> class Client(models.Model):
>  """ base class for everyone/thing """
>  surname = models.CharField(max_length=48, blank=False)
>  client_type = models.CharField(max_length=24, blank=True)
>  group = models.ManyToManyField('self',
> #db_table='foo_membership',
> blank=True)
> 
>  def __unicode__(self):
>  return u'%s : %s' % (self.client_type, self.surname)
> 
> class Membership(models.Model):
>  """ cross (xr) referencing and linking clients """
>  client_x = models.ForeignKey(Client, related_name='x_set')
>  client_r = models.ForeignKey(Client, related_name='r_set')
>  description = models.CharField(max_length=48, blank=False)
> 
>  def __unicode__(self):
>  return u'Linked: %s - %s' % (unicode(self.client_x),
>   unicode(self.client_r))
> - - - - - - - -
> 
> If I reverse the position of the above two classes prior to syncdb, 
> Django quite reasonably complains that Client (in Membership) does not 
> exist. If I leave them in the above sequence it invents its own 
> foo_client_group table for the n:m table and then creates my Membership 
> table too.
> 
> I have tried using db_table='foo_membership' but that causes ...
> 
>File "C:\usr\bin\lib\site-packages\django\db\backends\util.py", line 
> 19, in execute
>  return self.cursor.execute(sql, params)
> psycopg2.ProgrammingError: relation "foo_membership" already exists
> 
> I could cope with omitting my Membership table and adding a 
> 'description' column to Django's 'foo_client_group' table - but then how 
> do I make a class which knows about the foo_client_group table name?
> 
> 
> Is there a trick to it or have I (more likely) missed something obvious?
> 
> Sorry to be so opaque. I'm just getting over a month of late nights.
> 
> Thanks
> 
> Mike
> 
> 
> 
> > 
> 
> 


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

2009-07-27 Thread Mike Dewhirst

Daniel and Matthias

Thanks for your help. I finally figured out I don't need any automatic 
Django n:m at all! I just made my own n:m table and everything works the 
way I expect. I'll really try to keep things simple from now on ...

Cheers

Mike

Mike Dewhirst wrote:
> Matthias Kestenholz wrote:
> 
> 
> 
>> Is this your complete Membership model? Or do you have additional
>> fields there? If you've only got these two foreign keys, it might be
>> better to use a many to many field that references the same model (
>> ManyToManyField('self') )
> 
> Thanks Matthias - exactly what I wanted - see below. It isn't the 
> complete system but I'm just starting and want to get the beginnings 
> more or less correctly working.
> 
>> Plus, you should use unicode(), not str() inside __unicode__ -- str()
>> will bail if client_type or surname contains non-ASCII-chars.
> 
> Thanks again ...
> 
> Daniel Roseman wrote:
>> On Jul 24, 5:46 am, Mike Dewhirst  wrote:
>>> I'm new to Django and want to express a self-referencing design
>>> feature to link clients in the same table with each other. 
> 
> 
> 
>> You don't say what the error is. I can guess, though, and as always
>> the clue is in the error message (why do people never seem to read
>> these?)
> 
> Thanks also Daniel. You are right of course - my apologies. I did read
> the message but did not have the brainspace to understand it at the 
> time. Even now I'm relying on assumptions which I hope will become clear 
> one day. Which leads me to another question about Django orm ...
> 
> Does Django need to create all the tables itself? I have been dropping 
> everything and re-syncdb-ing to try and make things happen. Can I make 
> my own tables and ask Django to use them?
> 
> My new models.py is as you and Matthias advised ...
> - - - - - - - -
> from django.db import models
> 
> class Client(models.Model):
>  """ base class for everyone/thing """
>  surname = models.CharField(max_length=48, blank=False)
>  client_type = models.CharField(max_length=24, blank=True)
>  group = models.ManyToManyField('self',
> #db_table='foo_membership',
> blank=True)
> 
>  def __unicode__(self):
>  return u'%s : %s' % (self.client_type, self.surname)
> 
> class Membership(models.Model):
>  """ cross (xr) referencing and linking clients """
>  client_x = models.ForeignKey(Client, related_name='x_set')
>  client_r = models.ForeignKey(Client, related_name='r_set')
>  description = models.CharField(max_length=48, blank=False)
> 
>  def __unicode__(self):
>  return u'Linked: %s - %s' % (unicode(self.client_x),
>   unicode(self.client_r))
> - - - - - - - -
> 
> If I reverse the position of the above two classes prior to syncdb, 
> Django quite reasonably complains that Client (in Membership) does not 
> exist. If I leave them in the above sequence it invents its own 
> foo_client_group table for the n:m table and then creates my Membership 
> table too.
> 
> I have tried using db_table='foo_membership' but that causes ...
> 
>File "C:\usr\bin\lib\site-packages\django\db\backends\util.py", line 
> 19, in execute
>  return self.cursor.execute(sql, params)
> psycopg2.ProgrammingError: relation "foo_membership" already exists
> 
> I could cope with omitting my Membership table and adding a 
> 'description' column to Django's 'foo_client_group' table - but then how 
> do I make a class which knows about the foo_client_group table name?
> 
> 
> Is there a trick to it or have I (more likely) missed something obvious?
> 
> Sorry to be so opaque. I'm just getting over a month of late nights.
> 
> Thanks
> 
> Mike
> 
> 
> 
> > 
> 
> 


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



Re: Django and related_name

2009-07-29 Thread Mike Dewhirst

Asinox wrote:
> 
> 
> Hi guys, first im so sorry with my english, im new with Django, u
> know ;)
> 
> I have a problem with a related_name, the tables are fine, but the
> problem is that in the Select (DropDown) the data display is "bad", in
> this way: Tarifas_object:
> 
> Html code:
> 
> Tarifas object
> 
> how ill display the correct data?
> 
> my model:
> 
> class Tarifas(models.Model): recarga = models.CharField(max_length=7,
> help_text='Codigo de la tarifa')
>  precio = models.DecimalField(max_digits=7, decimal_places=2)
>  diligencias =  models.PositiveIntegerField(max_length=3)
> 

Is this a typo or is there such an attribute recognised by Django when 
you want to represent a decimal field?

> def __inicode__(self):



> return self.precio
> 
> class Meta:
> verbose_name_plural="Tarifas"
> 
> class Recarga(models.Model): socio = models.ForeignKey(User)
>  fecha = models.DateField(auto_now_add=True)
>   #valor = models.DecimalField(max_digits=6,
> decimal_places=2,verbose_name='Valor de la recarga', help_text=
> "Introduzca valores numericos ej.: 150.00")
>  valor = models.ForeignKey(Tarifas,
> related_name='recarga_valor')
>  diligencias = models.IntegerField(max_length=3,
> verbose_name='Cantidad de diligencias recargadas')
>  tiponcf = models.IntegerField(max_length=1,choices=TIPO_NCF,
> verbose_name='Tipo de comprobante fiscal')
>  ncf = models.CharField(max_length=19,verbose_name='Numero de
> comprobante fiscal')
>  cajero = models.CharField(max_length=20)
>  tipotarj = models.CharField(choices=TIPOS_TARJETAS,
> max_length=20, verbose_name='Tipo de tarjeta')
>  numtarj = models.IntegerField(max_length=16,
> verbose_name='Numero de tarjeta')
>  seguridad = models.IntegerField(max_length=3)
>  forma_pago = models.CharField(max_length=10,
> verbose_name='Forma de pago')
>  banco = models.CharField(max_length=20)
>  numerock = models.IntegerField(max_length=8,
> verbose_name='Numero de cheque')
> 
> def __unicode__(self):
> return u'%s %s %s %s' % (self.socio,self.diligencias, self.fecha)
> 
> 
> class Meta:
> ordering = ['socio']
> 
> Thanks guys.
> 
> > 
> 
> 


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

2009-08-05 Thread Mike Dewhirst

adelaide_mike wrote:
> This should really be a Python enquiry, but I am sure someone will
> know:
> 
> I need to calculate the date 12 weeks before today.  What is the best
> way?  TIA

This might give you a clue ...

from datetime import date

def anniversary_this_week(self, tday=date.today()):
 anniversary = self.birthdate.replace(year=tday.year)
 diff = anniversary.toordinal() - tday.toordinal()
 if diff < -358 or (diff >= 0 and diff <=7):
 return 'Yes'
 return 'No'

> 
> Mike
> > 
> 
> 


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



display module and template names in templates

2009-08-10 Thread Mike Dewhirst

If DEBUG is True I would like to include view.__name__ and the template 
filename somewhere in the rendered page.

It would be nice to adjust the {% block title %} so the information 
appears in the top of the browser window-frame so it didn't upset an 
page layout stuff.

Is there a reasonable way to do this?

Thanks for any pointers.

Mike

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



[highly recommended] Re: display module and template names in templates

2009-08-10 Thread Mike Dewhirst

Mike Ramirez wrote:
> On Monday 10 August 2009 08:47:57 pm Mike Dewhirst wrote:
>> If DEBUG is True I would like to include view.__name__ and the template
>> filename somewhere in the rendered page.
>>
>> It would be nice to adjust the {% block title %} so the information
>> appears in the top of the browser window-frame so it didn't upset an
>> page layout stuff.
>>
>> Is there a reasonable way to do this?
>>
>> Thanks for any pointers.
>>
>> Mike
>>
> 
> I use the django debug toolbar for a lot of this info, been awhile since I 
> used it and I can't remember if the view function name is displayed but you 
> can be sure the matching view function is called for the url in question, I 
> usually keep the urls.py open when I'm working on a project/app.

Mike - And Rob Hudson if you are listening :)

That is a great piece of kit. I have commented out all panels except 
Header, RequestVars and Template for the time being and that tells me 
most of what I want to know.

I think you're right that having the urls.py open too covers the rest of it.

Wonderful :)

Thanks

Mike

> 
> 
> http://rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/
> 
> Mike
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Model example for simple family tree

2009-08-11 Thread Mike Dewhirst

sniper wrote:
> Hi,
> I am new to django and wanted to try it out.
> 
> I would like to create a table for family tree
> where Relation is a many to many table which contains Profile ids
> 
> profile_id, relative_id,type,priority.
> 
> RELATIVE_CHOICES = (
> (u'F', u'Father'),
> (u'M', u'Mother'),
> (u'B', u'Brother'),
> (u'S', u'Sister'),
> (u'N', u'Son'),
> (u'D', u'Daugter'),
> (u'H', u'Husband'),
> (u'W', u'Wife'),
> )
> 
> # Create your models here.
> class Profile(models.Model):
>   first_name = models.CharField(max_length=20)
>   last_name = models.CharField(max_length=20,null=True)
>   gender = models.CharField(max_length=2, choices=GENDER_CHOICES)
>   birth_date = models.DateTimeField('birth day',null=True)
>   notes = models.TextField(null=True)
> 
> 

Sniper

I did exactly the same thing at exactly the same stage of my own 
exposure to Django. It gets easier as the newness wears off a bit and 
you get to trust the error messages.

Good luck

> class Relation(models.Model):

 person = models.ForeignKey(Profile, related_name='person_set')

>   person = models.ForeignKey(Profile)

 relative = models.ForeignKey(Profile, related_name='relation_set')

>   relative = models.ForeignKey(Profile)
>   type=models.CharField(max_length=2, choices=RELATIVE_CHOICES)
>   priority = models.IntegerField(default=1)
> 
> how do i do that?
> right now i am getting this error
> 
> Error: One or more models did not validate:
> ftree.relation: Accessor for field 'person' clashes with related field
> 'Profile.relation_set'. Add a
>  related_name argument to the definition for 'person'.
> ftree.relation: Accessor for field 'relative' clashes with related
> field 'Profile.relation_set'. Add
>  a related_name argument to the definition for 'relative'.
> 
> 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
-~--~~~~--~~--~--~---



misunderstanding

2009-08-16 Thread Mike Dewhirst

There's something here I'm not seeing. If anyone can point out the docco 
which refers I would be most grateful ... I'm using py2.6 and Django 
from svn head.

The template below displays the title correctly but claims "No meta 
dictionary passed". Since the title is one of the meta_dict key:value 
pairs I feel this should not be. Also, when I uncomment the #print line 
below, the entire meta_dict, including 'title': 'META items' prints.

Thanks for any pointers ...

Mike

 views.py (excerpt) ---
def display_meta(request):
 dct = {'title':'META items',}
 meta_dict = dict(request.META.items())
 meta_dict.update(dct)
 #print(meta_dict)
 return render_to_response('polls/meta_dict.html', meta_dict)


 meta_dict.html 
{% extends "base_polls.html" %}
{% block content_title %}{{ title }}{% endblock %}
{% block content %}
{% if meta_dict %}
 
 {% for key, value in meta_dict.items %}
  {{ key }} {{ value }}
 {% endfor %}
 
{% else %}
 No meta dictionary passed
{% endif %}
{% endblock %}
-



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

2009-08-16 Thread Mike Dewhirst

Karen and Eric - thank you. Yet another door opened for me :)

Mike


Karen Tracey wrote:
> On Sun, Aug 16, 2009 at 9:33 PM, Mike Dewhirst 

> 
> Based on what your template does, you don't seem to really want to 
> combine a dictionary with the key 'title' and the META dictionary. 
> Rather you want a dictionary with the key 'title' and the key 
> 'meta_dict', with the value for the 'meta_dict' key being the META 
> dictionary:
> 
> def display_meta(request):
> dct = {'title':'META items',}
> dct['meta_dict'] = request.META
> return render_to_response('polls/meta_dict.html', dct)
> 
> Karen
> 

Eric Abrahamsen wrote:
> 
> On Aug 17, 2009, at 9:33 AM, Mike Dewhirst wrote:
> Variables should be passed to the template as a dictionary, so this  
> response line should look like this:
> 
> return render_to_response('polls/meta_dict.html', {'meta_dict':  
> meta_dict}
> 
> Then it will be available in your template. My guess is that, since  
> meta_dict is itself a dictionary, you can currently access its  
> contents in your template by directly using its keys as variables.




> 
>  meta_dict.html 
> {% extends "base_polls.html" %}
> {% block content_title %}{{ title }}{% endblock %}
> {% block content %}
> {% if meta_dict %}
> 
> {% for key, value in meta_dict.items %}
>  {{ key }} {{ value }}
> {% endfor %}
> 
> {% else %}
> No meta dictionary passed
> {% endif %}
> {% endblock %}
> -
> 
> 
> > 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Showng the primary key in admin view

2009-09-01 Thread Mike Dewhirst

Joakim Hove wrote:
> Hello,
> 
> I have a (simplified) model like this
> 
> class Customer(models.Model):
>  name  =   models.CharField(max_length = 100)
>  date=   models.DateTimeField()
>  email  =   models.EmailField()
> 
> 
> When showing this in the (100 % default) admin view I get up nice
> entry boxes for the fields 'name', 'date' and 'email'. In addition I
> would very much like to display the 'id' field which django has
> automatically added (preferably as readonly). Any tips on how to
> achieve this?

 @property
 def id_field(self):
 return self.pk

 def __unicode__(self):
 return u'%s : %s' % (self.id_field, self.name)

Mike

> 
> Joakim
> > 
> 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Showng the primary key in admin view

2009-09-02 Thread Mike Dewhirst

Joakim Hove wrote:
> Thank you both for answering; however I am afraid we are
> misunderstanding eachother here.
> 
> I have created a admin.py file and registered my CustomerClass with
> the admin interface. That works, and I can select the CustomerClass
> when logged in to the admin interface.
> Let us say I have created three instances of the CustomerClass class,
> with primary keys ranging 0..2 - then using the __unicode__() function
> suggested below I am presented with a list of three items:
> 
>   0: John
>   1: Bill
>   2: George
> 
> Clicking on "2: George" I get up a new screen where I can edit the
> information about George:

and if you look up-screen at the "breadcrumbs" you should see ...

Home >> Customers >> 2: George

Does that do it?

M

> 
>   Name:  [  George ]
>   Date  :  [ 27/08/2009 ]
>   Email:  [ geo...@mail.com ]
> 
> Now - it is in this view I would have liked to display the primary key
> as well (the primary key serves as kind of customer id). I have tried
> to instantiate a CustomerAdmin class and listed the "id" field, there
> but that only gives run time error. It seems the admin view/template
> does not recognize the id which is an AutoField.
> 
> OK - thanks a lot for your time - further suggestions greatly
> appreciated!
> 
> Joakim
> 
> 
> 
> 
> 
> > 
> 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Showng the primary key in admin view

2009-09-02 Thread Mike Dewhirst

Joakim Hove wrote:
> Thank you both for answering; however I am afraid we are
> misunderstanding eachother here.
> 
> I have created a admin.py file and registered my CustomerClass with
> the admin interface. That works, and I can select the CustomerClass
> when logged in to the admin interface.
> Let us say I have created three instances of the CustomerClass class,
> with primary keys ranging 0..2 - then using the __unicode__() function
> suggested below I am presented with a list of three items:
> 
>   0: John
>   1: Bill
>   2: George
> 
> Clicking on "2: George" I get up a new screen where I can edit the
> information about George:
> 
>   Name:  [  George ]
>   Date  :  [ 27/08/2009 ]
>   Email:  [ geo...@mail.com ]
> 
> Now - it is in this view I would have liked to display the primary key
> as well (the primary key serves as kind of customer id). 

It is usually not a good idea to give business meaning to a primary key 
in a relational database. The literature is full of reasons against it.

Perhaps a better way would be to steer clear of primary keys altogether 
and instead create a new field of your own to contain the customer id?

It would probably survive dumping and reloading between different databases.

Mike



I have tried
> to instantiate a CustomerAdmin class and listed the "id" field, there
> but that only gives run time error. It seems the admin view/template
> does not recognize the id which is an AutoField.
> 
> OK - thanks a lot for your time - further suggestions greatly
> appreciated!
> 
> Joakim
> 
> 
> 
> 
> 
> > 
> 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Showng the primary key in admin view

2009-09-02 Thread Mike Dewhirst

Joakim Hove wrote:
> 
> 
> Hello,
> 
> thanks for the tip:
> 
>> It is usually not a good idea to give business meaning to a primary key
>> in a relational database. The literature is full of reasons against it.
> 
> I had a nagging feeling this might be the case. Do you have any links
> to "Best practice" om these questions - I am a database freshman.

There are cases for and against but in general the best rule is don't do
it.

As soon as you invest meaning in a pk you give up one complete degree of 
flexibility.

Imagine if you decide to rework your database schema one day to add some 
new-fangled feature. That would likely require a dump and data-tweak on 
reload. You would find it difficult to guarantee the same pk.

Don't do it if the primary key becomes a visible part of your data for 
users. For example, you might get away with bending the rule and use a 
pk as a delivery docket number because such a document is fairly 
short-lived.

I wouldn't do it. As a rule.

Mike

> 
> Thanks - Joakim
> > 
> 
> 



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Users Full Name in model form?

2009-09-07 Thread Mike Dewhirst

Streamweaver wrote:
> This was through a custom form in a public view.  I haven't done much
> with admin forms but maybe someone else knows?
> 
> 
> 
> On Sep 4, 4:50 pm, Anthony Simonelli  wrote:
>> Is this within the Admin interface?  If so, I'm having a similar
>> problem.  I have a model called Request with a FK relationship to an
>> Employee model.  Within the Admin interface, when adding a Request,
>> the drop-down of the Employees selection read "Employee Object".  This
>> is also the case when listing the Employees.  There is no way to
>> distinguish between the employees.
>>
>> How do I change, what I think is called the "string representation" of
>> the object within the Admin interface.  Also, is there some sort of
>> naming convention when creating models to get these fields
>> automatically?
>>
>> On Fri, Sep 4, 2009 at 1:26 PM, Streamweaver wrote:
>>
>>> I had a model that lists an owner with a FK relationship to the Users
>>> table.
>>> When using model form the dropdown for the owner field defaults to the
>>> username.
>>> I'd like to override that to use a users name as the choice portion of
>>> the dropdown sorted by users last name but I'm having trouble thinking
>>> through how to do this.
>>> Can anyone point me to an example of something like this?

Visit ...

http://docs.djangoproject.com/en/dev/intro/tutorial01

... and search in that page for "Wait a minute"

It indicates that you can return whatever string (actually unicode) 
representation you want as constructed from the object attributes when 
you bring an object via foreign key.

Mike



> > 
> 
> 


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

2009-09-08 Thread Mike Dewhirst

Dj Gilcrease wrote:
> On Mon, Sep 7, 2009 at 9:55 AM, Samuel Hopkins  
> wrote:
>> Hello Django peeps,
>>
>> I am a Django newbee. I have had my eye on Djanjo for a year or so now but
>> held off because I had limited python experience. However, after a summer of
>> python and watching Django's popularity snowball, I think I am ready to go
>> :)
>>
>> Anyhow, the purpose of this email was just to ask the community what
>> editor(s) they preferred to use with Django.
> 
> 
> I used TextPad for years, with no syntax highlighting. I now use
> Wingware, and since I work primarily on OpenSource Projects the Pro
> version is free.

I use TextPad with Python highlighting. It suits me because I'm used to 
it. I use the 'Run' option to launch Python with my unit tests or 
anything else for a quick syntax check. The results come back nicely.

Speaking of results I also like TextPad's search results (with or 
without re) and grep-like 'Find in files' which is very fast and lets 
you double-click a found line to open the file at that point.

I tried PyDev and like that too but found Eclipse too heavy when 
associated with SVN. I know there is SVN integration but I couldn't get 
it going smoothly enough so I gave up and happily went back to TextPad.

I'm definitely going to try Joshua's suggestion of pdb.

Thanks

Mike


> 
> > 
> 
> 


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



breadcrumb solution

2009-09-08 Thread Mike Dewhirst

I would like to get breadcrumbs working in a simple way. Could anyone 
please help?

I think I need a singleton with a dict like this ...

bread = singleton()

bread.dct['last_title'] =

Within each view and before doing anything else I want to ...

def someview(request):
title = 'whatever'
crumb = bread.dct['last_title']
bread.dct['last_title'] = title
# put title and crumb into the view context for extraction
# in the template as {{title}} and {{crumb}}


Is there a better way?

Thanks

Mike

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

2009-09-09 Thread Mike Dewhirst

Daniel Roseman wrote:
> On Sep 9, 7:32 am, Mike Dewhirst  wrote:
>> I would like to get breadcrumbs working in a simple way. Could anyone
>> please help?
>>
>> I think I need a singleton with a dict like this ...
>>
>> bread = singleton()
>>
>> bread.dct['last_title'] =
>>
>> Within each view and before doing anything else I want to ...
>>
>> def someview(request):
>> title = 'whatever'
>> crumb = bread.dct['last_title']
>> bread.dct['last_title'] = title
>> # put title and crumb into the view context for extraction
>> # in the template as {{title}} and {{crumb}}
>>
>> Is there a better way?
>>
>> Thanks
>>
>> Mike
> 
> Why do you need a singleton here? This is a pattern you don't see
> often in Python, so I'm intrigued as to why you think you need it.
> 
> Anyway, the better way is to do this as a templatetag.

I'm obviously off track. I just looked at template tags again and can't 
see anything - other than making a custom tag which seems a bit much for 
me just at the moment.

Apart from hard-coding variables in a template and passing the values in 
a context dictionary, how should it be done? Can you point me to any 
examples?

Thanks

Mike




> --
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: breadcrumb solution

2009-09-09 Thread Mike Dewhirst

Thanks David - I do :)

Cheers

M


David De La Harpe Golden wrote:
> Mike Dewhirst wrote:
>> I would like to get breadcrumbs working in a simple way. Could anyone 
>> please help?
> 
>> Is there a better way?
> 
> One thing you can do is a "pure template" based breadcrumb
> or pseudo-breadcrumb, assuming you have a template inheritance
> graph with different views rendering different templates -
> block.super is the key.  I'm sure I picked this up in a blog post
> somewhere, I didn't originate it:
> 
> *** base.html.djt:
> 
> {% block title %}EXAMPLE{% endblock %}
> and
> 
> 
>   {% block breadcrumb %}EXAMPLE{% endblock %}
> 
> 
> 
> *** child.html.djt:
> 
> {% extends "base.html.djt" %}
> 
> {% block title %}{{ block.super }} :: CHILD{% endblock %}
> 
> {% block breadcrumb %}{{ block.super }} » CHILD{% endblock %}
> 
> 
> 
> *** grandchild.html.djt:
> 
> {% extends "child.html.djt" %}
> 
> {% block title %}{{ block.super }} :: GRANDCHILD{% endblock %}
> 
> {% block breadcrumb %}{{ block.super }} » GRANDCHILD{% endblock %}
> 
> 
> 
> You get the idea.
> 
> 
> 
> > 
> 
> 


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



Re: Django Project Management App

2009-09-10 Thread Mike Dewhirst

Greg wrote:
> Hi all,
> 
> Since I started with django a year or so ago, I've been gradually
> building a very simple project management app for myself - it started
> as a project to learn the language but has evolved into a very useful
> tool, handling all my timetracking, task management and invoicing.
> 
> I'm wondering if it would be worth open sourcing it? 

+1

I think it would be well worthwhile.

I just downloaded Satchmo to see how a Django app should be structured; 
not because I want a shopping site. Satchmo is a very sophisticated 
piece of Django/Python obviously comprising many man-years of work.

If you open source your app it could serve the dual purpose of showing 
newbies (like me) a working app of only a year or so's sophistication 
(much easier to get one's head around) plus a project management tool.

Go for it :)

Mike


Right now it's
> very much set up for me and me only, but it wouldn't take too much
> effort to make it a portable app that others could use. I've looked
> for django project management projects to use and/or contribute to,
> but there doesn't seem to be any out there.
> 
> Any thoughts?
> 
> Greg
> > 
> 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: What JavaScript framework do you use and why?

2009-09-29 Thread Mike Dewhirst

I have heard nice things about Mochikit. I had a look at it a long time 
ago and fully intended to get involved but haven't had the opportunity 
yet ...

http://www.mochikit.com/about.html



esatterwh...@wi.rr.com wrote:
> I use mootools a lot. When I was deciding which on to use, I first
> looked at How big is the library ( how long is it going to take me to
> learn ), how complex, does it do what I want/need. Does it fit the way
> I think, does it make sense with python/django.
> 
> Mootools, to me was a pretty good fit. The descriptor of mootools
> was,'It's not about cows or milk! It stands for My Object Orientated
> Tools"
> 
> The best thing about mootools is the Class implementation. It really
> turns a muddy scripting language into a more OO lang like python. You
> can create new classes & objects which can inherit from each other,
> etc. Going from python to mootools is easy as you don't have such a
> big shift in gears.
> 
> There is also project that can convert your python code directly to
> mootools javascript.
> http://code.google.com/p/pygowave-server/wiki/PythonToJavaScriptTranslator
> 
> Also, while a topic of much debate, one of mootools strengths and
> consequently it's weakness is that it extends some of the naitive
> objects in javascript.  This makes coding faster and easier. However,
> the down side is that it doesn't really play well with some other
> javascript libraries. Personal experience has pointed out jquery and
> the 2.X versions of the YUI ( at least with out some patching ).
> But it has a host of built in methods for working with Javascripts
> native objects that just make life easier.
> 
> I would really miss the Classes and ease/speed at which you can create
> applications.
> 
> As of late Mootools has been under a pretty big surge in development.
> in the last 5-6 months it has gone from 1.2 to 1.2.4.1 and is on the
> verge of 2.0, so their has been a little frustration with backward
> compatibility and change in some syntax. But they have all previous
> versions on github making it pretty easy to stick with 1 version.
> 
> Obviously a little biased, but that's my 2 cents.
> 
> On Sep 28, 8:37 am, Joshua Russo  wrote:
>> MooTools does look interesting. What would you miss most about it, if you
>> had to develop without it?
>>
>>
>>
>> On Mon, Sep 28, 2009 at 11:07 AM, justind  wrote:
>>
>>> Joshua,
>>> Take a look at MooTools. It's a great library with a great API. It's
>>> been said that JQuery makes the DOM fun, but MooTools makes Javascript
>>> fun.
>>> On Sep 28, 4:37 am, Joshua Russo  wrote:
 On Mon, Sep 28, 2009 at 4:00 AM, Jani Tiainen  wrote:
> Joshua Russo kirjoitti:
>> Great links guys, thanks. I'm still in the mindset of frameworks just
>> making JavaScript less painful too and I'm looking for ways to move
>> beyond that. I just started looking at Dojo before posting this and
>>> it
>> definitely looks like it has potential.
> I'm pretty "heavy" user of Dojo. My project is completely built on top
> of Django/Dojo using JSON-RPC to do talk with Django part.
> I'm pretty happy how it works, specially declarative way to make
>>> widgets
> is pretty cool comparing to other that usually require JS markup to
> achieve same thing.
> Dojango is pretty nice. I just don't use (model)forms all.
 Do you use the Admin app at all? Or are your sites all just custom views?
> > 
> 
> 


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

2009-10-27 Thread Mike Dewhirst

Todd Blanchard wrote:
> Total django noob here.  Rails/PHP/WebObjects refugee here.
> 
> I'm starting a project where some models need to be fully versioned.
> 
> IOW, record update is forbidden - every save to a changed model should  
> result in a new record with a new version number or timestamp along  
> with identity pulled from the current authenticated user's session.   
> Queries/relationships should be specified as "fetch newest" or "fetch  
> history".  IOW sometimes I want to traverse a relationship and just  
> get the "current" record.  Sometimes I want to get the history of that  
> relationship.
> 
> Anybody done this?  Got any tips?

Marty Allchin has documented this very precisely and eloquently in 
chapter 11 of his Pro Django published recently by Apress.

Highly recommended :)

Cheers

Mike
> 
> Thanks,
> -Todd Blanchard
> 
> > 
> 
> 


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



setting up headache migrating to apache

2009-10-29 Thread Mike Dewhirst

I'm trying to replicate my (working ok) winxp testing environment on 
openSuSE 11.1 with Apache2 as a parallel testing environment. We're 
nowhere near production at the moment.

The problem I'm having on openSuSE when i try /usr/bin/python 
/srv/www/vhosts/ccm/climate/ccm/tests.py is ...

Traceback (most recent call last):
   File "/srv/www/vhosts/ccm/climate/ccm/tests.py", line 7, in 
 from django.contrib.auth.models import User
   File 
"/usr/lib64/python2.6/site-packages/django/contrib/auth/models.py", line 
6, in 
 from django.db import models
   File "/usr/lib64/python2.6/site-packages/django/db/__init__.py", line 
10, in 
 if not settings.DATABASE_ENGINE:
   File "/usr/lib64/python2.6/site-packages/django/utils/functional.py", 
line 268, in __getattr__
 self._setup()
   File "/usr/lib64/python2.6/site-packages/django/conf/__init__.py", 
line 38, in _setup
 raise ImportError("Settings cannot be imported, because environment 
variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable 
DJANGO_SETTINGS_MODULE is undefined.

... BUT ...

in /etc/pythonstart

   
   import sys
   sys.path.append('/srv/www/vhosts/ccm')
   

... AND ...

in /etc/profile.local
   export DJANGO_SETTINGS_MODULE=climate.settings

Then after restarting the computer, os.environ includes ...
'DJANGO_SETTINGS_MODULE': 'climate.settings',
... among all the other environment variables.

Physically, the settings file is ...

   /srv/www/vhosts/ccm/climate/settings.py

... and I can launch /usr/bin/python (2.6.0 as provided by openSuSE 
11.1) and prove /srv/www/vhosts/ccm/ is on the pythonpath by doing ...

~>/usr/bin/python
Python 2.6 (r26:66714, Feb  3 2009, 20:49:49)
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import climate.settings
ldaps://192.168.0.188:636
 >>>

... where the above output is embedded in a print statement in 
settings.py and proves there are no syntax errors in settings.py

I have also tried all the above as root and get the same results so I 
don't think it is a permissions thing.

Can any kind person see where I'm going wrong?



Thanks

Mike


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



media_url tute

2009-11-13 Thread Mike Dewhirst
I have looked at the django docs 
(http://docs.djangoproject.com/en/dev/topics/forms/media/) which 
painstakingly describe how to set up MEDIA_ROOT and MEDIA_URL.

Does anyone know of a tutorial or other docco which covers the topic?

Thanks

Mike

--

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




Re: Restrict admin to superusers only

2009-11-27 Thread Mike Dewhirst
chefsmart wrote:
> Is there a way to allow only superusers to login to and use the admin
> section? Users with is_staff = True do exist and that can't be changed
> because this app is in use and makes use of is_staff in some other
> way.

I believe so. Create a group (say no_admin?) with no permissions and put 
each of your is_staff=True users into that group. At the same time 
remove all their personally assigned permissions.

Should do the trick.

I would create a test user and try it out to ensure things still work 
properly.

Mike

> 
> Can this be achieved without changing the code in contrib.admin or
> contrib.auth?
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> 

--

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




Re: Custom Authentication Backend

2009-12-02 Thread Mike Dewhirst
bfrederi wrote:
> I am writing my own custom authentication for AD/ldap and I am trying
> to authenticate the user without saving the user in the Django User
> table. I also don't want the user to have to log in every time they
> want to view something. Is there any way to not save the user in the
> Django User table and keep them authenticated? I don't require them to
> access admin or anything, I just need them to be authenticated.
> 
> So far I have this as my backend (the ldap backend it falls back on
> after the default backend):
> http://dpaste.com/hold/128199/
> 
> But when I use that code, it is still saving the User model instance.
> I know, because the next time I log in I get a "Duplicate entry". I
> don't want to have to make a user for every person that logs into my
> django site via their ldap credentials if I can avoid it. 

It isn't clear to me that you want to avoid the effort of putting a user 
in or whether you really want to avoid having them in the Django database.

If you just want to avoid the effort and don't mind them being in there 
I can recommend Peter Herndon's django_ldap_groups ...

http://code.google.com/p/django-ldap-groups/

... which I have recently installed and it works very well.

This kit automatically inserts the user from the AD or eDirectory into 
the Django database complete with whatever info you want to extract and 
also putting them into Django groups you have related to AD or eD groups.

This lets users login with ldap auth and if the ldap server is down they 
can log into the Django app using Django auth.

Regards

Mike

I would
> greatly appreciate it if someone could point me in the right
> direction, or tell me what I'm doing wrong.
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> 

--

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




design starting question

2009-12-09 Thread Mike Dewhirst
I want to design a site to replace an existing one running on my 
client's Windows 2008 server.

Currently, external users are given manually generated basic auth login 
credentials to view their own directory on the server. It is running 
Apache 2.2 and there is zero html and no database.

The documents in the customer directories are pdf consignment notes and 
delivery dockets which form a rudimentary proof of delivery system.

The new requirement is for external users to have a search facility for 
documents in their own branch of the directory tree. For example, the 
customers know some or all of the filename (document numbers are in the 
filenames) and want to go directly to the pdf file. They also know the 
date (perhaps roughly) of a document.

The documents are produced by a separate system and just appear in the 
customer directories. There is no way to actively link that production 
event with a new app.

I'm not sure what to do.

Is there a way to treat the Windows directory structure like a database?

If so, is that a Django thing or just Python?

I like the URLConf potential for a customer to type in the base URL, a 
slash and a fragment of the document name to trigger a direct display if 
there is only one search result but a list if there is more than one.

Thanks for any ideas

Mike

--

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




Re: LDAP-groups problem

2009-12-17 Thread Mike Dewhirst
Wayne wrote:
> Hi,
> 
> I tried to use djando-ldap-groups but got some errors from database
> configuration. Could somebody shed some light on the possible problems
> of my set up?
> 



Maybe the Oracle API is translating the PK into a LOB? If LOB is a large 
object then that is probably the issue.

I can say there is no problem with that particular app with PostgreSQL.

> cx_Oracle.DatabaseError: ORA-02329: column of datatype LOB cannot be
> unique or a
>  primary key
> 
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> 

--

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




why wordpress

2010-04-15 Thread Mike Dewhirst
I have just been asked by a client to install Wordpress for them. 
Someone in the marketing department apparently wants a blog for the 
organisation.


I'd prefer to avoid php so I'm wondering if anyone knows of a Python or 
even better a Django equivalent?


Thanks

Mike

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



Re: why wordpress

2010-04-15 Thread Mike Dewhirst

On 16/04/2010 11:15am, CLIFFORD ILKAY wrote:

On 04/15/2010 08:37 PM, Mike Dewhirst wrote:

I have just been asked by a client to install Wordpress for them.
Someone in the marketing department apparently wants a blog for the
organisation.

I'd prefer to avoid php so I'm wondering if anyone knows of a Python
or even better a Django equivalent?


Plenty of choices here:
<http://blog.montylounge.com/2010/02/10/eleven-django-blog-engines-you-should-know/>.
I used django-article on a recent project and found it easy to incorporate.



Thanks Clifford - great :)

Mike

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



Re: why wordpress

2010-04-15 Thread Mike Dewhirst

On 16/04/2010 4:47pm, Xavier Ordoquy wrote:


Le 16 avr. 2010 à 03:18, CLIFFORD ILKAY a écrit :


On 04/15/2010 09:13 PM, Shawn Milochik wrote:

There are probably a thousand blogging apps done in Django, because
it seems that a lot of people make one when they discover Django.

However, I think you should give them the Wordpress they asked for,
because it's maintained for security by a large organization for
free. Unless you plan to constantly maintain the Django app for
them.


Perhaps Wordpress needs constant maintenance because it wasn't very 
well-written in the first place. I'd rather be responsible for a Django 
application any day than Wordpress. Even if a large organization maintains 
Wordpress, I wouldn't want to be responsible for maintaining an installation of 
Wordpress without being paid well for support because you will be on a constant 
upgrade treadmill.


Not to mention the way wordpress plugins serialize configuration informations 
(paths, IPs, urls) making wordpress almost impossible to move across servers or 
even just moving the installation path.


Thaanks for the heads-up

Mike




Regards,
Xavier.



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



Re: GUI builder for django

2010-04-21 Thread Mike Dewhirst

On 22/04/2010 8:10am, andres osinski wrote:

No, and it's not a good idea to do WYSIWYG development for HTML. HTML is
not a format that produces static content; it varies depending on screen
fonts, browser, and platform, and getting that right means sticking to
relative layout, making content flow, and taking care of quirks. WYSIWYG
editors don't do any of that. and the quality of their output is dubious
at best.
Taking the time to produce sane HTML and CSS is a must for web
development, but it's not that difficult a task and the knowledge to do
it can be learned in a few days.


I agree. I have used WYSIWYG editors for static pages in the past and I 
guess I would again under appropriate circumstances. I still have 
Dreamweaver.


For Django however, the only way forward is to use css to lay out your 
pages and logic to populate them. The quantity of actual html code ought 
to be deliberately reduced to the absolute minimum for reasons of 
maintainability and re-use.


Here are a couple of links which might help ...

http://jeffcroft.com/blog/2006/feb/25/django-templates-the-power-of-inheritance/

http://www.djangobook.com/en/2.0/chapter04/

It is easy to understand. A little effort now will save you vast effort 
later. It isn't too steep to get up there.


Good luck.



Thanks

On Wed, Apr 21, 2010 at 6:28 PM, John Finlay mailto:fin...@moeraki.com>> wrote:

I'm just getting started with django coming from a background of
developing desktop apps on *nix. Is there something equivalent to a
GUI builder for django?

Alternatively, is there a good WYSIWYG html editor that produces
editable html so I could quickly create a template and then retrofit
it with django template tags?

Thanks

John

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




--
Andrés Osinski
http://www.andresosinski.com.ar/

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


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



Re: New User Stuck on Tutorial Part 2

2010-05-10 Thread Mike Dewhirst

On 11/05/2010 3:42pm, Old Davy wrote:

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely
not in the right place.

Ensure that you have a template dir that your settings knows about,
and that template dir has a subdirectory called 'admin' where that
file is placed.

Shawn


That would make the most sense, and that would be my working assumption.
But I can't for the life of me see where the disconnect is.

this is the string that's in the TEMPLATE_DIRS section of my settings.py
file:

"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html"


You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS

This is mine ...

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates').replace('\\','/'),)

This puts my templates directory in the same dir as my settings.py file.

Inside it I have a sub-dir for each application for which I want 
templates. For example, in one of them I have ...


../templates/admin/base_site.html

Which contains ...

{% extends "base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {% trans 'Mysite site admin' %}{% endblock %}

{% block branding %}
{% trans 'Mysite administration' %}
{% endblock %}

... and which turns Django Admin into Mysite admin. However, the 
"base.html" which it extends is actually in ../templates


If I wanted Mysite base_site.html to extend the real Django base.html I 
would have to put ... {% extends "admin/base.html" %}


HTH

Mike





That's exactly the path that my directories show, including my
idiosyncratic upper case letters.

I did find the file that my poll app is referencing. Turns out it was in
my '/usr/local/lib/python2.6... path instead of my home directory. So
when I modified THAT file, it used my changes. However, that still
doesn't help, as it's not using the file that I copied to my local
directory.

I suppose I can play with a few more directories and see what happens...



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



Re: New User Stuck on Tutorial Part 2

2010-05-10 Thread Mike Dewhirst

On 11/05/2010 4:18pm, Old Davy wrote:

Thank you, Mike.  That DID work!

So, if I have a directory that contains the /admin/base_site.html, all I
have to do is specify the containing directory.

I'll need to study the actual string you used a little more closely once
I get more familiar with the concepts. I can see how that would give you
some added flexibility, but I'm not quite grokking the details yet.


OK - here is more room for confusion ...

In my settings.py ...

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)).replace('\\','/')

This is Python for getting the current directory path to the file in 
which the above code appears. Since it is in settings.py it returns my 
PROJECT_ROOT. The replace() just makes it cross-platform because I work 
in both Windows and Linux.


What follows is also in settings.py and is what makes what I said in my 
previous email true. Notice the comment? If filesystem loader appeared 
*after* the app_directories loader my previous email would have taken 
you right to the fairies at the end of the garden path.


TEMPLATE_LOADERS = (
# filesystem ahead of app_directories looks in project before django
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.eggs.load_template_source',

Mike



Still, at least I can continue the tutorial without that "mired in the
mud" feeling. Thank you very much!!!



On 05/10/2010 11:04 PM, Mike Dewhirst wrote:

On 11/05/2010 3:42pm, Old Davy wrote:

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely
not in the right place.

Ensure that you have a template dir that your settings knows about,
and that template dir has a subdirectory called 'admin' where that
file is placed.

Shawn


That would make the most sense, and that would be my working assumption.
But I can't for the life of me see where the disconnect is.

this is the string that's in the TEMPLATE_DIRS section of my settings.py
file:

"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html"



You want a directory rather than a file (base_site.html) for
TEMPLATE_DIRS

This is mine ...

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT,
'templates').replace('\\','/'),)

This puts my templates directory in the same dir as my settings.py file.

Inside it I have a sub-dir for each application for which I want
templates. For example, in one of them I have ...

../templates/admin/base_site.html

Which contains ...

{% extends "base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {% trans 'Mysite site admin' %}{%
endblock %}

{% block branding %}
{% trans 'Mysite administration' %}
{% endblock %}

... and which turns Django Admin into Mysite admin. However, the
"base.html" which it extends is actually in ../templates

If I wanted Mysite base_site.html to extend the real Django base.html
I would have to put ... {% extends "admin/base.html" %}

HTH

Mike





That's exactly the path that my directories show, including my
idiosyncratic upper case letters.

I did find the file that my poll app is referencing. Turns out it was in
my '/usr/local/lib/python2.6... path instead of my home directory. So
when I modified THAT file, it used my changes. However, that still
doesn't help, as it's not using the file that I copied to my local
directory.

I suppose I can play with a few more directories and see what happens...







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



Re: New User Stuck on Tutorial Part 2

2010-05-10 Thread Mike Dewhirst

On 11/05/2010 4:04pm, Mike Dewhirst wrote:

On 11/05/2010 3:42pm, Old Davy wrote:

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely
not in the right place.

Ensure that you have a template dir that your settings knows about,
and that template dir has a subdirectory called 'admin' where that
file is placed.

Shawn


That would make the most sense, and that would be my working assumption.
But I can't for the life of me see where the disconnect is.

this is the string that's in the TEMPLATE_DIRS section of my settings.py
file:

"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html"



You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS

This is mine ...

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT,
'templates').replace('\\','/'),)

This puts my templates directory in the same dir as my settings.py file.

Inside it I have a sub-dir for each application for which I want
templates. For example, in one of them I have ...

../templates/admin/base_site.html

Which contains ...

{% extends "base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {% trans 'Mysite site admin' %}{%
endblock %}

{% block branding %}
{% trans 'Mysite administration' %}
{% endblock %}

... and which turns Django Admin into Mysite admin. However, the
"base.html" which it extends is actually in ../templates

If I wanted Mysite base_site.html to extend the real Django base.html I
would have to put ... {% extends "admin/base.html" %}


Just realised I could have confused you a little.

So

You can extend anything you want to specifically nominate but if you 
just nominate a bare filename the way I do with base.html in ...


   mysite/templates/admin/base_site.html

... base.html has to exist in TEMPLATE_DIRS (mysite/templates)

If you want to extend "admin/base.html" from the above base_site.html 
then Django looks first in ...


   TEMPLATES_DIR/admin

... and if it doesn't find it then it looks in 
site-packages/django/contrib/admin/templates/admin


Mike



HTH

Mike





That's exactly the path that my directories show, including my
idiosyncratic upper case letters.

I did find the file that my poll app is referencing. Turns out it was in
my '/usr/local/lib/python2.6... path instead of my home directory. So
when I modified THAT file, it used my changes. However, that still
doesn't help, as it's not using the file that I copied to my local
directory.

I suppose I can play with a few more directories and see what happens...






--

Climate Pty Ltd
PO Box 308
Mount Eliza
Vic 3930
Australia +61

T: 03 9787 6598
M: 0411 704 143

Mike Dewhirst
Certified Scrum Master


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



template url tag fetches wrong URL with generic view

2010-05-12 Thread Mike Dewhirst
I'm working through the Coltrane weblog tutorial and trying to implement 
semi-hard-coded breadcrumbs. It seems reverse doesn't like what I've done.


This is the template inheritance chain ...

1. Salient parts of underlying template ...

{% block breadcrumbs %}{{ block.super }}
  › Mike's Blog
{% endblock %}


2. A separate template coltrane/entry_archive.html inherits the above 
breadcrumbs properly with block.super. It contains a link to a blog 
entry which successfully brings up a page containing the full entry via 
a generic view and coltrane/entry_detail.html but ...



3. I have a problem in breadcrumbs in coltrane/entry_detail.html ...

{% block breadcrumbs %}{{ block.super }}
  › Entries
  › Entry detail
{% endblock %}

... and here the url tag fetches the wrong URL. Instead of rendering 
entry_archive.html as I expected, it renders entry_detail.html with 
exactly the same detail as the link in 2 above.


I have tried closing down the dev server and browser and starting again 
but the same thing happens.


My urls.py and /urls/*.py files are as documented in the book.

Where have I gone astray?

Thanks

Mike

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



[Solved] template url tag fetches wrong URL with generic view

2010-05-12 Thread Mike Dewhirst

On 13/05/2010 12:43pm, Mike Dewhirst wrote:

I'm working through the Coltrane weblog tutorial and trying to implement
semi-hard-coded breadcrumbs. It seems reverse doesn't like what I've done.


Totally fair. I don't like what I did either.

In 3. below I left out the = between href and the url tag.

Sorry to bother you

Mike



This is the template inheritance chain ...

1. Salient parts of underlying template ...

{% block breadcrumbs %}{{ block.super }}
› Mike's Blog
{% endblock %}


2. A separate template coltrane/entry_archive.html inherits the above
breadcrumbs properly with block.super. It contains a link to a blog
entry which successfully brings up a page containing the full entry via
a generic view and coltrane/entry_detail.html but ...


3. I have a problem in breadcrumbs in coltrane/entry_detail.html ...

{% block breadcrumbs %}{{ block.super }}
› Entries
› Entry detail
{% endblock %}

... and here the url tag fetches the wrong URL. Instead of rendering
entry_archive.html as I expected, it renders entry_detail.html with
exactly the same detail as the link in 2 above.

I have tried closing down the dev server and browser and starting again
but the same thing happens.

My urls.py and /urls/*.py files are as documented in the book.

Where have I gone astray?

Thanks

Mike



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



Re: Uploaded File Security

2010-05-19 Thread Mike Dewhirst

On 20/05/2010 11:00am, Lee Hinde wrote:

I'm working on an intranet app for a client that will have file uploads.
I'm early in the process, but have the uploading working just fine via
admin.

Once we get to deployment, I'm unclear on how to coordinate the security
that django will know about (group X has access to X's files, but not
group Y's),

When I poke around for discussions on protecting uploaded files, the
most recent and seemingly on point discussion is here:

http://stackoverflow.com/questions/2780893/django-authentication-htaccess-static

Which is basically suggesting that one hash the name and hope that
no-one guesses the resulting path.

What's best practice here?


If it has to be secure rather than just wishful thinking the webserver 
must demand credentials. If you are using Apache, that means .htaccess 
files which point to a list of credentials for each group.


Maybe you could obtain a django authentication backend which Apache can 
use as well? On an Intranet you should be able to access LDAP 
connectivity somewhere - Microsoft AD, Novell eDirectory or Linux LDAP.


I'm very interested in your progress here because I have to travel this 
road in the medium term future.


I have done a test implementation of Peter Herndon's django-ldap-groups 
with eDir and one of the next steps for me is to look at the Apache LDAP 
docs.


http://code.google.com/p/django-ldap-groups/

Good luck

Mike



Thanks.

   - Lee

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


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



Re: Built in password reset views resulting in Caught NoReverseMatch while rendering: Reverse for 'django.contrib.auth.views.password_reset_confirm'

2010-05-30 Thread Mike Dewhirst

Simon

Have considered the sequence in which templates are loaded?

See http://docs.djangoproject.com/en/dev/ref/settings/

If you put the filesystem template loader ahead of the app_directories 
django will find your own versions named identically with django 
versions and use them instead.


TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)

hth

Mike

On 30/05/2010 11:49pm, Cromulent wrote:

Well I got it working by changing the names of my templates to
something other than the default value. This seems like a bug to me.
Surely Django should use a provided template if it is available and
only fall back on the built in ones as an absolute last resort?
Especially as I had specified in the dictionary the correct template
name and that they were available.

On May 30, 10:41 am, Cromulent  wrote:

I'm using Django 1.2.1 on Mac OS X with Python 2.6.1 if that matters.
I've read the documentation and this is what I have for my urls.py
file:

password_reset_dict = {
 'post_reset_redirect' : '/profiles/login/',
 'email_template_name' : 'registration/password_reset_email.html',
 'template_name' : 'registration/password_reset_form.html',

}

password_reset_confirm_dict = {
 'template_name' : 'registration/password_reset_confirm.html',
 'post_reset_redirect':'/profiles/login/',

}

(r'^reset/$', 'django.contrib.auth.views.password_reset',
password_reset_dict),

(r'^reset/confirm/$',
'django.contrib.auth.views.password_reset_confirm', \
password_reset_confirm_dict),

(r'^reset/done/$', 'django.contrib.auth.views.password_reset_done'),

(r'^reset/complete/$',
'django.contrib.auth.views.password_reset_complete'),

The strange thing is that when the error comes back the generic view
does not seem to be using the templates that I have specified in the
dictionary, instead the error points to the internal
password_reset_email.html template and this line in particular:

{{ protocol }}://{{ domain }}{% url
django.contrib.auth.views.password_reset_confirm uidb36=uid
token=token %}

I've done a fair bit of Googling and tried the various methods
mentioned but the ones that seemed most promising require you to
change the template and as it does not actually get to my template I'm
at a bit of a loss.

Can anyone tell me where I am going wrong with this at all?

Any help is very much appreciated.




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



Re: Built in password reset views resulting in Caught NoReverseMatch while rendering: Reverse for 'django.contrib.auth.views.password_reset_confirm'

2010-05-31 Thread Mike Dewhirst

On 1/06/2010 6:20am, Cromulent wrote:

Hi Mike,

Thanks for the response. I did think of that. My template loaders
setting is as follows:

TEMPLATE_LOADERS = (
 'django.template.loaders.app_directories.Loader',
 'django.template.loaders.filesystem.Loader',
)

all of my templates are stored in the template directory for each
individual Django application to save on cross dependencies or global
dependencies as I want to maximise the modularity of them. From
reading the docs the app_directories loader is the correct one for
this situation.


I'm not sure this is correct but that is just my own uncertainty because 
I haven't read those docs recently. However I took a different approach 
which probably came from following one of the django books.


# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates')

My PROJECT_ROOT is the path to settings.py


The problem with the filesystem loader is that you need to specify all
your template paths in the settings file, which is something I was
trying to avoid as the app_directories loader was what I wanted.


As you can see I only specify one templates dir. If I want to use my own 
templates for an imported app (or my own for that matter) I just create 
a sub-directory in TEMPLATE_DIRS and give it the app name. Django just 
knows where to look and uses any template it finds there in preference 
to one of the same name in the installed site-packages app.


Cheers

Mike


I guess the app_directories loader works on the order of apps listed in
the INSTALLED_APPS tuple?


I don't know. You'd need to lok at the gjango source to get that.



On May 31, 2:05 am, Mike Dewhirst  wrote:

Simon

Have considered the sequence in which templates are loaded?

Seehttp://docs.djangoproject.com/en/dev/ref/settings/

If you put the filesystem template loader ahead of the app_directories
django will find your own versions named identically with django
versions and use them instead.

TEMPLATE_LOADERS = (
  'django.template.loaders.filesystem.load_template_source',
  'django.template.loaders.app_directories.load_template_source',
)

hth

Mike

On 30/05/2010 11:49pm, Cromulent wrote:




Well I got it working by changing the names of my templates to
something other than the default value. This seems like a bug to me.
Surely Django should use a provided template if it is available and
only fall back on the built in ones as an absolute last resort?
Especially as I had specified in the dictionary the correct template
name and that they were available.



On May 30, 10:41 am, Cromulentwrote:

I'm using Django 1.2.1 on Mac OS X with Python 2.6.1 if that matters.
I've read the documentation and this is what I have for my urls.py
file:



password_reset_dict = {
  'post_reset_redirect' : '/profiles/login/',
  'email_template_name' : 'registration/password_reset_email.html',
  'template_name' : 'registration/password_reset_form.html',



}



password_reset_confirm_dict = {
  'template_name' : 'registration/password_reset_confirm.html',
  'post_reset_redirect':'/profiles/login/',



}



(r'^reset/$', 'django.contrib.auth.views.password_reset',
password_reset_dict),



(r'^reset/confirm/$',
'django.contrib.auth.views.password_reset_confirm', \
password_reset_confirm_dict),



(r'^reset/done/$', 'django.contrib.auth.views.password_reset_done'),



(r'^reset/complete/$',
'django.contrib.auth.views.password_reset_complete'),



The strange thing is that when the error comes back the generic view
does not seem to be using the templates that I have specified in the
dictionary, instead the error points to the internal
password_reset_email.html template and this line in particular:



{{ protocol }}://{{ domain }}{% url
django.contrib.auth.views.password_reset_confirm uidb36=uid
token=token %}



I've done a fair bit of Googling and tried the various methods
mentioned but the ones that seemed most promising require you to
change the template and as it does not actually get to my template I'm
at a bit of a loss.



Can anyone tell me where I am going wrong with this at all?



Any help is very much appreciated.




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



Re: Directory structuring

2010-06-03 Thread Mike Dewhirst

EJ - one comment below ...

On 4/06/2010 11:41am, EJ wrote:

Hi guys, first of all: Thanks! Django-users has been a great resource
for me so far; I've come across many solutions for my own problems
here.

I'm not even really sure if this question is totally appropriate for
this page, but here goes:

I'm a new developer working on a small social networking website which
has grown pretty tremendously since I've started my job (about 8-9
months ago).  I've had no training except for what I've learnt on the
job, some of which has been from another fairly new developer.  So far
I've been able to see examples on the internet of how to do things and
follow them without too much trouble, but I've found that the
development environment now is very insufficient and totally
backwards, and I have no idea what to do or how to fix it.

At the moment, every time we get a new organisation to sign up and
start using our software, we create a new apache, django, python, and
software installation, which simply duplicates the software in each
app.

All of our app software is in subversion control except for a few
files (base.html, team.html and localsettings.py are the main ones)
that change between each site, as they are 'skinned' differently 'ie
have different colours, header images, slightly different content etc'

I'm trying (and struggling) to somehow put all of these files under
version control and still have the ability to maintain each site
individually, as well as add new (python-based and template-based)
functions, features and bugfixes across the whole software.

At the moment the environment is like this:
In ~/webapps/ there's a directory for each organisation/site, and each
of those directories contains /apache2/, /bin/, /lib/, and /vanilla/
(our software).

For each organisation, they simply go to http://(their
name).vteam.com.au and see the site in their skin.

Currently when I have to roll out a change or bugfix I edit my
development site, test it, make sure it works, and then I run a script
which simply runs "svn update" on all the other apps (and an apache
restart if it's a python change)

This doesn't seem to be very sustainable or efficient...
a) It's not the standard.  I've looked around at subversion repository
tutorials but can't seem to wrap my head around applying that to our
software.
b) Sometimes we need to change something on one site, but can't as the
file is under version control and may cause a clash when I try to
update it for a different fix later.


Have you tried doing a subversion 'export' instead of 'update'?

That means the production stuff is not under version control and 
therefore cannot clash.


Give the user which runs your script sufficient privileges to completely 
remove the directory trees, completely recreate them, export from svn 
and then chown, chmod as required and touch your wsgi script so you 
don't have to restart Apache.


hth

Mike


c) If I'm working on a large job on a certain file on my development
site, I can't commit that file to roll out a quick bug fix.

I'm wondering if anybody has had or seen a similar situation.  Help or
advice would be appreciated muchly!

Thanks,
Ethan



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



Re: setting DEBUG=False disables flatpages

2010-06-08 Thread Mike Dewhirst

On 8/06/2010 4:58pm, adrian wrote:

Hello Guys,

on all my projects I have the problem that setting DEBUG=False in
settings.py disables flatpages (404 Pages are displayed).
This also applies to newly created projects. This happens with Django
version 1.2.1. Can someone confirm this with his deployments?


I just changed to DEBUG = False and had a look at a flatpage with the 
dev server and it works fine for me.


Python 2.6.5, django 1.2.x (head)

Mike



Additionally if running the "manage.py runserver" or as fcgi with
DEBUG=False the return codes are always 200 (even if the page
displayed is my 404 page). Is also in this case someone able to
confirm this?

I have found a ticket with number  "http://code.djangoproject.com/
ticket/13673" where the behavior is also mentioned - but it is still
unreviewed since more than a week.


Best Regards,

Adrian



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



Re: how to develop cms on django

2010-07-19 Thread Mike Dewhirst

On 19/07/2010 7:02pm, Dmitry Dulepov wrote:

Hi!

Julio Cesar Rodriguez Cruz wrote:

sir i am a beginner in python and django..

i want develop a content management system using django..


It is a bit late to respond to this but I have to say it: you are going to
fail this project. Why? Can you imagine yourself saying: "I need to develop
a passenger aircraft (such as Boeing) completely, in a month time without
any prior knowledge of aircraft development"? Basically this is what you
said in your mail. There are too many things to consider if you want to
develop a CMS. I know because I am one of TYPO3 CMS developers. You simply
can't do that in a short time frame with am unknown technology. Forget it.
This is a planned failure.



Hey - not necessarily!

I think failure isn't part of the plan. I think Julio just wants some 
feedback on how fabulous django is. So here it is ...


Django is fabulous.

There is only one way to make a CMS happen quickly. Find an existing 
django CMS and implement that. You can google for one.


You also might need to find a django hosting provider who will install 
it for you.


While the hosting provider is getting your CMS up and running, you 
should work through the examples in the django docs. With that under 
your belt, buy James Bennett's Practical Django Projects and work your 
way through that too.


At that point you will be in a position to look at the source code of 
the CMS you implemented via your hosting provider and make any 
configuration tweaks which suit your needs.


Good luck


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



data import and auto-incrementing id columns

2010-07-20 Thread Mike Dewhirst
The data I want to import is in Paradox tables and that can be easily 
exported in any format.


However, I believe the id columns in Paradox are gunna have to be used 
to re-establish relationships (1:n and n:m) in PostgreSQL.


How is this going to work when django models specify auto-incrementing 
fields for those columns?


At this point I'm just trying to establish a dump and repeatable pump 
(drop, create, bulk insert) process driven by scripts so I can quickly 
morph the destination as I change my mind during django development.


I can't quite see how to avoid using existing Paradox keys.

Thanks for any hints

Mike

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



Re: No fixtures found

2010-07-25 Thread Mike Dewhirst

John

It looks like you mis-spelled slightly ...

> ... 'django.contrib.sessi[o]ns.middleware.Session(s)Middleware',

It should be django.contrib.sessions.middleware.SessionMiddleware but 
you have probably discovered that already.


Cheers

Mike

On 26/07/2010 6:59am, john wrote:

I still don't see why I am getting the error messages:
Traceback:
File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1-
py2.6.egg/django/core/handlers/base.py" in get_response
   80. response = middleware_method(request)
File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1-
py2.6.egg/django/contrib/auth/middleware.py" in process_request
   15. assert hasattr(request, 'session'), "The Django
authentication middleware requires session middleware to be installed.
Edit your MIDDLEWARE_CLASSES setting to insert
'django.contrib.sessions.middleware.SessionMiddleware'."

Exception Type: AssertionError at /admin
Exception Value: The Django authentication middleware requires session
middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to
insert 'django.contrib.sessions.middleware.SessionMiddleware'.

My MIDDLEWARE_CLASSES is as follows.

  MIDDLEWARE_CLASSES = (
... 'django.contrib.auth.middleware.AuthenticationMiddleware',
... 'django.contrib.sessins.middleware.SessionsMiddleware',
... 'django.middleware.common.CommonMiddleware',
... )
when I try and run my app.  The traceback says I need to edit my
middleware classes, but the requested modual is already in the
middleware_classes.

On Jul 25, 2:51 pm, n3ph  wrote:

   Am 25.07.2010 21:36, schrieb Daniel Roseman:


On Jul 25, 8:11 pm, johnwrote:

I got the message 'No fixtures found' when I ran the python manage.py
syncdb command.  I am working in sqlite3 which seems to be working as
evidenced by the fact that if I type sqlite in a terminal I get the
sqlite>.



The first time I got the following output, followed by the
aforementioned message.  Subsequent syncdb's just return the
message.

So what's the problem with that? Have you in fact defined any
fixtures? Do you need any?
--
DR.


Right, this isn't really a problem.. unless you need and had defined
some fixtures... if not - don't care about




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



Re: No fixtures found

2010-07-25 Thread Mike Dewhirst

On 26/07/2010 5:11am, john wrote:

I got the message 'No fixtures found' when I ran the python manage.py
syncdb command.  I am working in sqlite3 which seems to be working as
evidenced by the fact that if I type sqlite in a terminal I get the
sqlite>.

The first time I got the following output, followed by the
aforementioned message.  Subsequent syncdb's just return the
message.


This is normal behaviour. syncdb does nothing if the table already 
exists - in other words it works only once to create a new table 
deliberately in case you have inserted data. You wouldn't want it to 
repeat a create and wipe out your data.


If it doesn't discover any new tables to create it reports 'No fixtures 
found'


If you want to adjust a table this means you need to dump all data in 
the table to a receptacle somewhere, change the defining class in 
models.py then drop the table and run syncdb again. Finally you need a 
script to adjust your dumped data and pump it back into the new table. 
This is a very common process and Google will help when you need to do it.


HTH

Mike




Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
...
Installing index for admin.LogEntry model
Installing index for auth.Permission model
Installing index for auth.Group_permissions model
Installing index for auth.User_user_permissions model
Installing index for auth.User_groups model
Installing index for auth.Message model
No fixtures found.

The Traceback is:
Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin
Django Version: 1.2.1
Python Version: 2.6.4
Installed Applications:
['django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'mysite.books']
Installed Middleware:
('django.contrib.auth.middleware.AuthenticationMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.middleware.common.CommonMiddleware')


Traceback:
File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1-
py2.6.egg/django/core/handlers/base.py" in get_response
   80. response = middleware_method(request)
File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1-
py2.6.egg/django/contrib/auth/middleware.py" in process_request
   15. assert hasattr(request, 'session'), "The Django
authentication middleware requires session middleware to be installed.
Edit your MIDDLEWARE_CLASSES setting to insert
'django.contrib.sessions.middleware.SessionMiddleware'."

Exception Type: AssertionError at /admin
Exception Value: The Django authentication middleware requires session
middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to
insert 'django.contrib.sessions.middleware.SessionMiddleware'.

My MIDDLEWARE_CLASSES is as follows.

  MIDDLEWARE_CLASSES = (
... 'django.contrib.auth.middleware.AuthenticationMiddleware',
... 'django.contrib.sessins.middleware.SessionsMiddleware',
... 'django.middleware.common.CommonMiddleware',
... )



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



Re: How long do objects live?

2010-08-11 Thread Mike Dewhirst

On 12/08/2010 11:24am, Andy wrote:

When I create an object in Django, how long does it live?

When Django finishes responding to a HTTP request, the Python process
lives on to serve the next request. Does that mean all those objects
that were created would continue to hang around?


No. As soon as all references to an object are gone, the object is 
automatically garbage collected.


I think however that the web server might hang on to processes according 
to keep-alive settings.


Mike




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



Re: Create files and directories from Django 1.2.1

2010-08-14 Thread Mike Dewhirst

On 15/08/2010 12:10am, Mark Mooij wrote:

Hi all,

I recently migrated from Django 1.1.1 to 1.2.1. In 1.1.1 I had an
application which imports an external python script in which a
directory and some files are created. Since the migrate this doesn't
work anymore, I get a number of IOErrors because the files (and
directory) that should be created can't be found. I've tried changing
my directories and slashes (I'm using Windows), but no success.


Have you changed anything else?

For example, are you processing the Microsoft Windows update patches 
which (for WinXP) insert extra permission steps? Have you changed your 
OS from XP to Win7?


Can you post the source of the script?



Can't I use the os python functions anymore in Django 1.2.1? In the
documentation I've read about Managing files in models but I prefer to
handle this through my external script.

I hope anybody can help me.

Thanks,
Mark



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



Re: Create files and directories from Django 1.2.1

2010-08-15 Thread Mike Dewhirst

On 16/08/2010 1:06am, Mark Mooij wrote:

Hi Mike,

Thanks for your reply. I haven't changed anything else, I am
processing the MS updates, but I don't think this is the problem, as
this all worked fine before the migration to 1.2.1, also if I call the
script directly (outside Django) it works fine.
My view looks like this:
..
import createKML
..
def my_view(request, arg):
 ...
 createKML.createKML(arg)


I don't really know what is happening here that might have changed in 
1.2.1 maybe someone else can suggest something.


In the meantime here is suggested approach to discovering the exact 
problem ...


import os
...
def createKML(id, basepath="D:/path/to/mysite/templates/maps"):
...
try:
if id:
kmlpath = "%s/%s" % (basepath, str(id))
if not os.path.isdir(kmlpath):
os.makedirs(kmlpath)
writefile = "%s/%s" % (kmlpath, str(id))
f = open(writefile, 'wb')
else:
raise
except Exception as e:
print("id = %s\nbasepath = %s\n%s" % (id, basepath, e)
...


mike


 ...

In the createKML.py the problem arises in:
...
import os
...
def createKML(id):
...
os.mkdir("D:/path/to/mysite/templates/maps/"+str(id))
writefile = "D:/path/to/mysite/templates/maps/"+str(id)+"/"+str(id)
+ ".kml"
f = open(writefile, 'wb')
...

I hope this helps?


On 14 aug, 21:55, Mike Dewhirst  wrote:

On 15/08/2010 12:10am, Mark Mooij wrote:


Hi all,



I recently migrated from Django 1.1.1 to 1.2.1. In 1.1.1 I had an
application which imports an external python script in which a
directory and some files are created. Since the migrate this doesn't
work anymore, I get a number of IOErrors because the files (and
directory) that should be created can't be found. I've tried changing
my directories and slashes (I'm using Windows), but no success.


Have you changed anything else?

For example, are you processing the Microsoft Windows update patches
which (for WinXP) insert extra permission steps? Have you changed your
OS from XP to Win7?

Can you post the source of the script?






Can't I use the os python functions anymore in Django 1.2.1? In the
documentation I've read about Managing files in models but I prefer to
handle this through my external script.



I hope anybody can help me.



Thanks,
Mark




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



Re: Create files and directories from Django 1.2.1

2010-08-15 Thread Mike Dewhirst

On 16/08/2010 12:57pm, Mike Dewhirst wrote:

On 16/08/2010 1:06am, Mark Mooij wrote:

Hi Mike,

Thanks for your reply. I haven't changed anything else, I am
processing the MS updates, but I don't think this is the problem, as
this all worked fine before the migration to 1.2.1, also if I call the
script directly (outside Django) it works fine.
My view looks like this:
..
import createKML
..
def my_view(request, arg):
...
createKML.createKML(arg)


I don't really know what is happening here that might have changed in
1.2.1 maybe someone else can suggest something.

In the meantime here is suggested approach to discovering the exact
problem ...

import os
...
def createKML(id, basepath="D:/path/to/mysite/templates/maps"):
...
try:
if id:
kmlpath = "%s/%s" % (basepath, str(id))


actually .. kmlpath = "%s/%s" % (basepath, id)


if not os.path.isdir(kmlpath):
os.makedirs(kmlpath)
writefile = "%s/%s" % (kmlpath, str(id))


actually .. writefile = "%s/%s" % (kmlpath, id)


f = open(writefile, 'wb')
else:
raise
except Exception as e:
print("id = %s\nbasepath = %s\n%s" % (id, basepath, e)
...


mike


...

In the createKML.py the problem arises in:
...
import os
...
def createKML(id):
...
os.mkdir("D:/path/to/mysite/templates/maps/"+str(id))
writefile = "D:/path/to/mysite/templates/maps/"+str(id)+"/"+str(id)
+ ".kml"
f = open(writefile, 'wb')
...

I hope this helps?


On 14 aug, 21:55, Mike Dewhirst wrote:

On 15/08/2010 12:10am, Mark Mooij wrote:


Hi all,



I recently migrated from Django 1.1.1 to 1.2.1. In 1.1.1 I had an
application which imports an external python script in which a
directory and some files are created. Since the migrate this doesn't
work anymore, I get a number of IOErrors because the files (and
directory) that should be created can't be found. I've tried changing
my directories and slashes (I'm using Windows), but no success.


Have you changed anything else?

For example, are you processing the Microsoft Windows update patches
which (for WinXP) insert extra permission steps? Have you changed your
OS from XP to Win7?

Can you post the source of the script?






Can't I use the os python functions anymore in Django 1.2.1? In the
documentation I've read about Managing files in models but I prefer to
handle this through my external script.



I hope anybody can help me.



Thanks,
Mark






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



Re: Create files and directories from Django 1.2.1

2010-08-16 Thread Mike Dewhirst

On 16/08/2010 10:22pm, Doug Blank wrote:

On Mon, Aug 16, 2010 at 7:23 AM, Mark Mooij  wrote:

Allright I tried a couple of things with your suggested appraoch:







I doubt it. You shouldn't really do this:

kmlpath = "%s/%s" % (basepath, game_id)


I suggested this to avoid having to cast game_id as a string. I'm not 
all that knowledgeable about the upcoming Python 3 tsunami but I figure 
there will be less hassle if I use the inbuilt string formatting in %s. 
At least I hope so!




but do this:

kmlpath = os.path.join(basepath, game_id)


Now I have a question - more Python than Django. os.path.join is very 
clever but in Windows we have multiple approaches. One is to simply use 
forward slashes and rely on the infrastructure to know what to do and 
the other is to be agnostically cross-platform with os.path.sep and 
os.path.join. We can also use r'raw\backslashes' and 
u'C:\\escaped\\backslashes'


I have come unstuck using all of them at one time or another. I can't 
quite put my finger on it at the moment but I have also seen things like 
'C:\path\to/some/file.txt' arising from combinations of the approaches 
and surprisingly being successful.


So my question is, has anyone written a dissertation on the best 
approaches for particular circumstances?


Mike



as different OS's have different path formats. Or perhaps it is the
kml string that you are creating that has other issues (unicode?) I
would print out the mkdirs string to see what you are creating.

HTH,

-Doug


Mark

On 16 aug, 08:32, Mike Dewhirst  wrote:

On 16/08/2010 12:57pm, Mike Dewhirst wrote:






On 16/08/2010 1:06am, Mark Mooij wrote:

Hi Mike,



Thanks for your reply. I haven't changed anything else, I am
processing the MS updates, but I don't think this is the problem, as
this all worked fine before the migration to 1.2.1, also if I call the
script directly (outside Django) it works fine.
My view looks like this:
..
import createKML
..
def my_view(request, arg):
...
createKML.createKML(arg)



I don't really know what is happening here that might have changed in
1.2.1 maybe someone else can suggest something.



In the meantime here is suggested approach to discovering the exact
problem ...



import os
...
def createKML(id, basepath="D:/path/to/mysite/templates/maps"):
...
try:
if id:
kmlpath = "%s/%s" % (basepath, str(id))


actually .. kmlpath = "%s/%s" % (basepath, id)


if not os.path.isdir(kmlpath):
os.makedirs(kmlpath)
writefile = "%s/%s" % (kmlpath, str(id))


actually .. writefile = "%s/%s" % (kmlpath, id)




f = open(writefile, 'wb')
else:
raise
except Exception as e:
print("id = %s\nbasepath = %s\n%s" % (id, basepath, e)
...



mike



...



In the createKML.py the problem arises in:
...
import os
...
def createKML(id):
...
os.mkdir("D:/path/to/mysite/templates/maps/"+str(id))
writefile = "D:/path/to/mysite/templates/maps/"+str(id)+"/"+str(id)
+ ".kml"
f = open(writefile, 'wb')
...



I hope this helps?



On 14 aug, 21:55, Mike Dewhirst  wrote:

On 15/08/2010 12:10am, Mark Mooij wrote:



Hi all,



I recently migrated from Django 1.1.1 to 1.2.1. In 1.1.1 I had an
application which imports an external python script in which a
directory and some files are created. Since the migrate this doesn't
work anymore, I get a number of IOErrors because the files (and
directory) that should be created can't be found. I've tried changing
my directories and slashes (I'm using Windows), but no success.



Have you changed anything else?



For example, are you processing the Microsoft Windows update patches
which (for WinXP) insert extra permission steps? Have you changed your
OS from XP to Win7?



Can you post the source of the script?



Can't I use the os python functions anymore in Django 1.2.1? In the
documentation I've read about Managing files in models but I prefer to
handle this through my external script.



I hope anybody can help me.



Thanks,
Mark


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






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



Re: help with understanding tag cloud code

2010-08-22 Thread Mike Dewhirst

On 23/08/2010 11:17am, John Yeukhon Wong wrote:

Hi, I am confused with this piece of code. This is a code responsible
for building a tag cloud. It lives in the views.py

The part I don't understand is

 # Calculate tag, min and max counts.
 min_count = max_count = tags[0].bookmarks.count()

I never had used this 3 assignments in Python before. I also don't get
why it's tags[0]


x = y = z = 3
 is the same in Python as
z = 3
y = z
x = y

tags[0] is the first element of the tag list. In Python, lists and other 
iterables are zero-based.


hth


According to the book, it is iterating through the tag lists.
I really can't follow the logic there, and this also prevents me from
understanding the rest of the for loop

Thank you for any input!

//code begins

def tag_cloud_page(request):
 MAX_WEIGHT = 5
 tags = Tag.objects.order_by('name')
 # Calculate tag, min and max counts.
 min_count = max_count = tags[0].bookmarks.count()
 for tag in tags:
 tag.count = tag.bookmarks.count()
 if tag.count<  min_count:
  min_count = tag.count
 if max_count<  tag.count:
 max_count = tag.count
 # Calculate count range. Avoid dividing by zero.
 range = float(max_count - min_count)
 if range == 0.0:
 range = 1.0
 # Calculate tag weights.
 for tag in tags:
 tag.weight = int( MAX_WEIGHT * (tag.count - min_count) /
range)
 variables = RequestContext(request, { 'tags': tags })
 return render_to_response('tag_cloud_page.html', variables)

// code ends



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



deployment problem gotcha

2010-08-30 Thread Mike Dewhirst
I had an admin media problem finding base.css in deploying an app from 
the Django (svn head) dev server on Windows to Apache 2.2 on Linux


Because I had prepared this email ready to ask for help, I'm posting it 
anyway with the hope that it helps someone.


Everything else was working. Firebug was saying it couldn't find 
base.css and I couldn't see anything wrong with the following excerpts 
from settings.py and vhosts.conf:


... from settings.py ...

MEDIA_ROOT = '/srv/www/ccm/htdocs/static'
MEDIA_URL = '/static/'
ADMIN_MEDIA_ROOT = 
'/usr/local/lib64/python/site-packages/django/contrib/admin/media/'

ADMIN_MEDIA_PREFIX = '/media/'

... from vhosts.conf  ...

Alias /media/ 
/usr/local/lib64/python/site-packages/django/contrib/admin/media



  AllowOverride None
  Order deny,allow
  Allow from all


Alias /static/ /srv/www/ccm/htdocs/static/
Alias /tiny_mce/ /srv/www/ccm/htdocs/static/js/tiny_mce/
Alias /jquery/ /srv/www/ccm/htdocs/static/js/jquery/


  AllowOverride None
  Order deny,allow
  Allow from all



Now, in order to get some meaningful error messages I included this

import sys
sys.stdout = sys.stderr

in my wsgi script - as per the recommendation I found in 
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques


and after which, I discovered "Symbolic link not allowed or link target 
not accessible: /usr/local/lib64/python" in the Apache error log. This 
gave the clue that I needed:


/usr/local/lib64/python2.6/site-packages/django/contrib/admin

rather than the one prepared earlier which incorporated /python/ which 
is a symbolic link.


Google indicated I could have included Options FollowSymLinks and maybe 
I should have done that instead.


Maybe an expert who has read this far might care to comment?

Mike

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



Re: deployment problem gotcha

2010-08-30 Thread Mike Dewhirst

Graham

Thanks for your response. Everything works nice now.

I read the reference and fixed the missing slashes and commented out 
print functions if dev-oriented or added the print option 
file=sys.stderr if reporting an error.


Nice to learn something before it bites :)

I have decided to keep the django admin-media files untouched in-situ
because it keeps my own static files area less cluttered. It also means
less hassle for me when django tweaks admin templates, js, css and images.

I also decided to use FollowSymLinks so I could stick with the more
generic python rather than python2.6 in the path.

Thanks again

Mike


On 30/08/2010 5:36pm, Mike Dewhirst wrote:

I had an admin media problem finding base.css in deploying an app
from the Django (svn head) dev server on Windows to Apache 2.2 on
Linux

Because I had prepared this email ready to ask for help, I'm
posting it anyway with the hope that it helps someone.

Everything else was working. Firebug was saying it couldn't find
base.css and I couldn't see anything wrong with the following
excerpts from settings.py and vhosts.conf:

... from settings.py ...

MEDIA_ROOT = '/srv/www/ccm/htdocs/static' MEDIA_URL = '/static/'
ADMIN_MEDIA_ROOT =
'/usr/local/lib64/python/site-packages/django/contrib/admin/media/'

ADMIN_MEDIA_PREFIX = '/media/'

... from vhosts.conf  ...

Alias /media/
/usr/local/lib64/python/site-packages/django/contrib/admin/media


You are missing a trailing slash on filesystem path which may be a
cause of problems.



AllowOverride None Order deny,allow Allow from all 

Alias /static/ /srv/www/ccm/htdocs/static/ Alias /tiny_mce/
/srv/www/ccm/htdocs/static/js/tiny_mce/ Alias /jquery/
/srv/www/ccm/htdocs/static/js/jquery/

 AllowOverride None Order
deny,allow Allow from all 

Now, in order to get some meaningful error messages I included
this

import sys sys.stdout = sys.stderr


That shouldn't have made any difference because the error message is
from Apache and not from the Python web application.

That workaround to broken WSGI applications is also only need in
mod_wsgi 2.X and earlier and not 3.X. This is because default change
in 3.0 as gave up trying to make people write portable WSGI
applications. Read:

http://blog.dscpl.com.au/2009/04/wsgi-and-printing-to-standard-output...



in my wsgi script - as per the recommendation I found
inhttp://code.google.com/p/modwsgi/wiki/DebuggingTechniques

and after which, I discovered "Symbolic link not allowed or link
target not accessible: /usr/local/lib64/python" in the Apache error
log. This gave the clue that I needed:

/usr/local/lib64/python2.6/site-packages/django/contrib/admin

rather than the one prepared earlier which incorporated /python/
which is a symbolic link.

Google indicated I could have included Options FollowSymLinks and
maybe I should have done that instead.

Maybe an expert who has read this far might care to comment?


I would generally recommend that a copy be made of media directory
into a sub directory of Django site and use it from there instead.
That way you can customise them without fiddling with the originals.

Graham


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



Re: mod_wsgi, apache, windows XP

2010-09-02 Thread Mike Dewhirst

On 3/09/2010 7:46am, Jesse wrote:

Hello Graham,

I have the c:/public/apache/apache_django_wsgi.conf working now, at
least apache restarts.  Do you know if mod_wsgi has a problem with
these versions:
python 2.7 and apache 2.2, and postgres 8.4, psycopg 2.2.2

My server error is:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
'django.db.backends.postgresql_psycopg2' isn't an available database
backend.


I don't think it is a wsgi problem. This looks like you may not have 
installed psycopg2 on your server.




[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using
django.db.backends.XXX, where XXX is one of:
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] 'dummy',
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was:
cannot import name utils

Thank you!

On Sep 2, 9:10 am, Jesse  wrote:

Thanks!  I did see the hello using the corrected localhost/myapp, so I
at least know that I have the right version of mod_wsgi.  Now I'm back
to my original problem.  The apache server will not restart when I add
the following line to the http.conf file:

Include "c:/public/apache/apache_django_wsgi.conf"

which I place before the here:
Include "c:/public/apache/apache_django_wsgi.conf"
#WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"


Order allow,deny
Allow from all


The apache_django_wsgi.conf file has the following:
//start code
Alias /media/ "c:/public/media/"


Order allow, deny
Option Indexes
Allow from all
IndexOptions FancyIndexing


WSGIScriptAlias / "c:/public/apache/django.wsgi"



//end code

The error is Request operation failed.

Thx for your help!!

Jesse
On Sep 1, 8:53 pm, Graham Dumpleton
wrote:




On Sep 2, 1:13 pm, Jesse  wrote:



I'm using Python 2.7, Apache 2.2 and grabbed the mod_wsgi that
supposedly works.  I changed the name of the file to mod_wsgi and
placed into Apache modules library.  I changed the folders, so the
apache folder by itself and created the following in the apache
http.conf file:
WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"




Order allow,deny
Allow from all




The myapp.wsgi is:
def application(environ, start_response):
 status = '200 OK'
 output = 'Hello World!'



 response_headers = [('Content-type', 'text/plain'),
 ('Content-Length', str(len(output)))]
 start_response(status, response_headers)



 return [output]



Apache starts fine, no errors, but the localhost is still the original
apache page and not hello world.



What URL are you using? Sounds like you are using:



  http://localhost



and not:



  http://localhost/myapp



Your WSGIScriptAlias has it mounted at sub URL not root of site which
is where standard Apache 'It Works' page would be found.



Graham



On Sep 1, 4:25 pm, Graham Dumpleton
wrote:



On Sep 2, 4:46 am, Jesse  wrote:



created project using startproject testproject



Problems with apache_django_wsgi.conf
1.  Added following line toApache:
LoadModule wsgi_module modules/mod_wsgi.so



2. Created folder c:/django/testproject/apache



3.  Created file c:/django/testproject/apache/django.wsgi
// code starts
import os, sys
sys.path.append("/c:/django")



All your paths where you have '/c:' instead of just 'c:' are wrong to
start with.



os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'



import django.core.handlers.wsgi



application = django.core.handlers.wsgi.WSGIHandler()
// code ends



4.  Apachestarts and restarts. local host is originalapache"It
works"



5.  Created file c:/django/testproject/apache_django_wsgi.conf
//code starts
Alias /media/ /c:/django/testproject/media/




Order deny,allow
Allow from all




WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi




Order deny,allow
Allow from all

//code ends



6.  Added following line toApachehttp.conf
Include "c:/django/testproject/apache/apache_django_wsgi.conf"



7.  Apacheerror, cannot restart.



Any help is much appreciated.



Does theApacheerror log have anything in it?



WhichApacheversion? Which Python version? Which mod_wsgi object did
you grab, or did you compile from source code?



Are you trying to run 64bitWindows?



BTW, recommended to test first with a WSGI hello world program and not
Django.



See hello world example in:



  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide



Graham




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



Re: mod_wsgi, apache, windows XP

2010-09-02 Thread Mike Dewhirst

On 3/09/2010 2:16pm, Jesse wrote:

I have django and postgres working on the local django server.  I had
to install psycopg2-2.2.2.win32-py2.7 in order for that to work.  I
don't believe I have access to an earlier version of psycopg.  Are you
using postgres?


Yes but a different stack - python 2.6, the same revision of postgresl 
and psycopg2. I run the django development server on Win XP and Apache 
2.2 on linux. I leave postgresql running on the XP machine and point the 
linux setup at it across the LAN so I can use development machine data 
for the time being. Works well.


I haven't been following this thread closely but I do remember some time 
ago getting the same error because I had forgotten to install psycopg2 
when deploying to the linux machine.


Your error actually says django either can't find the backend you have 
specified in your settings.py or it can find it but it isn't available 
for some reason.


I would be investigating the database side of things. Without googling I 
would know whether there might be any subtle psycopg2 version problems 
but I'd eliminate everything else as a possibility first.


Mike


Jesse

On Sep 2, 5:41 pm, Mike Dewhirst  wrote:

On 3/09/2010 7:46am, Jesse wrote:


Hello Graham,



I have the c:/public/apache/apache_django_wsgi.conf working now, at
least apache restarts.  Do you know if mod_wsgi has a problem with
these versions:
python 2.7 and apache 2.2, and postgres 8.4, psycopg 2.2.2



My server error is:



TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
'django.db.backends.postgresql_psycopg2' isn't an available database
backend.


I don't think it is a wsgi problem. This looks like you may not have
installed psycopg2 on your server.





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



Re: Generate a daily serial/batch/lot number

2010-09-06 Thread Mike Dewhirst

On 6/09/2010 4:19pm, kmpm wrote:

I have a project running in a manufacturing industry that is actually
built upon django.
In this I need to generate a unique serial, batch or lot number
(depending on what you would like to call it) that is a running number
from 0 to whathever for each and every day.


So when every day ticks over at midnight, the serial number starts at 
zero again? Does production continue across the time 00:00? Why don't 
you use a continuously increment number?


I don't know what the "right" thing to do is. I'm sure there will be a 
classic solution. I think I would be writing a singleton function 
nextnum() which returns the next number as required and then


   lot_no = models.IntegerField(default=nextnum)

I'm not sure what would happen threadwise but a singleton would be a 
natural place to deal with thread-locking and restarting the sequence 
when the clock ticks over.


lot_no then gets the value prior to the save()

Mike


There is a high risk of concurrency so just finding the previous max
and then do a +1 before saving is not what I want.
The important part of the model looks like this...

class ProducedEntity(models.Model):
 
 production_date = models.DateField(auto_now_add=True)
 lot_no = models.PositiveIntegerField(default=0)

 class Meta:
 unique_together = ('production_date', 'lot_no')

Of course I could just save it and see if the .save() call works
without generating a IntegrityError but that's not elegant.
Is there a way of generating that number per day in a way that it's
done when I save the model?



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



Re: Generate a daily serial/batch/lot number

2010-09-06 Thread Mike Dewhirst

On 6/09/2010 5:38 PM, kmpm wrote:

On Sep 6, 9:02 am, Mike Dewhirst  wrote:

On 6/09/2010 4:19pm, kmpm wrote:


I have a project running in a manufacturing industry that is actually
built upon django.
In this I need to generate a unique serial, batch or lot number
(depending on what you would like to call it) that is a running number
from 0 to whathever for each and every day.


So when every day ticks over at midnight, the serial number starts at
zero again? Does production continue across the time 00:00? Why don't
you use a continuously increment number?

I don't know what the "right" thing to do is. I'm sure there will be a
classic solution. I think I would be writing a singleton function
nextnum() which returns the next number as required and then

 lot_no = models.IntegerField(default=nextnum)

I'm not sure what would happen threadwise but a singleton would be a
natural place to deal with thread-locking and restarting the sequence
when the clock ticks over.

lot_no then gets the value prior to the save()

Mike



Yes it ticks over at midnight, and no there is no production at that
time. More or less office hours only.
A singleton would be nice but as you said it's not thread safe and
won't scale nicely if we were to use multiple frontend servers or
anything like that.


Then it would need to be a database trigger. At least in PostgreSQL you 
could write it in the Python proc language supplied. It could create a 
new temporary table with an incrementing column each night as a source 
for the sequence number. That would cover occasional system stoppages 
during the day.


I'm not sure how to integrate that in a nice way with django models 
except as you alreadhy indicated with unique for date.



There is a project called django-idmapper[1] that I just found that
might solve it by using a model that seems to be stored in shared
memory.
If running on multiple frontends that would need to be something like
memcached but I don't know about thread safety and concurrency there
either.


[1]http://github.com/dcramer/django-idmapper




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



Re: Generate a daily serial/batch/lot number

2010-09-06 Thread Mike Dewhirst
I'm reminded that almost all my own disasters were caused by premature 
optimisation.


I would go with the simplest solution and keep an eye on performance as 
it scales. Gives you plenty of time to research plan B.


That'll be 2c please

M

On 7/09/2010 4:49am, kmpm wrote:



On Sep 6, 6:52 pm, Preston Holmes  wrote:


what about a simple function that does something as low tech as
checking a lock file.  If you had multiple front end servers, this
could be a running process on a server using semaphore lock.

-Preston


Sort of thought about that as well.
Meanwhile I found two other solutions to similar problems.
One is really high tech and made for GAE[1] dealing with high
concurrency counters using memcashed and periodically persisting the
counter to database. That solution involves something similar that a
lock file would do but still not...
The other [2] is on the other hand very low tech and deals with race-
conditions in django in a more trial-and-error kind of way that was my
first plan for this. Try your best by looking at a previous Max value
and take care of the integrity error that might occur.
I am really intrigued by the scalability of the first one and the
pragmatist in me would go for the second.

I really don't want to hit the database for either read or write more
then necessary so if I could get a highly probable counter value as
default by doing something similar as the GAE[1] approach and just
deal with the integrity error when that unlikely event occurs just as
option 2 describes.
What would the django community go for? It is of course a matter of
what scalability and performance requirements you have but what would
be the "right" way if you wanted a as pure django solution as
possible? All these questions... and to many answers.

[1] 
http://appengine-cookbook.appspot.com/recipe/high-concurrency-counters-without-sharding/
[2] http://stackoverflow.com/questions/3522827/



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



webmin

2010-09-08 Thread Mike Dewhirst
A perl, C and C++ colleague is leaning towards python/django and needs 
an app roughly equivalent to Webmin.


Does anyone know of some django-ish thing for him to look at?

Thanks

Mike

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



Re: windows xp, python 2.6, mod_wsgi, apache 8.4, MySQL 5.1 - CSS not loading.

2010-09-12 Thread Mike Dewhirst

On 12/09/2010 7:33am, Jesse wrote:

Hello,
I've successfully implemented mod_wsgi with Apache on Windows XP using
MySQL 5.1.  Everything but the CSS/html for the index page is
working.  Even the admin pages are working with style sheets.  The
following is my code.  I cannot seem to find the error that is not
loading the CSS style sheets for the html pages.

http.conf file
<  -- code start
Include "c:/django/apache/apache_django_wsgi.conf"


Order allow,deny
Allow from all


<  -- code end

apache_django.wsgi file:

<  -- code start
Alias /media/ "C:/Python26/Lib/site-packages/django/contrib/admin/
media/"

Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing



Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing



Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing



WSGIScriptAlias / "C:/django/apache/django.wsgi"

Alias /site_media/ "C:/django/mysite/site_media/"


Allow from all


<  -- code end

django.wsgi:

<  -- code start
import os, sys
sys.path.append("c:/django")
sys.path.append("c:/django/mysite")
# may be required :)
#sys.path.append('/path/to/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

<  -- code end


settings file
<  -- code start
MEDIA_ROOT = 'c:/django/mysite/site_media'
MEDIA_URL = 'http://www.myproject.org/mysite/site_media/'
ADMIN_MEDIA_PREFIX = 'http://www.myproject.org/media/'
TEMPLATE_DIRS = (
'C:/django/mysite/templates',
<  -- code end



I wouldn't be able to diagnose your settings because I don't run Apache 
on Windows.


Reading between the lines I think you have a settings.py problem which 
you may be able to fix if you study my working settings for Apache 
below. Good luck ...


Here is my own working settings.py code

WinXP + django dev server

MEDIA_ROOT = '/users/miked/py/djngo/src/htdocs/static/'
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/media/'
ADMIN_MEDIA_ROOT = '/media/' # dev server magic makes this work

Same site on staging/test server - Linux + Apache

MEDIA_ROOT = '/srv/www/ccm/htdocs/static/'
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/media/'
ADMIN_MEDIA_ROOT = 
'/usr/local/lib64/python/site-packages/django/contrib/admin/media/'



... and here is the Apache configuration which works sort of like the 
dev-server magic on Windows ...


Alias /media/ 
/usr/local/lib64/python/site-packages/django/contrib/admin/media/



  # follow symlinks because django is in ../python2.6/site-packages/.
  Options +FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all


/usr/local/lib64/python/site-packages/django/contrib/admin/media/>

  Options +FollowSymLinks
  AllowOverride None
  Order deny,allow
  # allow anyone to access the ../media/ directory
  Allow from all


 Alias /static/ /srv/www/ccm/htdocs/static/
 Alias /tiny_mce/ /srv/www/ccm/htdocs/static/js/tiny_mce/
 Alias /jquery/ /srv/www/ccm/htdocs/static/js/jquery/

 
  AllowOverride None
  Order deny,allow
  Allow from all
 






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



Re: windows xp, python 2.6, mod_wsgi, apache 8.4, MySQL 5.1 - CSS not loading.

2010-09-12 Thread Mike Dewhirst

On 13/09/2010 3:11pm, Mike Dewhirst wrote:

On 12/09/2010 7:33am, Jesse wrote:

Hello,
I've successfully implemented mod_wsgi with Apache on Windows XP using
MySQL 5.1. Everything but the CSS/html for the index page is
working. Even the admin pages are working with style sheets. The
following is my code. I cannot seem to find the error that is not
loading the CSS style sheets for the html pages.


In my reply a couple of minutes ago I should have included an item from 
one of my templates which is inherited by all the others ...


{% block extrastyle %}

{% endblock %}

Apache is finding href="/static/css/ccm.css" by way of the apache alias 
/static/ resolving to the exact directory containing ../ccm/ccm.css


hth

Mike




http.conf file
< -- code start
Include "c:/django/apache/apache_django_wsgi.conf"


Order allow,deny
Allow from all


< -- code end

apache_django.wsgi file:

< -- code start
Alias /media/ "C:/Python26/Lib/site-packages/django/contrib/admin/
media/"

Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing



Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing



Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing



WSGIScriptAlias / "C:/django/apache/django.wsgi"

Alias /site_media/ "C:/django/mysite/site_media/"


Allow from all


< -- code end

django.wsgi:

< -- code start
import os, sys
sys.path.append("c:/django")
sys.path.append("c:/django/mysite")
# may be required :)
#sys.path.append('/path/to/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

< -- code end


settings file
< -- code start
MEDIA_ROOT = 'c:/django/mysite/site_media'
MEDIA_URL = 'http://www.myproject.org/mysite/site_media/'
ADMIN_MEDIA_PREFIX = 'http://www.myproject.org/media/'
TEMPLATE_DIRS = (
'C:/django/mysite/templates',
< -- code end



I wouldn't be able to diagnose your settings because I don't run Apache
on Windows.

Reading between the lines I think you have a settings.py problem which
you may be able to fix if you study my working settings for Apache
below. Good luck ...

Here is my own working settings.py code

WinXP + django dev server

MEDIA_ROOT = '/users/miked/py/djngo/src/htdocs/static/'
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/media/'
ADMIN_MEDIA_ROOT = '/media/' # dev server magic makes this work

Same site on staging/test server - Linux + Apache

MEDIA_ROOT = '/srv/www/ccm/htdocs/static/'
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/media/'
ADMIN_MEDIA_ROOT =
'/usr/local/lib64/python/site-packages/django/contrib/admin/media/'


... and here is the Apache configuration which works sort of like the
dev-server magic on Windows ...

Alias /media/
/usr/local/lib64/python/site-packages/django/contrib/admin/media/


# follow symlinks because django is in ../python2.6/site-packages/.
Options +FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all



Options +FollowSymLinks
AllowOverride None
Order deny,allow
# allow anyone to access the ../media/ directory
Allow from all


Alias /static/ /srv/www/ccm/htdocs/static/
Alias /tiny_mce/ /srv/www/ccm/htdocs/static/js/tiny_mce/
Alias /jquery/ /srv/www/ccm/htdocs/static/js/jquery/


AllowOverride None
Order deny,allow
Allow from all









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



Re: Django and third party python apps, best practices for path locations?

2010-09-15 Thread Mike Dewhirst

On 16/09/2010 12:06pm, Nick wrote:

Yes and no. I'm familiar with the term but haven't read up on it
enough to wrap my head around installing it and getting it setup. Is
it absolutely essential to get used to working with virtualenv if you
plan to develop on a Windows machine but your production servers are
running *nix?


I do that and it works ok  but I don't know whether it is 
best practice.


I don't use virtualenv although it seems like a good way to segregate 
stuff for different python versions. I don't currently have a need for 
it so it is on the future list for me. Back to your "Is it absolutely 
essential" question ...


No.

I always install third party apps with "setup.py install" which puts 
them in the correct respective site-packages directories on both Windows 
and Linux and they "just work".


I use my own source directory on Windows for my own django apps and they 
all play together on both platforms without much current thought on my part.


The trick is to automate delivery of your own source to the linux web 
server directory you have chosen. I think it would complicate things 
incredibly to try and manage third party source delivery at the same time.


I use subversion hook scripts to trigger svn export into the chosen 
directory every time I commit a source change on Windows. At this point 
I must say the linux machine I'm using is a staging server not a 
production server. It doesn't matter if something goes belly-up. In fact 
when the unit tests fail it is usually because I haven't installed or 
updated a third party package on the linux machine.


Finally, I put a shortcut to the site-packages directory in the same 
directory as my settings.py file so I can visit third-party source 
whenever I feel like it.


hth

Mike



On Sep 15, 9:50 pm, "nick.l...@gmail.com"  wrote:

Nick,

yes...and no.

Have you looked at using Virtualenv?http://pypi.python.org/pypi/virtualenv

On Thu, Sep 16, 2010 at 1:44 AM, Nick
wrote:
Let's say you have Python installed to D:/dev/python2.6



Is it wise/common practice to put django and other third party python
libraries (like pygments or markdown) in the python2.6/Lib/site-
packages/ directory while putting your actual projects in a completely
separate location off the python path?



I ask because I want to get used to placing my python install, django
install, third party python libs, django projects, and django
applications in a familiar/standard path structure so migrating to
various web hosts will be as painless as possible plus well organized.



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


--
Guadajuko! Vamos a correr!
  -"Cool! we are going to run!"




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



Re: Auto Increment Primary_Key

2010-09-19 Thread Mike Dewhirst
This might not work for you but I would consider South. 

You might be able to rework the schema and migrate the data. 



On 19/09/2010, at 4:40 PM, "hellowrakesh...@gmail.com" 
 wrote:

> Hi,
> I am in a trouble and need help. We have an application developed in
> Django and has a custom defined (Char Type) primary key. Due to few
> new features, we need to change the primary key to a AutoGenerated
> Key. We manually added a column named id, a sequence and a trigger
> (same naming convention as Django creates since doing syncdb for
> existing tables doesn't work). The problem the we are facing is-
> 1) The application works fine when "id" is added in the Job class in
> models (models.CharField(max_length=200, primary_key=True)). While
> saving, a job object, job.id or job.pk  (job is the model name)
> returns None although "id" is generated in Db.
> 2) If we remove "id" from Job class (w/o removing the db column,
> sequence and trigger), the application works fine but its extremely
> slow. The query which takes .08 seconds is taking 31 seconds to
> execute. We face the same issue, if we replace the "id" as AutoField.
> The performance is very slow.
> 
> We can live with approach 1 but while running unit tests, it fails
> since it doesnt create the sequence and trigger on its own (note in
> approach 1, auto field is not specified) and by specifying auto field,
> tests work fine but the application is very slow.
> 
> We need to fix this and its a bottle neck for us now. Any help on this
> will be highly appreciated.
> Thanks in advance.!
>  Rakesh
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



how should models be semi-related

2010-09-20 Thread Mike Dewhirst
I have an address model with a 'country' field and a phone model with a 
'country_code' field.


I would guess the right approach is to use choices for both fields so 
the user can always select or change country in an address AND 
country_code in a phone number.


However, I would like the selection of at least one to be automatic. If 
an address record exists when creating a phone record the relevant 
country_code should be inserted as a default.


Is there a way to sensibly do this with code in a model?

A related question - if django signals are a reasonable way to tackle 
this, might it be better to write database triggers?


Thanks

Mike

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



Re: Why Django Apps Suck

2010-09-21 Thread Mike Dewhirst
Also at pycon-au http://glamkit.org/ where the talk focused on 
reusability of apps.



On 22/09/2010 6:26am, klaasvanschel...@gmail.com wrote:

Ok here it goes: I don't have a proper platform for my observations /
rants so I figured I'd try my luck here. Django has been my favorite
framework for developing web applications for about a year and a half,
so it comes from a position of love when I say that the Django app
really sucks as a level of abstraction. And I'm really looking for a
way out so any suggestions are much appreciated. A tl;dr is provided
below.

Others have complained before me. Two particular ones worth mentioning
are:
http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fix-it
which claims that "Apps which provide models are inflexible" and
http://www.mutualinformation.org/2010/03/why-i-switched-to-pylons-after-using-django-for-six-months/
Both claim that the Django app provides the wrong level of
abstraction, neither goes in too much detail exactly why that is the
case. That's the question I'll attempt to answer.

Before we can answer the question we must first set some reasonable
expectations for an "app". I'd say an app is a small package of
closely related features as they are presented to the user (in the
context of a web project) that can be easily modified/extended for any
given project.

Examples of apps (in my own particular context):
* Dealing with customer information (a mini CRM). Adding, editing,
useful overviews.
* A small news app (Add, edit, overviews)
* Our own particular UserProfile app (editing, viewing others,
birthday calendars etc.)
* A small budgetting tool (creating budgets, see how much money has
been used)
* Logging time lines (for worked hours), searching them.

I choose this definition for "app" because it is a very useful one in
the context of web projects. At least in my context it works like
this: we have a lot of customers with similar intranets and extranets.
Each one of them might want a particular subset of the various apps we
have "on the shelf".

By the way: there's other things that can already be reused quite
well. Anything pure python for example. Or extensions to Django (extra
fields, extra context managers, middleware etc etc.) This is not my
concern, mainly because it already works well.

One thing that deserves extra stress is that apss should be easily
extendable. Exactly the fact that every customer want something that
is slightly different from the next is how we're able to provide
value. (This is also the reason I like Django in the first place:
making stuff "your own way" is very easy). So: if no one want exactly
the same, extensibility is a major prerequisite for reusability.

What are some typical things we want to do when extending (modifying)
an app for the context of a particular project?
* Deal with authorization in the context of the particular django
project
* Styling for the project
* Turn a subset of the functionality on or off for a given project (no
docs, no 'advanced features')
* Add one or more fields to one or more models and possibly related
edit pages, view pages forms etc

Given this control flow let's try to do some of the typical
modifications mentioned above:
Authorization:
Django has a beautiful mechanism for authorization, which is using
decorators (@may_do_a_b_or_c) directly in the views.py.
Tempting, but will not be modifyable in any way once you lift the app.
(because the decorator will become tied to the view function). Other
mechanisms are not presented (in a standardized way). If anyone has
ideas about this I'd love to discuss them.

Styling:
This actually works well, by providing sufficient amount of hooks in
the templates and extending.

Turning functionality on and off:
This could be made to work by working with a 'url_parts.py' in the
reusable app, that provides different url_patterns for the various
subsets. So one for the CRUD, one for the docs, one for the simple
features and one for the advanced features. Our project's urls.py
would then simply include the right subset from this url_parts.py. I'm
not sure it's very pretty though.

Extending models
This is the big one, for two reasons.
1. You almost always want to do this (for any change to the app that
is reflected in the underlying data)
2. It's pretty much impossible.

Why is it impossible?
Firstly, /app/models.py is always discovered, so unless we make all
Models abstract, or we do not include "app" in settings.py, models are
created for syncdb and any related commands.

Secondly, let's take a look at Django's control flow:
* urls.py matches and calls,
* possibly via a decorator
* a view in views.py, that may use any number of
   * models,
   * forms and
   * templates
The "official" way to modify a reusable app for your particular app is
by making it available as a kwarg with proper default in the view, and
then customizing it from urls.py.
However, if you simply want to add one field to a much used object,
this solution implies passing

Re: Where do you put your business logic in django? Organizing big projects in django.

2010-09-27 Thread Mike Dewhirst

On 27/09/2010 5:08pm, MrMuffin wrote:

Where do you put your business logic in django? In my project I`ve put
it into the models.py, but that file soon become huge and hard to
maintain. Of course I can just stuff it into whatever file I like, but
I`d like to have some standard way of doing this. There seems to be
something missing in django when it comes to business logic. It`s all
model, views and templates and that`s all great for small projects,
but both the models.py and views.py very soon gets huge and how do you
re-organize your project when that happens? Splitting views and models
into seperate files is only a partial solution and that requires some
hackish code in __init__.py to make syncdb etc work. And then there`s
urls.py.

Should there be a better and standardized way to organize huge
projects in django?


I hope some dguru answers this because it is important.

I reckon business rules should be in models.py because that represents 
the database and I've always thought that is where the business rules 
belong for the sake of data integrity.


There is probably nothing wrong with multiple model files named for the 
tables in the app if you want to keep them small. You might want to 
import them 'from app import table_x.table_x as table_x'. Bit ugly I 
suppose - this is really why it makes lotsa sense to split a big project up.


Business logic is different than business rules. That is simply the 
application logic and that probably belongs in views.py but there is 
nothing stopping you importing stuff from app_logic.py which can import 
stuff from big_project.py.


If it is a giant project you probably ought to split it into smaller 
apps each of which is focused on a self-contained subset of your entire 
functionality. That way, you might be able to put parts of it on 
sourceforge and I can use it :)


Mike



Thanks for your time.



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



Re: Accessing schemas in django

2010-09-27 Thread Mike Dewhirst

On 27/09/2010 4:53pm, Jean-Pierre De Villiers wrote:

Hi,
Is there a way to access an existing database schema in Django?
Any help would be appreciated!


google for 'existing schema django'



J



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



Re: What's the best way to implement project permissions in a project management app?

2010-10-04 Thread Mike Dewhirst

On 5/10/2010 11:32am, Stodge wrote:

  What's the best way to implement project permissions in a project
management app? Should I just create the concept of membership and
have a function is_member on the project model?



Have a look at django-todo. A quick read the other day indicated to me 
that it has what you are looking for. I'm planning to look more closely 
but haven't had time yet.


Mike

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



Re: /admin list help ASAP

2010-10-20 Thread Mike Dewhirst

On 21/10/2010 1:24pm, Bobby Roberts wrote:

hi all.  I have two models setup let's call them

Gallery
Photos

photos has a field as such:

GalleryId = models.ForeignKey('Gallery', verbose_name=_('Gallery Id'),
related_name='Gallery_Id',blank=False, null=False, help_text=_("Please
choose the gallery to which you wish to associate this photo."))

Ok now here's the question.

In the listing page for my photos, I want to print Gallery.Title

the two models are related on Photos.GalleryId=Gallery.Id

How do I return Gallery title in the listing page in /admin?



You can write a function in __unicode__() to display the two ...

def getGallery(self):
pass # not sure how to get the Gallery title

def __unicode__(self):
return u'%s: %s' % (self.getGallery,
self.title)

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



Re: Converting Django to Desktop App? (Multiple Instances)

2010-10-29 Thread Mike Dewhirst

On 29/10/2010 6:33pm, Victor Hooi wrote:

Hi,

This is a bit of a strange scenario.

We have a simple Django application used to maintain a database of
newspaper/journal articles. We're extensively using the django-admin
as part of this app.

Currently, we're having issues getting a production environment with
Python provisioned (corporate environment, locked technology roadmap
etc.), however, we will have access to a Oracle database instance.

One possibility raised was that for each of the clients (fairly small,
under 5), we install a local instance of Django and Apache, which they
access with their browser, and each of these instances communicates
with a single Oracle DB instance.


That looks a bit 'under the radar' with regard to locked roadmap etc. 
Why not dig the pit a bit deeper and make your own server with Apache, 
Django and your Oracle db. Much cleaner than Apache/Django everywhere.


With only 5 users presumably all inside the perimeter you could set it 
up on a well endowed desktop machine. I would be tempted to put it all 
in a VirtualBox running Linux so there wouldn't be any Apache production 
disclaimers relating to Windows. I'm assuming corporate environment == 
Microsoft. Also, if a hole in the locked roadmap emerged in future you 
have a VM ready to roll.


My 2c

Mike


I know on the Rails side, there was a product by Joyent called
Slingshot (http://joyeur.com/2007/03/22/joyent-slingshot/), which
allegedly did something similar (packaged up a RoR app into a desktop
application).

Are there any particular issues we need to be aware of if we decided
to go down this path?

In particular, I wasn't sure how multiple instances of Django would
handle concurrency if they were communicating with a single database.
Any advice there?

Any other possible drawbacks/roadblocks?

Cheers,
Victor



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



Re: Django - Alternative to using NULLs? (for integer and FK fields).

2010-11-29 Thread Mike Dewhirst

On 30/11/2010 4:26pm, Victor Hooi wrote:

heya,

Phone Number - Yup, you're both right, I'll be using CharField now,
and model validation to make sure they're digits.

Spouse/Children:


Victor

I'm coming in late on this and don't have the context for your design 
but I think there might be a better (perhaps more flexible) way to 
handle spouses and children without worrying about NULLs.


I really like a single table for everyone. After all spouses and 
children are persons too. You can use a separate table to hold named 
many-to-many relationships between the person table and itself.


If the relationship is "Spouse" then that relationship speaks for 
itself. Children can simultaneously have relationships with "Father", 
"Mother", "Step-mother" etc. Other persons can have "Ex-spouse" 
relationships when divorced etc.


If you can find any person then you can navigate through all the 
relationships to find all connected persons.


Finally, if someone has multiple spouses then they probably need 
counselling but at least you can represent it with multiple relationship 
records :)


Mike



With children, a M2M field, there's a link table, and if you don't
have a spouse, then there won't be any lines in that table. So no need
for NULLs there. I've just tested it with just blank=True, and no
null=True - seems to do what I want (optional children).

With ForeignKeyField though, I thought this was simply an FK field,
with the ID number of the object we're relating/pointing stored in
that field? Isn't that how it works in a normal DB? Why is there a
separate Person_spouse table?

Is there any way to make this optional without using NULLs, or should
I make it a m2m field? (I suppose in theory you can have multiple
spouses...well, not under my jurisdiction, I guess...lol).

Cheers,
Victor

On Nov 30, 3:11 pm, Lachlan Musicman  wrote:

On Tue, Nov 30, 2010 at 12:28, Victor Hooi  wrote:

Hi,



I'm wondering what the community's stance on using NULL in Django is?



Say for example you have:



class Person(models.Model):
street_address = models.CharField(max_length=50, blank=True)
suburb = models.CharField(max_length=30)
postcode = models.IntegerField()
state = models.CharField(max_length=3)
email = models.EmailField()
mobile_phone_number = models.IntegerField(max_length=12)
home_phone_number = models.IntegerField(max_length=10,
null=True, blank=True)
work_phone_number = models.IntegerField(max_length=8,
null=True, blank=True)



   spouse = models.ForeignKey('self', null=True, blank=True)
   children = models.ManyToManyField('self', null=True,
blank=True)



For string fields like street_address, I can make these "blank=True",
and Django will store an empty string if the user leaves it blank.



However, for integer fields like home_phone_number and
work_phone_number, I've had to make these "null=True" for the case
where somebody doesn't supply them (i.e. they're meant to be optional,
mobile is required).



However, is there a better way of handling this case? (assuming I want
to keep these fields as integers).


Is it possible to know why you would want to keep them as integers?
Given that there are no mathematical functions that you would want to
apply to them


What about in the case of optional foreign keys (spouse and children)
- is there a better way of handling these, without using NULLs?


As I understand it, foreign keys are kept in the db as follows:

1. table_Person
2. table_Person_children
3. table_Person_spouse

table 2 has three columns: id, Person, Children
table 3 has three columns: id, Person, Spouse

or something to that effect.

Therefore, if there is no Spouse or Child, there is no entry for
Person in tables 2 or 3.








Cheers,
Victor



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




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



Re: Django - Alternative to using NULLs? (for integer and FK fields).

2010-11-29 Thread Mike Dewhirst

On 30/11/2010 5:10pm, Victor Hooi wrote:

Mike,

Hmm, I'm currently using a recursive ('self') Many2Many and ForeignKey
for Children and Spouse, respectively (see source in the first post).

Is that what you meant?

Or perhaps I'm not quite getting what you mean - any chance you could
paste a models.py example so I can make sure I'm on the same page?


Victor

I'm keeping track of companies, divisions and people with their 
relationships. For example, divisions can be traded between companies 
and people consult to companies or own trading entities. I can also keep 
track of pretty much any relationship of interest.


Hope this helps ...

class Entity(models.Model):
"""
Entities can be corporations or humans. entity_type indicates
which.
"""
entity_type = models.CharField(max_length=MEDIUM, blank=False,
choices=ENTITY_TYPES,
default=ENTITY_TYPES[0][0])
entity_name = models.CharField(max_length=LARGE, blank=False)
entity_title = models.CharField(max_length=SMALL, blank=True)
other_name = models.CharField(max_length=LARGE, blank=True)

slug = models.SlugField(max_length=VLARGE)

updated_by = models.ForeignKey(User, blank=True, null=True)
updated_date = models.DateTimeField(blank=True)
address = models.ForeignKey(Address, blank=True, null=True)

created = models.DateTimeField(auto_now_add=True)
saved = models.DateTimeField(auto_now=True)
saved_by = models.ForeignKey(User, blank=True, null=True,
related_name='entity_saved_by')
class Meta:
verbose_name_plural = 'entities'

def __unicode__(self):
ename = u' '.join(self.entity_title,
  self.other_name,
  self.entity_name)
return u'%s: %s (%s)' % (self.pk,
  ename.strip(),
  self.entity_type)


class Relationship(models.Model):
entity = models.ForeignKey(Entity, null=False,
related_name='rel_entity')
xref = models.ForeignKey(Entity, null=False,
related_name='xref_entity')
relationship = models.CharField(max_length=MEDIUM, blank=False,
choices=RELATIONSHIPS,
default=RELATIONSHIPS[0][0])
comment = models.CharField(max_length=HUGE, blank=True)
start_date = models.DateTimeField(blank=True, null=True)
end_date = models.DateTimeField(blank=True, null=True)

created = models.DateTimeField(auto_now_add=True)
saved = models.DateTimeField(auto_now=True)
saved_by = models.ForeignKey(User, blank=True, null=True,
related_name='relationship_saved_by')

    def __unicode__(self):
return u'%s: %s ' % (self.relationship, self.xref)


Mike



Cheers,
Victor

On Nov 30, 5:02 pm, Mike Dewhirst  wrote:

On 30/11/2010 4:26pm, Victor Hooi wrote:


heya,



Phone Number - Yup, you're both right, I'll be using CharField now,
and model validation to make sure they're digits.



Spouse/Children:


Victor

I'm coming in late on this and don't have the context for your design
but I think there might be a better (perhaps more flexible) way to
handle spouses and children without worrying about NULLs.

I really like a single table for everyone. After all spouses and
children are persons too. You can use a separate table to hold named
many-to-many relationships between the person table and itself.

If the relationship is "Spouse" then that relationship speaks for
itself. Children can simultaneously have relationships with "Father",
"Mother", "Step-mother" etc. Other persons can have "Ex-spouse"
relationships when divorced etc.

If you can find any person then you can navigate through all the
relationships to find all connected persons.

Finally, if someone has multiple spouses then they probably need
counselling but at least you can represent it with multiple relationship
records :)

Mike










With children, a M2M field, there's a link table, and if you don't
have a spouse, then there won't be any lines in that table. So no need
for NULLs there. I've just tested it with just blank=True, and no
null=True - seems to do what I want (optional children).



With ForeignKeyField though, I thought this was simply an FK field,
with the ID number of the object we're relating/pointing stored in
that field? Isn't that how it works in a normal DB? Why is there a
separate Person_spouse table?



Is there any way to make this optional without using NULLs, or should
I make it a m2m field? (I suppose in theory you can have multiple
spouses...well, not under my jurisdiction, I guess...lol).



Cheers,
Victor



On Nov 30, 3:11 pm, La

Re: Loading CSS

2010-12-01 Thread Mike Dewhirst

On 2/12/2010 1:48am, octopusgrabbus wrote:

Thank you. I've done made changes according to your suggestions, but
the css appears not to load. I am using apache, not the built-in web
server.


Here is my working vhost.conf for my Apache. See the aliases below which 
cause Apache to find the css file and make it available to your Django 
pages.


The AliasMatch entries which are commented out should have worked but I 
didn't have the patience so I used Alias entries instead.


Good luck

Mike




 ServerName http://xxx.xxx:80
 DocumentRoot /srv/www/xxx/htdocs/

 HostnameLookups Off
 UseCanonicalName Off

 ErrorLog /var/log/apache2/xxx_error_log
 CustomLog /var/log/apache2/xxx_access_log combined

 Alias /robots.txt /srv/www/xxx/htdocs/static/robots/robots.txt
 Alias /favicon.ico /srv/www/xxx/htdocs/static/img/favicon.ico

#AliasMatch /([^/]*\.css) /srv/xxx/ccm/htdocs/static/css/$1
#AliasMatch /([^/]*\.js) /srv/xxx/ccm/htdocs/static/js/$1
#AliasMatch (^/.+\.js) /srv/xxx/ccm/htdocs/static/js/$1

 Alias /media/ /srv/www/xxx/htdocs/static/
 Alias /static/ /srv/www/xxx/htdocs/static/
 Alias /tiny_mce/ /srv/www/xxx/htdocs/static/js/tiny_mce/
 Alias /jquery/ /srv/www/xxx/htdocs/static/js/jquery/

# now let the public access anything here
 
  AllowOverride None
  Order allow,deny
  Allow from all
 

 WSGIScriptAlias / /srv/www/xxx/climate/wsgi-bin/xxx.wsgi
 
  Order allow,deny
  Allow from all
 








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



Re: __init__.py file executed twice ?

2010-12-08 Thread Mike Dewhirst

On 9/12/2010 5:10am, martvefun wrote:



On 08-12-10 18:39, Tom Evans wrote:

On Wed, Dec 8, 2010 at 4:52 PM, martvefun  wrote:

Hello,

I'd like to start some threads when the server launch to listen to
events (I'm doing message passing).

To do so, I guess I should be using the __init__.py file at the root of
my project (by the way, what's the used of the other __init__.py files
in the apps)

I've tried with a simple test by only having 'print "starting server"'
into the file and the result is :

$ python manage.py runserver
starting server
starting server
Validating models...
0 errors found

Django version 1.2.3, using settings 'website.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Why the file is executed twice ? I don't want to have twice the same
threads.

Thank you

mart



__init__.py files aren't executed at the start of programs, the
presence of them denotes that a directory is a python module, and the
__init__.py is executed when that module is first imported under a
particular name.

Do you have a structure like this:

project
├── __init__.py
├── app1
│   └── __init__.py
└── app2
 ├── __init__.py
 └── models.py

and import from project.app2.models and from app2.models? That would
cause app2's __init__.py to be executed twice.

Cheers

Tom



Yes the structure of my project is more or less like that but I've not
two but 6 apps all with 'from django.db import models' in models.py
In several model (more than two), I'm using foreign keys to different
models.
For now the site doesn't do much, I'm using the database created with
the models in other files in the project folder.

So if the __init__.py is not a good place to start operations at server
startup, where should I put it ?


It seems like a good place to put it. Maybe you can test to see if the 
threads have been started already?


Here is a singleton which could live in your __init__.py and might help 
to record the state of your threading ... or anything else for that matter.


class singleton(object):
""" designed by Oren Tirosh and Jeff Pitman """
def __new__(self, *args, **kwargs):
if not '_singleton' in self.__dict__:
slate = object.__new__(self)
slate.state = {
'threads':True,
# add other state things as required
}
self._singleton = slate
return self._singleton

hth

Mike







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



Re: __init__.py file executed twice ?

2010-12-10 Thread Mike Dewhirst

On 10/12/2010 7:43pm, martvefun wrote:

On 09-12-10 01:37, Mike Dewhirst wrote:

It seems like a good place to put it. Maybe you can test to see if the
threads have been started already?

Here is a singleton which could live in your __init__.py and might
help to record the state of your threading ... or anything else for
that matter.

class singleton(object):
 """ designed by Oren Tirosh and Jeff Pitman """
 def __new__(self, *args, **kwargs):
 if not '_singleton' in self.__dict__:
 slate = object.__new__(self)
 slate.state = {
 'threads':True,
 # add other state things as required
 }
 self._singleton = slate
 return self._singleton

hth

Mike


Sorry but I don't really understand how works the function you gave me.


A singleton is a class which guarantees to return exactly the same 
object every time. It can only create an object once then returns a 
handle to the existing object instead of creating a new one.


If you initiate your threads and set (in the above example) 
slate.state['threads'] = True I think you can rely on that and avoid 
initiating them twice.


I used it once to manage the state of a "switch" where different parts 
of the project could instantiate a singleton object and read the state, 
make decisions and update the state reliably for other part of the app.


Mike



In my case, I create several objects like this :

# __init__.py
profile_rec_port = ProfileRecorder()
evaluation_port = EvaluationManager()
...

# evaluationmanager.py
class EvaluationManager(Thread):

 def __init__(self):
 self.port = Queue() # Initialize an infinite empty queue
 Thread.__init__(self) # Initialze the thread
 self.start() # Launch the thread
...




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



Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread Mike Dewhirst

On 12/12/2010 7:14am, jc wrote:

Apache&  mod_wsgi are configured correctly (I've created a hello
world .html apache file and a hello world mod_wsgi application with
no
problems). I know need my Django app to recognize my django.wsgi
file.
What makes me think that it's not recognizing my wsgi file is that I
went into my django.wsgi file I created and completely deleted all of
the code in the file and restarted Apache and it still gives me the
same page (a listing of the files from Django app, not my actual
Django application. Configuring Apache and mod_wsgi went really well
but I'm at a loss of how to fix this. Here are some details instead of
"it's
not working":


You are correct. Apache is not looking at the wsgi script. Have a look 
at the suggestions below ... before playing with django.wsgi.




Here is my current django.wsgi file:

import os
import sys
sys.path.append('/srv/www/duckling.org/store/')
os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/
store/.python-
egg'
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

I've tried a few different versions of the django.wsgi file
(including
a version like the one over at http://www.djangoproject.com/).
This version of my wsgi is from here:
http://library.linode.com/frameworks/django-apache-mod-wsgi/ubuntu-10...


Also, here is my vhost apache configuration file below. I think these
are
the main files that are suppose to do the job for me. Let me know if
you see any errors in what I'm doing and what else I might do to fix
this. The django app runs fine on the django's built-in development
server so I'm thinking it *might have* something with my paths.
No errors in my apache error.log file as well. It's acting as there's
no problem at all, which is not the case...the project isn't loading,
like I said just a listing of my files and directories of my Django
project. Here is my apache config file:


 ServerAdmin h...@duckling.org
 ServerName duckling.org
 ServerAlias www.duckling.org

 DocumentRoot /srv/www/duckling.org/store/


# DocumentRoot is where you keep non-django stuff eg., static files
# which is served by Apache without needing your Django code
DocumentRoot /srv/www/duckling.org/htdocs/



 
 Order Allow,Deny
 Allow from all
 


# now let the public access anything here
 
  AllowOverride None
  Order deny,allow
  Allow from all
 



 WSGIScriptAlias /django /srv/www/duckling.org/store/wsgi-scripts/
django.wsgi
 
 Order allow,deny
 Allow from all
 




Somewhere in your Apache config you have denied access to the entire 
filesystem to prevent outsiders from hacking in. Your Django code must 
also be hidden from outsiders so it will live safely in 
/srv/www/duckling.org/store because you haven't allowed anyone except 
Apache to see it.


Now you need to provide an allowed conduit to your Django code. So make 
an Apache script alias to map the website root (ie '/') to your Django 
code. Because you are using mod_wsgi the entry point is your django.wsgi 
script. So map / to the script:

 WSGIScriptAlias / /srv/www/duckling.org/store/wsgi-scripts/django.wsgi

# and give the public full access - but only to the entry point
 
  Order deny,allow
  Allow from all
 

hth
Mike



And here are versions of the stack that I'm using, I saw over at the
mod_wsgi site that you all would like the versions of what I'm using
on the server:
Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.5 with Suhosin-Patch
mod_python/3.3.1 Python/2.6.5 mod_wsgi/2.8


I would remove mod_python if possible



thanks,
j.



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



Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread Mike Dewhirst

On 12/12/2010 10:35am, jc wrote:

You definitely lost me in some places but you've also cleared some
things up in the process. I also noticed that I had "", which is lacking a directory for the
WSGIScriptAlias. I've fixed that now. *Now*, I no longer get my
listing of my files in my project when I go to my address *but* I now
get 500 Internal Server Error. I'm not sure if I should trust the logs


Always trust the logs. If you know enough about Apache to mistrust the 
logs then you wouldn't be here.



or maybe I've misconfigured something else (either in Apache or in my
django.wsgi file)...I had this same issue yesterday 500 error...

Also, when you said "Somewhere in your Apache config you have denied
access to the entire filesystem", do  you mean *Apache* has done this
so that it will keep others out of my project (not that I've actually
done this somewhere, right?)


Somewhere in your Apache config there will be something like this ...

# forbid access to the entire filesystem by default

Options None
AllowOverride None
Order deny,allow
Deny from all


... which - as the comment says - locks the public out of everything on 
the server.  actually means the root of the server itself. 
In other words /. The '/>' is not an XML closing tag even though it 
might look like it.


This is why you need to specifically open up public access to htdocs and 
your wsgi script directory. Incidentally, it is also why your Django 
code should not be in your your wsgi script directory. If it was Apache 
could reveal it to the public - which is what I think you were 
describing earlier.




After these changes, the project is still not running and I'm still
not sure if it's my django app that's the issue or wsgi and my Apache
configs. :/



1. In WSGIScriptAlias you map your wsgi script (django.wsgi itself) to 
the root of your duckling website. In other words your wsgi script 
becomes the / which is the slash at the end of http://1.2.3.4/


2. Your Apache config opens up access to the directory in which that 
script lives - in other words you create a hole in the entire filesystem 
lockdown.


To gain more info on wsgi scripts try ...

http://code.google.com/p/modwsgi/wiki/DebuggingTechniques

Good luck

Mike



thanks for the reply back, I do appreciate it...

j.

On Dec 11, 5:29 pm, Mike Dewhirst  wrote:

On 12/12/2010 7:14am, jc wrote:


Apache&mod_wsgi are configured correctly (I've created a hello
world .html apache file and a hello world mod_wsgi application with
no
problems). I know need my Django app to recognize my django.wsgi
file.
What makes me think that it's not recognizing my wsgi file is that I
went into my django.wsgi file I created and completely deleted all of
the code in the file and restarted Apache and it still gives me the
same page (a listing of the files from Django app, not my actual
Django application. Configuring Apache and mod_wsgi went really well
but I'm at a loss of how to fix this. Here are some details instead of
"it's
not working":


You are correct. Apache is not looking at the wsgi script. Have a look
at the suggestions below ... before playing with django.wsgi.












Here is my current django.wsgi file:



import os
import sys
sys.path.append('/srv/www/duckling.org/store/')
os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/
store/.python-
egg'
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()



I've tried a few different versions of the django.wsgi file
(including
a version like the one over athttp://www.djangoproject.com/).
This version of my wsgi is from here:
http://library.linode.com/frameworks/django-apache-mod-wsgi/ubuntu-10...



Also, here is my vhost apache configuration file below. I think these
are
the main files that are suppose to do the job for me. Let me know if
you see any errors in what I'm doing and what else I might do to fix
this. The django app runs fine on the django's built-in development
server so I'm thinking it *might have* something with my paths.
No errors in my apache error.log file as well. It's acting as there's
no problem at all, which is not the case...the project isn't loading,
like I said just a listing of my files and directories of my Django
project. Here is my apache config file:




  ServerAdmin h...@duckling.org
  ServerName duckling.org
  ServerAliaswww.duckling.org



  DocumentRoot /srv/www/duckling.org/store/


# DocumentRoot is where you keep non-django stuff eg., static files
# which is served by Apache without needing your Django code
DocumentRoot /srv/www/duckling.org/htdocs/




  
  Order Allow,Deny
  Allow from all
  


# now let the public access anything here
   
Allo

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread Mike Dewhirst

On 12/12/2010 10:56am, jc wrote:

I've tried to fix my config files and it gives me a 500 error, here is
what i see n the logs. I've been told by someone else that they think
it's still my mod_wsgi/Apache configuration and not the error that I'm
getting in the log about missing modules. Any suggestions? Here is the
server error log message and my newly configured files:

#
# error.log
#
mod_wsgi (pid=20698): Exception occurred processing WSGI script '/
srv/
www/duckling.org/store/wsgi-scripts/django.wsgi'.
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
wsgi.py", line 230, in __call__
  self.load_middleware()
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py", line 42, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s:
"%s"' % (mw_module, e))
  ImproperlyConfigured: Error importing middleware
satchmo_store.shop.SSLMiddleware: "No module named
satchmo_store.shop.SSLMiddleware
I'm at a loss here as to how I find out if the problem lies with
mod_wsgi or apache configs or django or satchmo. So, I'm posting here
just in case someone might be able to help me out. Without some help
this project is as good as doomed as I don't have a lot of skills and
I'm learning along the way.


The loading middleware error seems straightforward. My guess is the 
module containing the middleware cannot be found.


If you installed Satchmo correctly it will have added itself properly to 
the Python path and that error wouldn't occur.


If you are learning and still need to develop your skills I would 
recommend using the Django dev server to try it out.


hth

Mike



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



apache serving static files

2010-01-07 Thread Mike Dewhirst
I want to serve development code from SuSE 11.1 using Apache 2.2 with 
mod_wsgi in parallel with the Django server on WinXP.


It works - except I have obviously outsmarted myself configuring Apache 
to serve javascript. In particular tiny_mce.js.


As an example, here is part of my
  ../templates/admin/flatpages/flatpage/change_form.html ...
- - - - - - - -

- - - - - - - -

Here is part of my settings.py ...
- - - - - - - -
MEDIA_URL = '/static/'
MEDIA_ROOT = os.path.dirname(PROJECT_ROOT) + '/htdocs/static/'
- - - - - - - -
This PROJECT_ROOT is derived from os.path.dirname(__file__) which makes 
the root slightly different between WinXP Django dev server and SuSE 
Apache server


Here is part of my Apache conf ...
- - - - - - - -
AliasMatch /([^/]*\.js) /srv/www/ccm/htdocs/static/js/$1
- - - - - - - -
... which I thought would match "/tiny_mce/tiny_mce.js" from the above 
changeform.html snippet for Apache to find that script where it actually 
lives in

   /srv/www/ccm/htdocs/static/js/tiny_mce/tiny_mce.js
BUT according to the errorlog Apache is actually looking in
   /srv/www/ccm/htdocs/static/js/tiny_mce.js

On the WinXP dev server tiny_mce works fine based on the above MEDIA_URL 
and MEDIA_ROOT.


Any hints, pointers or docco links gratefully followed

Thanks

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




Re: apache serving static files

2010-01-07 Thread Mike Dewhirst

On 8/01/2010 2:13am, Stephen Emslie wrote:

Looks like the regular expression of the AliasMatch excludes any '/'
characters in the pattern, so is only going to match the last part of the
path.

Or roughly equivalent to doing path.split('/')[-1].

does the following work?

   AliasMatch /(.*\.js) /srv/www/ccm/htdocs/static/js/$1


Thanks Stephen

I really want the match string to start with a / hence ^/ and then any 
character . (including more slashes) one or more times + and ending in 
\.js  so I reckon it should be ^/.+\.js


AliasMatch (^/.+\.js) /srv/www/ccm/htdocs/static/js/$1

This is now finding tiny_mce according to FireBug BUT it isn't 
displaying the usual editing controls so there must be something else amiss.


Back to the drawing board I guess

Thanks

Mike





On Thu, Jan 7, 2010 at 12:48 PM, Mike Dewhirstwrote:


I want to serve development code from SuSE 11.1 using Apache 2.2 with
mod_wsgi in parallel with the Django server on WinXP.

It works - except I have obviously outsmarted myself configuring Apache to
serve javascript. In particular tiny_mce.js.

As an example, here is part of my
  ../templates/admin/flatpages/flatpage/change_form.html ...
- - - - - - - -

- - - - - - - -

Here is part of my settings.py ...
- - - - - - - -
MEDIA_URL = '/static/'
MEDIA_ROOT = os.path.dirname(PROJECT_ROOT) + '/htdocs/static/'
- - - - - - - -
This PROJECT_ROOT is derived from os.path.dirname(__file__) which makes the
root slightly different between WinXP Django dev server and SuSE Apache
server

Here is part of my Apache conf ...
- - - - - - - -
AliasMatch /([^/]*\.js) /srv/www/ccm/htdocs/static/js/$1
- - - - - - - -
... which I thought would match "/tiny_mce/tiny_mce.js" from the above
changeform.html snippet for Apache to find that script where it actually
lives in
   /srv/www/ccm/htdocs/static/js/tiny_mce/tiny_mce.js
BUT according to the errorlog Apache is actually looking in
   /srv/www/ccm/htdocs/static/js/tiny_mce.js

On the WinXP dev server tiny_mce works fine based on the above MEDIA_URL
and MEDIA_ROOT.

Any hints, pointers or docco links gratefully followed

Thanks

Mike

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








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




Re: Announce: django-ldap-groups

2010-01-19 Thread Mike Dewhirst

On 6/08/2009 10:15am, Peter Herndon wrote:


I'm pleased to announce the release of django-ldap-groups.  Of special
interest for building intranet sites, django-ldap-groups allows Django
users to authenticate against LDAP, and allows site administrators to
map LDAP organizational units (OUs) to Django groups.  This mapping
allows LDAP-authenticated users to acquire site permissions based on
their LDAP OU membership, automatically when they first log in to the
Django site. The app is available at
http://code.google.com/p/django-ldap-groups/, and is BSD licensed.


Peter

I have implemented this against Novell eDirectory and it works brilliantly.

Highly recommended :)

Thank you

Mike



Currently the app has been tested and works against Microsoft Active
Directory and Novell eDirectory.  Other LDAP servers will probably work
using the eDirectory backend, but none have been tested at the time of
writing.

Please let me know if you have any questions or comments.

Regards,

---Peter Herndon

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





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




Re: leading zeros

2010-01-22 Thread Mike Dewhirst

On 23/01/2010 11:12am, Patrick wrote:

Hello All,

I'm sorry for being a newbe and posting this site, but I'm desperate.
I inherited a django site and  when posts are added through the admin
page they render like this:

http://website/posts/category/2010/1/11/post_information/

but the link will only work if you add the leading zero to make it
look like this:


In the view called, extract the value which might need the leading zero 
(day and/or month) and give it one like this ...


def leadzero(val):
"""converts any val to a string"""
mth = '00%s' % val
# return the last 2 chars
return mth[-2:]



http://website/posts/category/2010/01/11/post_information/

Would any of you be kind enough to point me in the right direction to
resolve this?

thank you in advance,

patrick



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



Re: django and ldap

2010-02-04 Thread Mike Dewhirst

On 4/02/2010 11:14pm, David De La Harpe Golden wrote:

On 04/02/10 08:33, andreas schmid wrote:

@brad: can you show me some sample code for this?



David

I am using Peter Herndon's django-ldap-groups successfully. He has two 
backends; one for Novell's eDirectory which I'm using and another for MS 
Active Directory which I haven't tried.


   http://pypi.python.org/pypi/django-ldap-groups/0.1.3

... and here the relevant bits of my settings.py. Peter's comments all 
start on a new line while mine don't. I haven't adjusted anything here - 
this is working code. The getcreds() method simply fetches userid and 
password from a non-versioned file. I try and keep such stuff out of the 
repository  ...


ssl = True  # switch between SSL and non-SSL
SEARCH_DN = 'O=pq8nw'   # Organization name
# NT4_DOMAIN is used with Active Directory only, comment out for eDirectory
# NT4_DOMAIN = 'EXAMPLE'
# sAMAccountName is used with Active Directory
# Use the following for Active Directory
# SEARCH_FIELDS = ['mail','givenName','sn','sAMAccountName','memberOf','cn']
# Use the following for Novell eDirectory
# SEARCH_FIELDS = ['mail', 'givenName', 'sn', 'groupMembership', 'cn']
SEARCH_FIELDS = ['mail', 'givenName', 'sn', 'groupMembership', 'cn']

nds = credsdir + APP + '.nds'   # contains credentials
cred = getcreds(nds)# returns a 2-element list
BIND_USER = 'cn=%s,%s' % (cred[0], SEARCH_DN)
BIND_PASSWORD = cred[1] # valid password too
# CERT_FILE = ''# not used if ssl == False
ldap_srv = '192.168.0.108'
ldap_port = 389
protocol = 'ldap'
if ssl:
protocol = 'ldaps'
ldap_port = 636
CERT_FILE = credsdir + 'cert_pq8nw_9a30.b64'

LDAP_URL = protocol + '://%s:%s' % (ldap_srv, ldap_port)

AUTHENTICATION_BACKENDS = (
'ldap_groups.accounts.backends.eDirectoryGroupMembershipSSLBackend',

#'ldap_groups.accounts.backends.ActiveDirectoryGroupMembershipSSLBackend',
'django.contrib.auth.backends.ModelBackend',
)

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



Re: django-debug-toolbar and 404's

2010-02-10 Thread Mike Dewhirst

Rishab

Maybe you haven't included any toolbar panels?

Here is an example ...

if TOOLBAR:
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': TOOLBAR_REDIRECTS,
'SHOW_TOOLBAR_CALLBACK': None,
}

DEBUG_TOOLBAR_PANELS = (
#'debug_toolbar.panels.version.VersionDebugPanel',
#'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
)

MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

INSTALLED_APPS += (
'debug_toolbar',
)

Mike

On 11/02/2010 2:07pm, Rishabh Manocha wrote:

Hey Guys,

I know I must be doing something stupid here, but for the life of me, I
can't seem to be able to get django-debug-toolbar to work - I keep
getting a 404 error whenever I visit http://localhost:8000/admin/ (see
[1]). I've followed the Installation instructions at
http://github.com/robhudson/django-debug-toolbar. Here are the relevant
sections of my settings.py:

...
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

ROOT_URLCONF = 'testproject.urls'
...
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'testapp',
'debug_toolbar',
)

INTERNAL_IPS = ('127.0.0.1', )

and my testproject.urls.py :

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
 # Example:
 # (r'^testproject/', include('testproject.foo.urls')),

 # Uncomment the admin/doc line below and add
'django.contrib.admindocs'
 # to INSTALLED_APPS to enable admin documentation:
 # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

 # Uncomment the next line to enable the admin:
 (r'^admin/', include(admin.site.urls)),
)

This is running against 'Django version 1.2 beta 1', python 2.5.and the
latest checkout of django-debug-toolbar from github (if it matters, I've
symlinked the debug_toolbar folder into my site-packages).

I'd really appreciate pointers as to what I'm doing wrong here.

--

Best,

R

[1] - http://i.imgur.com/5GkiQ.png

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


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



Re: Django IDE

2010-02-17 Thread Mike Dewhirst

On 18/02/2010 9:38am, Jacek Furmankiewicz wrote:

We've had fairly good experience with Eclipse and the PyDev plugins
for it. Gives you even refactoring, which came in handy a few times.



I tried it and liked that but couldn't stick with it. My problem was 
integrating subversion in a seamless way. It all became too heavy and 
was really distracting me from actual programming. I went back to a nice 
editor and manual refactoring. It feels much more nimble.


ymmv

Mike

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



Re: LDAP Authentication and Single Sign on

2010-02-18 Thread Mike Dewhirst

On 19/02/2010 1:53am, Wayne wrote:

Hi,

I am about to develop an admin interface using Django framework for
several web applications . By design, those applications will be
decentralized, which means that they may use different databases and
reside on different servers and they will talk to each other via web
services. We have our LDAP server and we plan to use it for
authentication purpose. The authorization part for each application
will be handled locally by individual application. We want to
authenticate user only once for the access to multiple applications as
long as the log-in session does not expire.

What tools and packages Django can provide to realize our design? What
is the best strategy for the development?


http://www.mail-archive.com/django-users@googlegroups.com/msg94612.html



Many thanks in advance for your help and time.

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: custom auth backend and ./manage.py test

2010-02-21 Thread Mike Dewhirst

On 22/02/2010 10:53am, Stephen Crosby wrote:

I'm working on a project that requires a custom auth backend which
I've just written by subclassing contrib.auths.backends.ModelBackend
and overriding the authenticate method so it takes a third parameter.
It works nicely, but of course there are now lots of failed auth-
related tests because of the required third parameter to authenticate
when I run ./manage.py test. Related tests for my subclass of
contrib.auth.forms.AuthenticationForm also fail.

I'm just getting my feet wet with testing, so I don't know how to deal
with this properly. Can I override the default tests with new,
relevant ones? Should I just not subclass ModelBackend and
AuthenticationForm? Can I just tell django to skip certain tests?


I would leave existing tests to prove that the un-subclassed ancestral 
code stays wholesome and just write specific tests to prove your own new 
stuff.


hth

Mike




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



Re: How to share settings file in multiprogrammer project

2010-03-28 Thread Mike Dewhirst

On 29/03/2010 7:50am, Guillermo wrote:

Hi,

I'm working on a project with multiple programmers for the first time,
and I'm not sure how I should go about commiting the Django project's
setting file to the public repo. Since it can contain sensitive data,
how's this done usually so everybody works with the same settings
during development?


Guillermo

I write a little fetcher method which runs inside settings.py so I don't 
have to put credentials in the repository.


I keep all credentials in separate files in a credsdir and call 
settings.getcreds() for anything I need inside Django. credsdir still 
needs to be invisible in the filesystem to every user except the http 
server - chmod 700. If something was seriously sensitive you could use 
SSL/TLS and get your credentials from a secure server.


credsdir = '/srv/www/' + APP + /creds/'
creds =credsdir + APP +'.cred'
def getcreds(fname=creds):
#The first line of creds is user, next is password
fh = open(fname,'r')
cred = [fh.readline().strip(), fh.readline().strip()]
fh.close()
return cred

You choose your location according to location of your devs.

Mike


Cheers,
Guillermo



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



django version detection

2010-03-28 Thread Mike Dewhirst
Can someone kindly tell me how I can detect which subversion revision of 
Django is actually installed on my machine?


I need to re-install the exact same revision on another platform.

It is probably staring me in the face but I must be looking elsewhere.

Thanks

Mike

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



Re: django version detection

2010-03-28 Thread Mike Dewhirst

Much appreciated :)

M

On 29/03/2010 11:10am, Russell Keith-Magee wrote:

On Mon, Mar 29, 2010 at 8:07 AM, Mike Dewhirst  wrote:

Can someone kindly tell me how I can detect which subversion revision of
Django is actually installed on my machine?

I need to re-install the exact same revision on another platform.

It is probably staring me in the face but I must be looking elsewhere.


Yup :-)


import django
django.get_version()

'1.2 beta 1'

If you're installing from a SVN repository, you'll get an SVN revision too:


django.get_version()

'1.2 beta 1 SVN-12843'

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: django admin

2021-10-10 Thread Mike Dewhirst
Try manage.py collectstatic--(Unsigned mail from my phone)
 Original message From: Baraka Nzavi  
Date: 11/10/21  07:32  (GMT+10:00) To: Django users 
 Subject: django admin hello guys...what leads 
to the admin interface misbehaving in that the styling does not show



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c6a6bc37-1f3a-45d5-9b21-509295dfd220n%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/616368e2.1c69fb81.b6c16.8d20SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


RE: Permissions Model Inefficiency Killing DB

2021-11-24 Thread Mike Dewhirst
Do you think this is a consequence of permission complexity?I have 
instinctively avoided individual permissions for purely management reasons and 
stuck to user membership of auth groups (roles) and given permissions 
exclusively to groups.That postpones lookups to when they are needed.I can't 
imagine how difficult it would be to unravel your scenario and impose group 
permissions.Sorry I can't help with your actual question.CheersMike--(Unsigned 
mail from my phone)
 Original message From: Ryan Skadberg  Date: 
25/11/21  07:35  (GMT+10:00) To: Django users  
Subject: Permissions Model Inefficiency Killing DB Hi All -  Running Django 
2.2.24 (Yes, I know, we are working on moving to 3.2)  I've noticed some stalls 
in startup and finally have tracked it down.  It appears when permissions are 
imported, it checks EVERY user for permissions, NOT just the ones in the 
user_user_permissions table.  When you have 30k users in your DB this causes at 
least 60k SQL calls on startup.They all look something like this:2021-11-24 
19:04:46.725 UTC [39] LOG:  duration: 0.344 ms  statement: SELECT 
"auth_group"."id", "auth_group"."name" FROM "auth_group" INNER JOIN 
"user_groups" ON ("auth_group"."id" = "user_groups"."group_id") WHERE 
"user_groups"."customuser_id" = 273452021-11-24 19:04:46.728 UTC [39] LOG:  
duration: 0.379 ms  statement: SELECT "auth_permission"."id", 
"auth_permission"."name", "auth_permission"."content_type_id", 
"auth_permission"."codename" FROM "auth_permission" INNER JOIN 
"user_user_permissions" ON ("auth_permission"."id" = 
"user_user_permissions"."permission_id") INNER JOIN "django_content_type" ON 
("auth_permission"."content_type_id" = "django_content_type"."id") WHERE 
"user_user_permissions"."customuser_id" = 27345 ORDER BY 
"django_content_type"."app_label" ASC, "django_content_type"."model" ASC, 
"auth_permission"."codename" ASC I have 677 rows in user_user_permissions with 
a minimum customuser_id of 0 and a max of 27346.  When I start up my tests, 
instead of looking at the 677 users that have permissions in the 
user_user_permissions table, it checks all 27346.  As there is nothing in the 
table for them, this is super super inefficient.It appears that the SQL is 
doing something like:select id from public.userAnd really should be doing 
something like this to minimize SQL calls:select id from public.user where id 
in (select customuser_id from user_user_permissions);which in my case would be 
1/30th of the calls, which would be HUGE for startup (60k to 2k or so).Can 
anyone either explain why this is happening or a way to work around it or if I 
should file a bug?Thanks!Ryan



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0d5aa4db-ccd7-482a-8530-1cc8d76bbcc0n%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/619ebdd8.1c69fb81.4b1ac.9e2dSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


RE: Models

2022-01-21 Thread Mike Dewhirst
Not safely. You would need to script everything behind the scenes - including 
migration.A safer approach might be to use a generic table which contains the 
necessary meta information (char, int etc) as data alongside the actual data in 
each row. I would also consider booking sessions with a psychiatrist because 
that way madness lies!Maybe think about MongoDB although I have read somewhere 
that PostgreSQL has all you need if you are thinking about Mongo.Good 
luck--(Unsigned mail from my phone)
 Original message From: Prashanth Patelc 
 Date: 22/1/22  04:59  (GMT+10:00) To: Django users 
 Subject: Models Dear Django users,I need some 
information regarding Django models, I would  like to  know is there any way to 
create Django models through frontend or can we create models by super admin. 
Kindly share any tutorials or any examples available.Example:we are create 
models in djangolike below  fields ===class 
modelname(models.Model):       id = models.PrimeryKey(auto_now_add=true)       
name =models.CharField()       salary =models.DecimalField()But my concern is 
create model name and fields like in html or super admin can 
do> he will enter values in variables  with appropriate 
field type. for  eg., "name char  type", "Salary decimal field" and so 
on..=>When the user enter data into application it should directly store in 
database in the form of tables and rows..Regards;Prashanthemail : 
prashanthpat...@gmail.com 



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f065b2d2-6f1b-4a06-8302-e0ca5014ed2cn%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/61eb3dd0.1c69fb81.dfc41.c9dcSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Django docs failing with search docs - certificate has expired

2022-02-02 Thread Mike Dewhirst


 Error 503 certificate has expired

certificate has expired


 Guru Mediation:

Details: cache-syd10147-SYD 1643862123 79021947



Varnish cache server


--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8a77e035-5132-a2a6-f34a-a69724c1a4b7%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Django docs failing

2022-02-02 Thread Mike Dewhirst
The following error occurs when searching the docs for a term. It looks 
like the content delivery network node in Sydney Australia has had a 
certificate renewal glitch.



Error 503 certificate has expired

certificate has expired


Guru Mediation:

Details: cache-syd10147-SYD 1643862123 79021947



Varnish cache server


--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8a77e035-5132-a2a6-f34a-a69724c1a4b7%40dewhirst.com.au.

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0640f863-9d86-b79b-94b6-25542b2310ab%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


FIXED [Was: Django docs failing]

2022-02-02 Thread Mike Dewhirst

The internet seems to be self healing!

On 3/02/2022 3:47 pm, Mike Dewhirst wrote:
The following error occurs when searching the docs for a term. It 
looks like the content delivery network node in Sydney Australia has 
had a certificate renewal glitch.



Error 503 certificate has expired

certificate has expired


Guru Mediation:

Details: cache-syd10147-SYD 1643862123 79021947



Varnish cache server





--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/80c99857-f22e-d2fe-f623-a41b7687d796%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Off topic slightly - Apache https redirect

2022-02-06 Thread Mike Dewhirst
There seems to be a multitude of ways to redirect from http to 
https.Letsencrypt rewrote my conf for port 80 traffic to https but when a 
customer used http://mysite.com it brought up the Apache "this is working" 
page.Any pointers to the absolutely correct way?ThanksMike--(Unsigned mail from 
my phone)

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62007f89.1c69fb81.6f671.d033SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Off topic slightly - Apache https redirect

2022-02-07 Thread Mike Dewhirst
Yes ... that's almost what I went with after reading up on the topic. I left 
the 'permanent' off.Thanks Bob and everyone.CheersMike--(Unsigned mail from my 
phone)
 Original message From: Bob Kline  Date: 
8/2/22  06:30  (GMT+10:00) To: Django users  
Subject: Re: Off topic slightly - Apache https redirect On Sunday, February 6, 
2022 at 9:12:38 PM UTC-5 Mike Dewhirst wrote:There seems to be a multitude of 
ways to redirect from http to https.Any pointers to the absolutely correct 
way?How about something like this?   ServerName example.com  
ServerAlias www.example.com  Redirect permanent / 
https://example.com/  ... 



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c8c8177d-49c0-45f7-b382-31855ccb6b0an%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62018eb3.1c69fb81.e0fe.0b9fSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


  1   2   3   4   5   6   7   8   9   10   >