Re: How to allow a ForeignKey field to be null

2007-10-10 Thread Jeremy Dunck

On 10/11/07, Greg <[EMAIL PROTECTED]> wrote:
>
> Hello,
> I have the following field in my Orders class
>
> delivery_method = models.ForeignKey(Delivery)
>
> I want to be able to add a Order record and not specify a Delivery
> option when the order is initially created.
>
> I've tried
>
> delivery_method = models.ForeignKey(Delivery, null=True)
> and
> delivery_method = models.ForeignKey(Delivery,blank=True)
>
> However, when I do this I get the error 'This field is required'

Try it with both.
null=True, blank=True

null is DB-specific.  blank is validation-specific.

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



How to allow a ForeignKey field to be null

2007-10-10 Thread Greg

Hello,
I have the following field in my Orders class

delivery_method = models.ForeignKey(Delivery)

I want to be able to add a Order record and not specify a Delivery
option when the order is initially created.

I've tried

delivery_method = models.ForeignKey(Delivery, null=True)
and
delivery_method = models.ForeignKey(Delivery,blank=True)

However, when I do this I get the error 'This field is required'

/

Any suggestions?


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



Re: TinyMCE in admin

2007-10-10 Thread Jeremy Dunck

On 10/11/07, AniNair <[EMAIL PROTECTED]> wrote:
>
> My admin url ishttp://localhost:8000/admin/flatpages/flatpage/1/
>  The url being requested is
> [11/Oct/2007 10:21:35] "GET /admin/flatpages/flatpage/1/media/js/
> tiny_mce/tiny_m
> ce.js HTTP/1.1" 404 3644
> [11/Oct/2007 10:21:35] "GET /admin/flatpages/flatpage/1/media/js/
> tiny_mce/textar
> eas.js HTTP/1.1" 404 3647
>

And what URL would you *expect* to successfully serve the media?
As the doc[1] describes, relative URLs are prepended w/
settings.ADMIN_MEDIA_PREFIX.

[1]
http://www.djangoproject.com/documentation/model-api/#js

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



Re: TinyMCE in admin

2007-10-10 Thread AniNair

My admin url ishttp://localhost:8000/admin/flatpages/flatpage/1/
 The url being requested is
[11/Oct/2007 10:21:35] "GET /admin/flatpages/flatpage/1/media/js/
tiny_mce/tiny_m
ce.js HTTP/1.1" 404 3644
[11/Oct/2007 10:21:35] "GET /admin/flatpages/flatpage/1/media/js/
tiny_mce/textar
eas.js HTTP/1.1" 404 3647




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



Re: TinyMCE in admin

2007-10-10 Thread Jeremy Dunck

On 10/11/07, AniNair <[EMAIL PROTECTED]> wrote:
>
> I am trying to follow the method in 
> http://code.djangoproject.com/wiki/AddWYSIWYGEditor
>
> . I still can't get django find the files textareas.js and
> tiny_mce.js. it's returning 404. Please help. Thank you
>

What's your admin URL and what URL is being requested for the textarea.js?
This is generally a matter of putting the right number of ../ bits in
your Admin.js attribute.

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



TinyMCE in admin

2007-10-10 Thread AniNair

I am trying to follow the method in 
http://code.djangoproject.com/wiki/AddWYSIWYGEditor

. I still can't get django find the files textareas.js and
tiny_mce.js. it's returning 404. Please help. Thank you


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



Re: How to delete a table?

2007-10-10 Thread Jeremy Dunck

On 10/11/07, Greg <[EMAIL PROTECTED]> wrote:
...
> Do I need to do this with my sqliteman software
Yes.

> or ca I do something
> like Orders.delete() in my djano command prompt.

No.

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



How to delete a table?

2007-10-10 Thread Greg

Hello,
Simple question,  I have a database table called Orders.  I want to
delete this table so that when I do 'python manage.py syncdb' the
table will get recreated.  I want to make some modifications to the
columns in the table and I can't seem to do the with SQLite.  I don't
want to delete the information from my other tables...just the Orders
table.

Do I need to do this with my sqliteman software or ca I do something
like Orders.delete() in my djano command prompt.

Thanks


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



Re: Better solutions for my views?

2007-10-10 Thread John M

for your second question, i think you could use the ifchanged template
directive on a list of all your media information.  Similar to what
you're doing, but you don't have to build a dictionary, the templates
will print when the field on ifchanged changes.  something like that I
think.

J

On Oct 10, 3:17 pm, Bernd <[EMAIL PROTECTED]> wrote:
> Question 1 is solved. the brackets are wrong. right way is:
>   {% for event in events %}
>   event.get_thumbnail_url
>   {% endfor %}
>
> I would be appreciate if there would be any ideas to my second question
>
>   Bernd
>


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



Newforms Field Limit Question

2007-10-10 Thread machineghost

I recently attempted to implement a very large form using the newforms
library, and I discovered that if a form contains more than 45 fields
it generates a "too many values to unpack" error when you try to
render it in a template.  Does anyone know if this is deliberate
(either because of some Pythonic limitation or simply to stop people
from making insanely large forms), or whether this is something I
should file a bug for?  If it is deliberate, I think that a line
somewhere in the documentation about it would be helpful to anyone
else who tries to make a way-too-big form.

Jeremy


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



Re: problem with ChangeManipulator

2007-10-10 Thread [EMAIL PROTECTED]

Are you sure that articolo is not None or that c is not an int or
None?

On Oct 10, 12:48 pm, Gio <[EMAIL PROTECTED]> wrote:
> I get this error:
> unsupported operand type(s) for +: 'NoneType' and 'int'
>
> referred to this snippet of code, debug informations are pointing to
> the line where the ChangeManipulator is:
> -
> articolo = Articolo.objects.get(codice = c)
> try:
> manipulator = Articolo.ChangeManipulator(articolo.id)
> except Articolo.DoesNotExist:
> return HttpResponse('{success:false}')
> -
>
> Articolo, as defined in models.py
> -
> class Articolo(models.Model):
> codice= models.CharField(maxlength=255, unique=True)
> descrizione   = models.CharField(maxlength=255)
> immagine  = models.ImageField(upload_to='uploads')
> brand = models.ForeignKey(Brand)
> stagione  = models.ForeignKey(Stagione)
> prefisso  = models.ForeignKey(Prefisso)
> colore= models.ForeignKey(Colore)
> costo_imposto = models.FloatField(null=True)
> maggiorazione = models.IntegerField()
>
> def __str__(self):
> return self.codice
>
> class Meta:
> verbose_name_plural = 'articoli'
> ordering = ['codice']
>
> class Admin:
> pass
>
> def save(self):
> size = 300, 100
> try:
> im = Image.open(self.get_immagine_filename())
> im.thumbnail(size)
> im.save(self.get_immagine_filename(), im.format)
> except:
> self.immagine = 'none.jpg'
> super(Articolo, self).save()
>
> def delete(self):
> if self.immagine <> 'none.jpg':
> remove(self.get_immagine_filename())
> super(Articolo, self).delete()
> -
>
> Any idea?
> tnx


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



Re: filtering by null related object

2007-10-10 Thread Benjamin Slavin

Hi Casey,

You may want to take a look at ticket #1050.
http://code.djangoproject.com/ticket/1050

 - Ben

On 10/10/07, Casey T. Deccio <[EMAIL PROTECTED]> wrote:
>
> Given the following models:
>
> class ModelA(models.Model):
>   name = models.CharField(max_length=10)
>
> class ModelB(models.Model):
>   a = models.ForeignKey(ModelA)
>   name = models.CharField(max_length=10)
>
> I'd like to perform a query for ModelA objects that have no ModelB
> objects referring to them.  Is there a way to do this?  I've tried the
> following:
>
> qs = ModelA.objects.filter(modelb=None)
> qs = ModelA.objects.filter(modelb__isnull=True)
>
> but these don't work because INNER JOINs are performed on the tables, so
> there is no column to check for NULL.  How do others do this?
>
> Regards,
> Casey
>
>
>
>
> >
>

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



Collapsing Template blocks

2007-10-10 Thread handsome greg

Just a quick question about templates: I'm coming from a templating
system (html_template_sigma - ouch, I know) where you are able to hide
and show blocks like tpl.hideBlock('block_name'). ANY clue how I might
go about mimicking this behavior until we have a chance to revamp how
our templates are created in the first place? These templates are also
NOT coming from disk and are passed as strings to the module. I was
thinking of creating a secondary template that overrides the blocks I
want to hide with {% block hide_me %}{% endblock %} and then making
that extend the original template, but can't figure out how I would do
that unless the original template was on disk somewhere - which isn't
a fun option. Any pointers?

handsome 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Question 1 is solved. the brackets are wrong. right way is: {% for event in events %} event.get_thumbnail_url {% endfor %} I would be appreciate if there would be any ideas to my second question Bernd

2007-10-10 Thread Bernd
Question 1 is solved. the brackets are wrong. right way is:
  {% for event in events %}
  event.get_thumbnail_url
  {% endfor %}

I would be appreciate if there would be any ideas to my second question


  Bernd


On Wed, 2007-10-10 at 23:46 +0200, Bernd wrote:
> Hello,
>
> I'm working on a website with Django and I'm new to django, python and
> webdevelopment. I use the latest django svn-version.
> I have a few pages/templates and they worked. But I think about to
> simplify the source-code with the right use of django and python. I
> think my views are complicated right now and there must/should be a
> better solution.
>
> Models:
>
> class EventType(models.Model):
> type= models.CharField(max_length=40, unique=True)
> useable = models.BooleanField()
> crdate  = models.DateTimeField (auto_now_add=True)
> chdate  = models.DateTimeField(auto_now=True)
>
> class Event(models.Model):
> eventdate = models.DateField(core=True)
> eventtype = models.ForeignKey(EventType, limit_choices_to =
> {'useable': True})
> show_pics = models.BooleanField()
> crdate= models.DateTimeField(auto_now_add=True)
> chdate= models.DateTimeField(auto_now=True)
>
> def get_thumbnail_url(self):
>   return Config.objects.get (key='LINK_FLYER_TN').value % \
>  {'edate': self.eventdate.strftime('%Y%m%d'),
>   'mediaurl': settings.MEDIA_URL}
> # returns an url for  a thumbnail-picture
> # LINK_FLYER_TN = %(mediaurl)sevents/%(edate)s/%edate)s_tn.jpg
> # I don't save the name in an imagefield, because the only
> difference is the date
>
> class Media(models.Model):
> event   = models.ForeignKey(Event)
> partner = models.ForeignKey(Partner)
> desc= models.CharField(max_length=50)
> media   = models.ImageField(upload_to='events/%Y%m%d/presse')
> publishdate = models.DateField()
> show_media  = models.BooleanField()
> crdate  = models.DateTimeField(auto_now_add=True)
> chdate  = models.DateTimeField(auto_now=True)
>
>
> 2 Exercises/Questions:
>
> 1... I want to view a thumbnail-list from all events. So I thought I
> pass a dataset to my view
> events =
> Event.objects.select_related().filter(show_pics=True).order_by('-eventdate')

>
>
>   But so it's not possible to call:
>   {% for event in events %}
>event.get_thumbnail_url()
>   {% endfor %}
>
>
>   Now my solution is to loop through the dataset in a view and
> build a dictionary with the required information.
>   But in that case I loop twice through all events. The first time
> in the view. The second time in the template :-(
>
>   Does anybody know a better solution without saving the
> thumbnail-name/url in the database
>
> 2... For the events I have one ore more "Media". I want to create a
> site with following structure:
>
> Heading with Eventinformation
> First Mediainformation (related to the event above)
> Second Mediainformation (related to the event above)
> 
>
> Next Heading with Eventinformation
> First Mediainformation (related to the event above)
> .
>
>
>
>   Today my solution is the same as above. I loop through
> events/media in a view and create a dictionary
> {[eventinfo, [mediainfo, mediainfo,..]], [eventinfo, [mediainfo,
> mediainfo,..]],...}
>
>
>
> I hope my explanation is understandable and somebody can help me with
> a better solution. thanks
>
> Regards
>   Bernd
>
>
>
>

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



Re: dict objects are unhashable

2007-10-10 Thread Jeremy Dunck

On 10/10/07, kevinski <[EMAIL PROTECTED]> wrote:
>
> Honestly, I do not know what that means. How do I check this?

Apologies-- I assumed that the problem had something to do with
unicode and localization.

http://www.djangoproject.com/documentation/i18n/#if-you-don-t-need-internationalization-in-your-app

I now see the problem doesn't have anything to do with that.  The
problem appears to be with your urlconf.  Specifically, it appears
that you're providing a dictionary rather than a string for the name
parameter (the 4th parameter to an urlpatterns tuple).

If you have trouble identifying which one, please include the code
from positiontech2.urls so I can point out the problem.

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



Re: Better solutions for my views?

2007-10-10 Thread Bernd

Question 1 is solved. the brackets are wrong. right way is:
  {% for event in events %}
  event.get_thumbnail_url
  {% endfor %}

I would be appreciate if there would be any ideas to my second question


  Bernd


On Wed, 2007-10-10 at 23:46 +0200, Bernd wrote:
> Hello,
> 
> I'm working on a website with Django and I'm new to django, python and
> webdevelopment. I use the latest django svn-version.
> I have a few pages/templates and they worked. But I think about to
> simplify the source-code with the right use of django and python. I
> think my views are complicated right now and there must/should be a
> better solution. 
> 
> Models:
> 
> class EventType(models.Model):
> type= models.CharField(max_length=40, unique=True)
> useable = models.BooleanField()
> crdate  = models.DateTimeField (auto_now_add=True)
> chdate  = models.DateTimeField(auto_now=True)
> 
> class Event(models.Model):
> eventdate = models.DateField(core=True)
> eventtype = models.ForeignKey(EventType, limit_choices_to =
> {'useable': True}) 
> show_pics = models.BooleanField()
> crdate= models.DateTimeField(auto_now_add=True)
> chdate= models.DateTimeField(auto_now=True)
> 
> def get_thumbnail_url(self):
>   return Config.objects.get (key='LINK_FLYER_TN').value % \
>  {'edate': self.eventdate.strftime('%Y%m%d'),
>   'mediaurl': settings.MEDIA_URL}
> # returns an url for  a thumbnail-picture 
> # LINK_FLYER_TN = %(mediaurl)sevents/%(edate)s/%edate)s_tn.jpg
> # I don't save the name in an imagefield, because the only
> difference is the date
> 
> class Media(models.Model):
> event   = models.ForeignKey(Event)
> partner = models.ForeignKey(Partner)
> desc= models.CharField(max_length=50)
> media   = models.ImageField(upload_to='events/%Y%m%d/presse') 
> publishdate = models.DateField()
> show_media  = models.BooleanField()
> crdate  = models.DateTimeField(auto_now_add=True)
> chdate  = models.DateTimeField(auto_now=True)
> 
> 
> 2 Exercises/Questions:
> 
> 1... I want to view a thumbnail-list from all events. So I thought I
> pass a dataset to my view
> events =
> Event.objects.select_related().filter(show_pics=True).order_by('-eventdate') 
> 
> 
>   But so it's not possible to call:
>   {% for event in events %}
>event.get_thumbnail_url()
>   {% endfor %}
> 
> 
>   Now my solution is to loop through the dataset in a view and
> build a dictionary with the required information. 
>   But in that case I loop twice through all events. The first time
> in the view. The second time in the template :-(
> 
>   Does anybody know a better solution without saving the
> thumbnail-name/url in the database 
> 
> 2... For the events I have one ore more "Media". I want to create a
> site with following structure:
>   
> Heading with Eventinformation
> First Mediainformation (related to the event above)
> Second Mediainformation (related to the event above)
> 
> 
> Next Heading with Eventinformation
> First Mediainformation (related to the event above) 
> .
> 
> 
> 
>   Today my solution is the same as above. I loop through
> events/media in a view and create a dictionary 
> {[eventinfo, [mediainfo, mediainfo,..]], [eventinfo, [mediainfo,
> mediainfo,..]],...} 
> 
> 
> 
> I hope my explanation is understandable and somebody can help me with
> a better solution. thanks
> 
> Regards
>   Bernd
> 
> 
> 
> 


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



Re: dict objects are unhashable

2007-10-10 Thread kevinski

#  C:\Python25\lib\site-packages\django\core\urlresolvers.py in
reverse

 274. return self._resolve_special('500')
 275.
 276. def reverse(self, lookup_view, *args, **kwargs):
 277. try:
 278. lookup_view = get_callable(lookup_view, True)
 279. except (ImportError, AttributeError):
 280. raise NoReverseMatch

 281. if lookup_view in self.reverse_dict: ...

 282. return u''.join([reverse_helper(part.regex, *args, **kwargs) for
part in self.reverse_dict[lookup_view]])
 283. raise NoReverseMatch
 284.
 285. def reverse_helper(self, lookup_view, *args, **kwargs):
 286. sub_match = self.reverse(lookup_view, *args, **kwargs)
 287. result = reverse_helper(self.regex, *args, **kwargs)

▼ Local vars
VariableValue
args
()
kwargs
{}
lookup_view

self

# C:\Python25\lib\site-packages\django\core\urlresolvers.py in
_get_reverse_dict

 215. if not self._reverse_dict and hasattr(self.urlconf_module,
'urlpatterns'):
 216. for pattern in reversed(self.urlconf_module.urlpatterns):
 217. if isinstance(pattern, RegexURLResolver):
 218. for key, value in pattern.reverse_dict.iteritems():
 219. self._reverse_dict[key] = (pattern,) + value
 220. else:
 221. self._reverse_dict[pattern.callback] = (pattern,)

 222. self._reverse_dict[pattern.name] = (pattern,) ...

 223. return self._reverse_dict
 224. reverse_dict = property(_get_reverse_dict)
 225.
 226. def resolve(self, path):
 227. tried = []
 228. match = self.regex.search(path)

▼ Local vars
VariableValue
pattern
\d+)/$>
self


On Oct 10, 4:43 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 10/10/07, kevinski <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > Can someone help me with the following error. It occurs when I restart
> > Apache and try to load the Admin page. When I refresh, the Admin page
> > comes up, however the Documentation, Change Password, and Log Out
> > links callhttp://localhost/admin/. I reinstalled Django, but it did
> > not help.
> 
> >        215. if not self._reverse_dict and hasattr(self.urlconf_module,
> > 'urlpatterns'):
> >        216. for pattern in reversed(self.urlconf_module.urlpatterns):
> >        217. if isinstance(pattern, RegexURLResolver):
> >        218. for key, value in pattern.reverse_dict.iteritems():
> >        219. self._reverse_dict[key] = (pattern,) + value
> >        220. else:
> >        221. self._reverse_dict[pattern.callback] = (pattern,)
> >        222. self._reverse_dict[pattern.name] = (pattern,) ...
> >        223. return self._reverse_dict
> >        224. reverse_dict = property(_get_reverse_dict)
> >        225.
> >        226. def resolve(self, path):
> >        227. tried = []
> >        228. match = self.regex.search(path)
> >       ▶ Local vars
>
> Also, please expand local vars and show what the values of
> self._reverse_dict and pattern.name are.- Hide quoted text -
>
> - Show quoted text -


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



Re: dict objects are unhashable

2007-10-10 Thread kevinski

Honestly, I do not know what that means. How do I check this?

On Oct 10, 4:41 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 10/10/07, kevinski <[EMAIL PROTECTED]> wrote:
>
>
>
> > Can someone help me with the following error. It occurs when I restart
> > Apache and try to load the Admin page. When I refresh, the Admin page
> > comes up, however the Documentation, Change Password, and Log Out
> > links callhttp://localhost/admin/. I reinstalled Django, but it did
> > not help.
>
> What locale are you using?


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



Better solutions for my views?

2007-10-10 Thread Bernd
Hello,

I'm working on a website with Django and I'm new to django, python and
webdevelopment. I use the latest django svn-version.
I have a few pages/templates and they worked. But I think about to simplify
the source-code with the right use of django and python. I think my views
are complicated right now and there must/should be a better solution.

Models:

class EventType(models.Model):
type= models.CharField(max_length=40, unique=True)
useable = models.BooleanField()
crdate  = models.DateTimeField(auto_now_add=True)
chdate  = models.DateTimeField(auto_now=True)

class Event(models.Model):
eventdate = models.DateField(core=True)
eventtype = models.ForeignKey(EventType, limit_choices_to = {'useable':
True})
show_pics = models.BooleanField()
crdate= models.DateTimeField(auto_now_add=True)
chdate= models.DateTimeField(auto_now=True)

def get_thumbnail_url(self):
  return Config.objects.get(key='LINK_FLYER_TN').value % \
 {'edate': self.eventdate.strftime('%Y%m%d'),
  'mediaurl': settings.MEDIA_URL}
# returns an url for  a thumbnail-picture
# LINK_FLYER_TN = %(mediaurl)sevents/%(edate)s/%edate)s_tn.jpg
# I don't save the name in an imagefield, because the only difference is
the date

class Media(models.Model):
event   = models.ForeignKey(Event)
partner = models.ForeignKey(Partner)
desc= models.CharField(max_length=50)
media   = models.ImageField(upload_to='events/%Y%m%d/presse')
publishdate = models.DateField()
show_media  = models.BooleanField()
crdate  = models.DateTimeField(auto_now_add=True)
chdate  = models.DateTimeField(auto_now=True)


2 Exercises/Questions:

1... I want to view a thumbnail-list from all events. So I thought I pass a
dataset to my view
events = Event.objects.select_related
().filter(show_pics=True).order_by('-eventdate')

  But so it's not possible to call:
  {% for event in events %}
   event.get_thumbnail_url()
  {% endfor %}

  Now my solution is to loop through the dataset in a view and build a
dictionary with the required information.
  But in that case I loop twice through all events. The first time in
the view. The second time in the template :-(

  Does anybody know a better solution without saving the
thumbnail-name/url in the database

2... For the events I have one ore more "Media". I want to create a site
with following structure:

Heading with Eventinformation
First Mediainformation (related to the event above)
Second Mediainformation (related to the event above)

Next Heading with Eventinformation
First Mediainformation (related to the event above)
.

  Today my solution is the same as above. I loop through events/media in
a view and create a dictionary
{[eventinfo, [mediainfo, mediainfo,..]], [eventinfo, [mediainfo,
mediainfo,..]],...}


I hope my explanation is understandable and somebody can help me with a
better solution. thanks

Regards
  Bernd

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



Re: dict objects are unhashable

2007-10-10 Thread Jeremy Dunck
On 10/10/07, kevinski <[EMAIL PROTECTED]> wrote:
>
> Can someone help me with the following error. It occurs when I restart
> Apache and try to load the Admin page. When I refresh, the Admin page
> comes up, however the Documentation, Change Password, and Log Out
> links call http://localhost/admin/. I reinstalled Django, but it did
> not help.

>215. if not self._reverse_dict and hasattr(self.urlconf_module,
> 'urlpatterns'):
>216. for pattern in reversed(self.urlconf_module.urlpatterns):
>217. if isinstance(pattern, RegexURLResolver):
>218. for key, value in pattern.reverse_dict.iteritems():
>219. self._reverse_dict[key] = (pattern,) + value
>220. else:
>221. self._reverse_dict[pattern.callback] = (pattern,)
>222. self._reverse_dict[pattern.name] = (pattern,) ...
>223. return self._reverse_dict
>224. reverse_dict = property(_get_reverse_dict)
>225.
>226. def resolve(self, path):
>227. tried = []
>228. match = self.regex.search(path)
>   ▶ Local vars
>

Also, please expand local vars and show what the values of
self._reverse_dict and pattern.name are.

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



Re: dict objects are unhashable

2007-10-10 Thread Jeremy Dunck

On 10/10/07, kevinski <[EMAIL PROTECTED]> wrote:
>
> Can someone help me with the following error. It occurs when I restart
> Apache and try to load the Admin page. When I refresh, the Admin page
> comes up, however the Documentation, Change Password, and Log Out
> links call http://localhost/admin/. I reinstalled Django, but it did
> not help.

What locale are you using?

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



dict objects are unhashable

2007-10-10 Thread kevinski

Can someone help me with the following error. It occurs when I restart
Apache and try to load the Admin page. When I refresh, the Admin page
comes up, however the Documentation, Change Password, and Log Out
links call http://localhost/admin/. I reinstalled Django, but it did
not help.


TypeError at /admin/
dict objects are unhashable
Request Method: GET
Request URL:http://localhost/admin/
Exception Type: TypeError
Exception Value:dict objects are unhashable
Exception Location: C:\Python25\lib\site-packages\django\core
\urlresolvers.py in _get_reverse_dict, line 222
Python Executable:  C:\wamp\apache2\bin\httpd.exe
Python Version: 2.5.1
Template error

In template c:\python25\lib\site-packages\django\contrib\admin
\templates\admin\base.html, error at line 28
Caught an exception while rendering: dict objects are unhashable
18  {% if not is_popup %}
19  
20  
21  
22  {% block branding %}{% endblock %}
23  
24  {% if user.is_authenticated and user.is_staff %}
25  
26  {% trans 'Welcome,' %} {% if user.first_name %}
{{ user.first_name|escape }}{% else %}{{ user.username }}{% endif %}.
27  {% block userlinks %}
28  {%
trans 'Documentation' %}
29  / {%
trans 'Change password' %}
30  / {% trans
'Log out' %}
31  {% endblock %}
32  
33  {% endif %}
34  {% block nav-global %}{% endblock %}
35  
36  
37  {% block breadcrumbs %}{%
trans 'Home' %}{% if title %}  {{ title|escape }}{% endif
%}{% endblock %}
38  {% endif %}
Traceback (innermost last)
Switch to copy-and-paste view

* C:\Python25\lib\site-packages\django\template\__init__.py in
render_node
   803.
   804. def render_node(self, node, context):
   805. return node.render(context)
   806.
   807. class DebugNodeList(NodeList):
   808. def render_node(self, node, context):
   809. try:
   810. result = node.render(context) ...
   811. except TemplateSyntaxError, e:
   812. if not hasattr(e, 'source'):
   813. e.source = node.source
   814. raise
   815. except Exception, e:
   816. from sys import exc_info
  ▶ Local vars
  Variable  Value
  context
  [{'block': '>, ,  / '>, ,  / '>, ,  '>]>}, {'title': u'Site
administration'}, {'MEDIA_URL': 'http://10.1.2.214:81/'},
{'LANGUAGES': (('ar', 'Arabic'), ('bn', 'Bengali'), ('bg',
'Bulgarian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'),
('da', 'Danish'), ('de', 'German'), ('el', 'Greek'), ('en',
'English'), ('es', 'Spanish'), ('es_AR', 'Argentinean Spanish'),
('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('ga',
'Gaeilge'), ('gl', 'Galician'), ('hu', 'Hungarian'), ('he', 'Hebrew'),
('hr', 'Croatian'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja',
'Japanese'), ('ko', 'Korean'), ('km', 'Khmer'), ('kn', 'Kannada'),
('lv', 'Latvian'), ('mk', 'Macedonian'), ('nl', 'Dutch'), ('no',
'Norwegian'), ('pl', 'Polish'), ('pt', 'Portugese'), ('pt-br',
'Brazilian'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'),
('sl', 'Slovenian'), ('sr', 'Serbian'), ('sv', 'Swedish'), ('ta',
'Tamil'), ('te', 'Telugu'), ('tr', 'Turkish'), ('uk', 'Ukrainian'),
('zh-cn', 'Simplified Chinese'), ('zh-tw', 'Traditional Chinese')),
'LANGUAGE_BIDI': False, 'LANGUAGE_CODE': 'en-us'}, {}, {'perms':
,
'messages': [], 'user': }, {}]
  e
  TypeError('dict objects are unhashable',)
  exc_info
  
  node
  
  self
  ['>,
,  / '>,
,  / '>,
,  '>]
  wrapped
  TemplateSyntaxError('Caught an exception while rendering: dict
objects are unhashable',)
* C:\Python25\lib\site-packages\django\template\defaulttags.py in
render
   337. self.kwargs = kwargs
   338.
   339. def render(self, context):
   340. from django.core.urlresolvers import reverse,
NoReverseMatch
   341. args = [arg.resolve(context) for arg in self.args]
   342. kwargs = dict([(smart_str(k,'ascii'), v.resolve(context))
for k, v in self.kwargs.items()])
   343. try:
   344. return reverse(self.view_name, args=args,
kwargs=kwargs) ...
   345. except NoReverseMatch:
   346. try:
   347. project_name = settings.SETTINGS_MODULE.split('.')[0]
   348. return reverse(project_name + '.' + self.view_name,
args=args, kwargs=kwargs)
   349. except NoReverseMatch:
   350. return ''
  ▶ Local vars
  Variable  Value
  NoReverseMatch
  
  args
  []
  context
  [{'block': '>, ,  / '>, ,  / '>, ,  '>]>}, {'title': u'Site
administration'}, {'MEDIA_URL': 'http://10.1.2.214:81/'},
{'LANGUAGES': (('ar', 'Arabic'), ('bn', 'Bengali'), ('bg',
'Bulgarian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'),
('da', 'Danish'), ('de', 'German'), ('el', 'Greek'), ('en',
'English'), ('es', 'Spanish'), ('es_AR', 'Argentinean Spanish'),
('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('ga',
'Gaeilge'), ('gl', 'Galician'), ('hu', 'Hungarian'), ('he', 'Hebrew'),

another 6 hour code jam - tagmindr.com

2007-10-10 Thread anders conbere

Just a quick announcement, though created without any for knowledge of
djangogigs, a group of us got together last Saturday with the proposal
of creating a fully functional web app from idea to production in 6
hours.

We were given the seed idea of an app that would help you remember
things you had tagged by reminding you at a certain date, and the
result was tagmindr. You give it a username that you use around the
web, and it will check ma.gnolia.com, de.licio.us and flickr for
anything tagged tagmindr, and then secondarily search those entries
for any tags of the form "remind:". When that date comes up, it
puts that item in a public rss feed that you can be watching.

http://tagmindr.com/

you can read more about the event at my blog

http://anders.conbere.org

or leo's blog

http://www.embracingchaos.com/2007/10/tagmindr-use-de.html

Anyway the event was a blast, we finished in about 6 and half hours,
and while the prod version only has support for delicious and magnolia
the flickr support was easy to add and is in svn.

That's all :-D

~ Anders

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



Re: RegexField and Admin interface

2007-10-10 Thread oliver

@ Nader : i think you got it, just give it a try! if it doesnt work
django will tell you anyway ;) You define a function that gets called
on validation of the field is the very abstract view of it as i
understand it.



On Oct 10, 6:34 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > class Property(models.Model):
> >def isValidUKPostcode(self, field_data):
> >p = re.compile(r'^(GIR 
> > 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HIK-Y][0-9](|
> > [0-9]|[ABEHMNPRVWXY]))|[0-9][A-HJKSTUW]) [0-9][ABD-HJLNP-UW-Z]{2})$')
> >if not p.match(field_data['postcode']):
> >raise validators.ValidationError("You have to have a 
> > space in the
> > Postcode and all Capital letters.")
>
> 
>
> I'm gonna raise a personal pet-peeve here...if the computer can
> reformat/clean the incoming value, it should do so.  Unless the
> space has specific syntactic value, you should normalize
> everything to an uppercase format with no spaces, and /then/
> validate it.  Or allow your validation to accept a sloppy value
> and then normalize it before you save.
>
> Either way, there's very little more user-abusive than requiring
> them to enter such things (phone numbers, ID numbers, credit-card
> numbers, etc) in an exact format.  PARTICULARLY when spaces are
> involved.  I had one site require that a US phone# be formatted
> as "(999) 999-".  I had to type the bloody parens, the dash,
> AND THE [expletive] SPACE before the form validated.
>
> On the other end of the spectrum, our VoIP system's web portal
> allows phone numbers to be entered in such a flexible number of
> ways that as long as I use numbers, it takes it.  With any
> mixture of dashes, periods, parens, spaces, or none of the above,
> it normalizes it into an internal format, and then displays it in
> a uniform fashion.
>
> 

I agree with that!  And i will probably make it better. Still
learning ;)
>
> My understanding of the "right/Django" way to do this using
> newforms is to use the clean_*  methods to normalize this data
> before it gets shoved off to the DB, and that these clean_*
> methods would look something like
>
>clean_postcode_re = re.compile('[^0-9a-z]', re.I)
>def clean_postcode(self):
>  return clean_postcode_re.sub('',self.postcode).upper()
>

do you need to do clean in the admin as well?

o

> However, this seems to do it on a (newform)Field-by-field basis.
>   I couldn't find much in the way of affixing such functionality
> to a Model field.  The best I've been able to determine, one uses
> a custom model field as decribed here:
>
> http://www.djangoproject.com/documentation/model-api/#custom-field-types
>
> with it's caveat about "read the source and if it breaks, you get
> to keep both pieces".  One would then override the
> get_db_prep_save() method to take the raw value and return the
> reformated/cleaned version (such as stripping out non-digit
> characters from a phone-number field).
>
> Is there an analog function for formatting things coming *out* of
> the DB?  Using the phonenumber example, one might want to use the
> get_db_prep_save() to strip out anything non-numeric, and then
> store that form in the DB, but then when getting the field,
> display it as a formatted number.  E.g:
>
>"800.555.1212" from the user
> ->  "8005551212" in the DB
>->  "(800)555-1212" coming back out from the DB
>
> -tim


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



Watch TV stations from around the World

2007-10-10 Thread jrou

Even watch the War in Iraq live and uncensored from your Laptop or PC
for FREE after a small onetime installment fee. 1,000's more
stations.  http://jblog.ipodpsp.hop.clickbank.net


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



Re: django_root or application_root ?

2007-10-10 Thread Malcolm Tredinnick

On Wed, 2007-10-10 at 10:19 -0700, Hugh Bien wrote:
> Hi,
> 
> 
> I'm a Django newbie (just finished the tutorial on djangobook.com).
> I'm about to try building a blog with Django to learn some more and I
> was wondering if there's some sort of DJANGO_ROOT that specifies the
> path to the root of your project.

Since you won't always have a "project", the answer is no. A project is
just a convenience. A directory holding some apps, settings file and URL
configuration file. However, you could quite happily have your
applications installed anywhere you like in your Python path and put
your settings and URL conf files somewhere different. This becomes more
common as you reuse applications. And there's no way for Python or
Django to know whether you have most things under one directory (not all
things, since you're already probably using django.sites.admin, for
example, which isn't installed in your project).

> The djangobook tipped us to use Python's __file__ for setting the
> TEMPLATE_DIRS:
> 
> 
> import os.path
> 
> TEMPLATE_DIRS = (
> os.path.join(os.path.basename(__file__), 'templates'),
> )
> 
> Is this the preferred/conventional way?

If it works for you, go for it.

Regards,
Malcolm



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



Re: RegexField and Admin interface

2007-10-10 Thread Tim Chase


> class Property(models.Model):
>   def isValidUKPostcode(self, field_data):
>   p = re.compile(r'^(GIR 
> 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HIK-Y][0-9](|
> [0-9]|[ABEHMNPRVWXY]))|[0-9][A-HJKSTUW]) [0-9][ABD-HJLNP-UW-Z]{2})$')
>   if not p.match(field_data['postcode']):
>   raise validators.ValidationError("You have to have a 
> space in the
> Postcode and all Capital letters.")



I'm gonna raise a personal pet-peeve here...if the computer can 
reformat/clean the incoming value, it should do so.  Unless the 
space has specific syntactic value, you should normalize 
everything to an uppercase format with no spaces, and /then/ 
validate it.  Or allow your validation to accept a sloppy value 
and then normalize it before you save.

Either way, there's very little more user-abusive than requiring 
them to enter such things (phone numbers, ID numbers, credit-card 
numbers, etc) in an exact format.  PARTICULARLY when spaces are 
involved.  I had one site require that a US phone# be formatted 
as "(999) 999-".  I had to type the bloody parens, the dash, 
AND THE [expletive] SPACE before the form validated.

On the other end of the spectrum, our VoIP system's web portal 
allows phone numbers to be entered in such a flexible number of 
ways that as long as I use numbers, it takes it.  With any 
mixture of dashes, periods, parens, spaces, or none of the above, 
it normalizes it into an internal format, and then displays it in 
a uniform fashion.



My understanding of the "right/Django" way to do this using 
newforms is to use the clean_*  methods to normalize this data 
before it gets shoved off to the DB, and that these clean_* 
methods would look something like


   clean_postcode_re = re.compile('[^0-9a-z]', re.I)
   def clean_postcode(self):
 return clean_postcode_re.sub('',self.postcode).upper()

However, this seems to do it on a (newform)Field-by-field basis. 
  I couldn't find much in the way of affixing such functionality 
to a Model field.  The best I've been able to determine, one uses 
a custom model field as decribed here:

http://www.djangoproject.com/documentation/model-api/#custom-field-types

with it's caveat about "read the source and if it breaks, you get 
to keep both pieces".  One would then override the 
get_db_prep_save() method to take the raw value and return the 
reformated/cleaned version (such as stripping out non-digit 
characters from a phone-number field).

Is there an analog function for formatting things coming *out* of 
the DB?  Using the phonenumber example, one might want to use the 
get_db_prep_save() to strip out anything non-numeric, and then 
store that form in the DB, but then when getting the field, 
display it as a formatted number.  E.g:

   "800.555.1212" from the user
->  "8005551212" in the DB
   ->  "(800)555-1212" coming back out from the DB

-tim





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



Validating Unique filenames and file types

2007-10-10 Thread jacoberg2

Hey,
I finally got a file upload working and now i want to be sure of what
people are uploading.
I am trying to write some custom validators, but have a little
difficulty about starting.
One thing that i think should be considered in the  file field, is the
option 'unique'.
when ever i set it equal to true, i get a programming error, that
says  have a context error.
I would think this was the unique at work but i know that there is
nothing in the database so it
shouldnt be throwing any error, since the file really is unique. So it
would be cool if that worked
sooner or later. The other major concern is the type of file, i want
to check and make sure that
each file uploaded is a .ini file for reading. So any suggestions
would be greatly appreciated.

Jacob Berg


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



Re: Help with Jinja Template

2007-10-10 Thread Brutus

Thank you Oliver for your answer.

 On 7 Okt., 22:19, olivier <[EMAIL PROTECTED]> wrote:
> Calling a template seems a little bit overkill.

Of course. But I just write some stuff to get my grip on Python again,
haven't used it for a long time. I grabbed the newest version of
"Learning Python" and started to play around. I wanted to use Jinja
because it's a lot like Django (which I'm looking forward to use as
soon as i finished the Python book) but can be used standalone without
any hassle (just easy_install and import).

On 7 Okt., 22:19, olivier <[EMAIL PROTECTED]> wrote:
> ... should the annotation tag be written if track.annotation is empty ?)

If the tag is set in the YAML file, it should be written. I guess it
makes no sense to write empty tags... but it does no harm either (or
does it?). So I just check for all allowed tags and if they are set,
they are written, wether or not they are empty.

On 7 Okt., 22:19, olivier <[EMAIL PROTECTED]> wrote:
> I don't like though the {%- if tag in playlist %} syntax which, I
> guess, invokes some jinja magic and translates to something  like
> getattr(playlist, tag, None) or hasattr(playlist, tag), but it's not
> that clear by reading the doc and your code which one is used (and
> which one you want : should the annotation tag be written if
> track.annotation is empty ?)

I do: print tmpl.render({"playlist": playlist})

Well playlist is a dictionary containing the tag-value pairs, parsed
from the corresponding YAML file. In the template i want to itterate
over a list of allowed tags and if the tag is present in the context,
print it. What would be the best way to do this with Djangos template
system?

I just scribbled together something in Jinja because i want to play
around and ended up with this (probably messy stuff):

{%- for tag in ['title', 'creator', 'annotation', 'info', 'image',
'location', 'identifier', 'date', 'license', 'attribution'] %}
{%- if tag in playlist %}
<{{ tag }}>{{ playlist[tag] }}
{%- endif %}
{%- endfor %}

Because i found no way, how i could access the variables from the
template (well locals() shows them, dir() too, but i could'nt access
them) i wrapped them in a second dict with "playlist": playlist, so i
could do "if tag in playlist" and "playlist[tag]".





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



Re: Users vs Sites

2007-10-10 Thread MarcoX

thank you, Chris.

The solution of my problem is therefore very difficult to implement.
The branch of which you speak to me is still in testing. And however
it seems that it cannot resolve my problem completely.
Therefore not are others (simpler) solutions?

MarcoX

On 10 Ott, 18:31, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> You'd need row-level permission for that, and that's outside of the
> admin's intended philosophy. Though, there's such a branch being
> developed, and I can recall seeing somewhere a django app for that
> purpose. Just google it and it should pop up.
>
> Also, since row-level permission is not built into the admin in any way,
> you'd find yourself doing custom admin views, which is neither bad nor
> hard, but you might feel overwhelmed by the task, since it's a bit hard
> to grasp at first.
>
> ~Chris
>
> El mi?, 10-10-2007 a las 07:51 -0700, MarcoX escribi?:
>
> > Hi to all,
> > I have a problem on the configuration of the users in django.
> > In my plan I have 4 sites. I would want that in the admin view I can
> > specify for some users the possibility of being able to make
> > determined actions for determined sites.
> > For example, the user X can write the object Y only for the site Z.
>
> > Thank you


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



django_root or application_root ?

2007-10-10 Thread Hugh Bien
Hi,
I'm a Django newbie (just finished the tutorial on djangobook.com).  I'm
about to try building a blog with Django to learn some more and I was
wondering if there's some sort of DJANGO_ROOT that specifies the path to the
root of your project.

The djangobook tipped us to use Python's __file__ for setting the
TEMPLATE_DIRS:

import os.path

TEMPLATE_DIRS = (
os.path.join(os.path.basename(__file__), 'templates'),
)

Is this the preferred/conventional way?

Thanks!
- Hugh

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



Re: deseb installation in ubuntu

2007-10-10 Thread Xan



On Oct 9, 9:50 pm, Derek Anderson <[EMAIL PROTECTED]> wrote:
> well, is 7.04, site-packages is here:
> /usr/lib/python2.5/site-packages/
>

Well, not I put deseb directory here

> but your problem obviously precedes this.  did you muck with you
> manage.py file?

No, I did not touch manage.py. manage.py is:

#!/usr/bin/python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the
directory containing %r. It appears you've customized things.\nYou'll
have to run django-admin.py, passing it your settings module.\n(If the
file settings.py does indeed exist, it's causing an ImportError
somehow.)\n" % __file__)
sys.exit(1)

if __name__ == "__main__":
execute_manager(settings)

My settings.py is:

# Django settings for analitzador project.

# Us de deseb
import deseb
# S'acaba l'us de deseb

DEBUG = True
TEMPLATE_DEBUG = DEBUG
[...]

So, what fails?
I don't know!

Thanks,
Xan.

>
> or, when you say "import setting.py", you're not literally typing
> "import setting.py" are you?  make sure you're not including the
> extension in your manage.py, or anywhere else you're calling it.  (same
> goes for DJANGO_SETTINGS_MODULE)
>
> derek
>
>
>
> Xan wrote:
> > Hi,
>
> > * I have installed django 0.96 in ubuntu 7.04 [http://
> > packages.ubuntu.com/gutsy/python/python-django] (when I run dpkg -l I
> > get version "0.96-1~feisty1")
>
> > * I want to install deseb and I follow installation instructions
> > [http://code.google.com/p/deseb/wiki/Installation]
>
> > * The problem is that, after I do import als setting.py, I get the
> > following error:
>
> > python manage.py runserver
> > Error: Can't find the file 'settings.py' in the directory containing
> > 'manage.py'. It appears you've customized things.
> > You'll have to run django-admin.py, passing it your settings module.
> > (If the file settings.py does indeed exist, it's causing an
> > ImportError somehow.)
>
> > * I think that the problem is that I don't know where is
> > "/site-packages".  I created the directory  "site-
> > packages" in /usr/share/python/ and I put "deseb" as a subdirectory
>
> > Where is the error?
>
> > Thanks in advance,
> > Xan.
>
> --
>   looking to buy or sell anything?
>
>  try:http://allurstuff.com
>
>   it's a classified ads service that
>   shows on a map where the seller is
>   (think craigslist + google maps)
>
>   plus it's 100% free :)


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



problem with ChangeManipulator

2007-10-10 Thread Gio

I get this error:
unsupported operand type(s) for +: 'NoneType' and 'int'

referred to this snippet of code, debug informations are pointing to
the line where the ChangeManipulator is:
-
articolo = Articolo.objects.get(codice = c)
try:
manipulator = Articolo.ChangeManipulator(articolo.id)
except Articolo.DoesNotExist:
return HttpResponse('{success:false}')
-


Articolo, as defined in models.py
-
class Articolo(models.Model):
codice= models.CharField(maxlength=255, unique=True)
descrizione   = models.CharField(maxlength=255)
immagine  = models.ImageField(upload_to='uploads')
brand = models.ForeignKey(Brand)
stagione  = models.ForeignKey(Stagione)
prefisso  = models.ForeignKey(Prefisso)
colore= models.ForeignKey(Colore)
costo_imposto = models.FloatField(null=True)
maggiorazione = models.IntegerField()

def __str__(self):
return self.codice

class Meta:
verbose_name_plural = 'articoli'
ordering = ['codice']

class Admin:
pass

def save(self):
size = 300, 100
try:
im = Image.open(self.get_immagine_filename())
im.thumbnail(size)
im.save(self.get_immagine_filename(), im.format)
except:
self.immagine = 'none.jpg'
super(Articolo, self).save()

def delete(self):
if self.immagine <> 'none.jpg':
remove(self.get_immagine_filename())
super(Articolo, self).delete()
-

Any idea?
tnx


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



Re: pattern question

2007-10-10 Thread Rob Slotboom

Hi Malcolm,

SMART

Thanks
Rob


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



Re: Users vs Sites

2007-10-10 Thread Chris Hoeppner

You'd need row-level permission for that, and that's outside of the
admin's intended philosophy. Though, there's such a branch being
developed, and I can recall seeing somewhere a django app for that
purpose. Just google it and it should pop up.

Also, since row-level permission is not built into the admin in any way,
you'd find yourself doing custom admin views, which is neither bad nor
hard, but you might feel overwhelmed by the task, since it's a bit hard
to grasp at first.

~Chris

El mi�, 10-10-2007 a las 07:51 -0700, MarcoX escribi�:
> Hi to all,
> I have a problem on the configuration of the users in django.
> In my plan I have 4 sites. I would want that in the admin view I can
> specify for some users the possibility of being able to make
> determined actions for determined sites.
> For example, the user X can write the object Y only for the site Z.
> 
> Thank you
> 
> 
> > 


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



pattern question

2007-10-10 Thread Rob Slotboom

I want to create a pattern to get one or more occurences of, let's
say, slug.

/bla/
/bla/blob/
/bla/blob/blebber/
/bla/blob/blebber/and_a_lot_more
etc.

I get it working for up to two slugs with

('^([^/]+)/([^/]+)/$', 'page'),


def page(request, *slugs):
   slug_list = []
   for slug in slugs:
  slug_list.append(slug)
   return render_to_response('platte_pagina.html', {
  'slug_list' : slug_list,
   }, context_instance=RequestContext(request))


I studied some regex tutorials but I still can't figure out how to fix
repetition in the pattern.


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



Re: Django-tagging weirdness (noob question)

2007-10-10 Thread James Bennett

On 10/9/07, coffeeho <[EMAIL PROTECTED]> wrote:
> As a CharField, there's no problem. When I changed it to get the
> sexier ManyToManyField it got weird. The tags appear and transfer
> between fields (in admin view) and save in the link like they should,
> but they do not appear in the tagging "tagged items" table - only in
> the link (in admin view). I humbly beg for assistance.  (yes, I'm a
> noob... I know)

This won't work; because of database-level requirements, many-to-many
fields aren't updated by the admin (or any sort of
automatically-generated form) until *after* the object has completely
saved, which means that when save() is running the many-to-many
relation isn't yet updated.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: Totally Stumped - Authenticate and Login a user

2007-10-10 Thread JimR

Karen,
Thanks for the reply.  I looked at the traceback, but it didn't help a
whole lot.  It pointed me in the direction of the login function in
django.contrib.auth.views.  I ended up taking the authentication and
login snippet from above and moving it to another view that I created,
calling that view from the member registration view.  That fixed the
problem (although I don't know why!).

Here's what I did:

members.py:
...
u = User.objects.create_user(request.POST['user_name'],
  request.POST['email'],
  request.POST['password'])

   user_login_validate(request)
   return HttpResponseRedirect('/loginsuccess/')
...


views.py:
...
def user_login_validate(request):
username = request.POST['user_name']
password = request.POST['password']
user = authenticate(username=username, password=password)

if user is not None:
if user.is_active:
login(request, user)
else:
return render_to_response('login.html')

Also curiously, the redirect would not work from within
user_login_validate, so I moved it back to the original view and it
worked.  This Django stuff sure can be maddening at times!

On Oct 10, 10:16 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On 10/10/07, JimR <[EMAIL PROTECTED]> wrote:
>
>
>
> > Any Suggestions?
>
> The traceback from the error you are seeing might help people figure out
> where the problem lies.
>
> Karen


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



Users vs Sites

2007-10-10 Thread MarcoX

Hi to all,
I have a problem on the configuration of the users in django.
In my plan I have 4 sites. I would want that in the admin view I can
specify for some users the possibility of being able to make
determined actions for determined sites.
For example, the user X can write the object Y only for the site Z.

Thank you


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



Re: Validation of dynamically generated forms

2007-10-10 Thread FrankW

If you look at f.errors or k.errors, you'll see:
{'cart_item_b': [u'This field is required.'], 'cart_item_a': [u'This
field is required.']}

The reason for this is that the forms data looks like:
{'a': '1', 'b': '2'}
or
{'a': 1, 'b': 2}

The tricks that you're playing with changing the name of the fields
'cart_item_' + str(key) is messing you up.

Try this:
>>> class CartForm(forms.Form):
... def __init__(self, a):
... super(CartForm, self).__init__(a)
... for key in a.keys():
... self.fields[str(key)] =
forms.IntegerField(required  = True)
... self.fields[str(key)].bf =
forms.forms.BoundField(self, self.fields[str(key)], str(key))
... self.fields[str(key)].bf._data =
int(a[key])
... return
...
>>> j = CartForm({'a':'1','b':'2'})
>>> j.is_valid()
True

On Oct 8, 6:19 pm, pinco <[EMAIL PROTECTED]> wrote:
> Frank,
> thak you for your help.
>
> I worked on the form model using bound field, and now the forms is
> bound.
>
> class CartForm(forms.Form):
> def __init__(self, a):
> super(CartForm, self).__init__(a)
> for key in a.keys():
> self.fields['cart_item_' + str(key)] = 
> forms.IntegerField(required
> = True)
> self.fields['cart_item_' + str(key)].bf = 
> BoundField(self,
> self.fields['cart_item_' + str(key)], 'cart_item_' + str(key))
> self.fields['cart_item_' + str(key)].bf._data = 
> int(a[key])
> return
>
> However, I still have some problems.
> 1- I don't understand how the form validates:
>
> >>> f = CartForm({'a':'1', 'b':'2'})
> >>> f.is_bound
> True
> >>> f.is_valid()
> False
> >>> k = CartForm({'a':1, 'b':2})
> >>> k.is_bound
> True
> >>> k.is_valid()
>
> False
>
> I supposed the first one validation to be false since the field widget
> is an IntegerField.
>
> 2 - I'm not able to figure out to read the form after it has been
> posted.
>
> Can you help me?
>
> Many thanks
>
> On 7 Ott, 02:45, FrankW <[EMAIL PROTECTED]> wrote:
>
> > In your example,
> > self.fields[str(key)]=forms.CharField(initial=c[key])
> > isn't doing what you expect.
>
> > You are setting the initial attribute of a field, not creating
> > a BoundField. See django/newforms/forms.py, and look at the
> > comments for BaseForm and Form and the code for
> > BoundField.
>
> > On Oct 6, 8:31 am, pinco <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I'm trying to figure out how to build a form to display x fields,
> > > where x is determined at runtime (e.g. a form to update the quantities
> > > of all the items in a shopping cart).
>
> > > My model is:
>
> > > class CartForm(forms.Form):
>
> > > def __init__(self, c, *args, **kwargs):
> > > super(CartForm, self).__init__(*args, **kwargs)
> > >   # c is a dictionary containing cart items
> > > for key in c.keys():
> > > 
> > > self.fields[str(key)]=forms.CharField(initial=c[key])
> > > return
>
> > > My view is:
>
> > > def show_cart(request):
> > > cart = Cart.objects.get(pk=request.session.get('cart_id', None))
> > > cart_items = cart.cartitem_set.all() #Just to avoid two hits for 
> > > the
> > > same info
> > > form = CartForm(c=create_cart_dictionary(cart_items))
> > > return render_to_response('show_cart3.html', {'cart': cart,
> > > 'num_items': cart.no_items, 'cart_items': cart_items, 'form':form})
>
> > > def update_quantity(request):
>
> > > if request.method == 'POST':
> > > cart = Cart.objects.get(pk=request.session.get('cart_id', 
> > > None))
> > > form = CartForm(request.POST)
> > > #old_quantity =item.quantity
> > > if form.is_valid():
> > > for item in cart.cartitem_set.all():
> > > itemid = item.id
> > > new_quantity = 
> > > form.cleaned_data['cart_item' + str(itemid)]
> > > ... save the new quantities
>
> > > Create_cart_dictionary is a function that create a dictionary like
> > > {'item_id': item}.
>
> > > show_cart() works as expected, since it displays a dynamically
> > > generated form with fields named by the item.id displayed.
>
> > > update_quantity() do not works, since form.is_valid() is always false:
>
> > > >>> form = CartForm({'a': 10, 'b':20})
> > > >>> form
>
> > > >>> form.is_valid()
> > > False
> > > >>> form = CartForm({'a': '10', 'b':'20'})
> > > >>> form.is_valid()
> > > False
> > > >>> print form
>
> > > A: > > name="a" value="10" id="id_a" />
> > > B: > > name="b" value="20" id="id_b" / form.is_bound
>
> > > False
>
> > > The problems seems to be that the form is not bound.
> > > What I'm doing wrong? How to bound and validate the dynamically
> > > generated form?



Re: TypeError in Django Admi with edit_inline

2007-10-10 Thread mrsynock


> In fact this particular problem seems to be Gone on the newforms-admin
> branch, so that's another alternative for a workaround, if you (mrsynock)
> are  feeling adventurous  enough to switch to a branch.

Sadly I'm not  very adventurous :-)
I'll just remove unique.

Thank you for answers



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



Re: form_for_model should return TextareaWidget

2007-10-10 Thread Malcolm Tredinnick

On Wed, 2007-10-10 at 09:09 -0400, Malcolm Tredinnick wrote:
> On Wed, 2007-10-10 at 14:51 +0200, Thomas Guettler wrote:
> > Hi,
> > 
> > How can I get a TextareaWidget with form_for_model()?
> > 
> > I have a solution, but it is too much code. You need to create
> > an own DB-Field.
> 
> Right there, as you realise, you're looking the right place. 

Wow, that was a bad sentence. Poor English and incorrect meaning. :-(

I meant to say: "... you know you're looking in the *wrong* place."

/me slinks off to get some coffee.

Malcolm



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



Re: form_for_model should return TextareaWidget

2007-10-10 Thread Malcolm Tredinnick

On Wed, 2007-10-10 at 14:51 +0200, Thomas Guettler wrote:
> Hi,
> 
> How can I get a TextareaWidget with form_for_model()?
> 
> I have a solution, but it is too much code. You need to create
> an own DB-Field.

Right there, as you realise, you're looking the right place. You're
trying to create a form, so should never have to look further than form
fields and widgets.

What you want to do here is, given the particular field of the model,
replace its default form field with you own version that uses the
Textarea widget. This means using the formfield_callback parameter to
form_for_model(). That is given each model field in turn and should
return a form field instance. You need to be able to handle *every*
field in your model, so start with something that operates like the
default (see newforms/models.py) and extend it.

Basically, the form field you want to return is probably something like

forms.CharField(, widget=Textarea(rows=4, cols=40))

Regards,
Malcolm



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



Re: Django-tagging weirdness (noob question)

2007-10-10 Thread coffeeho

I'm using version 0.96.

On Oct 9, 8:55 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 10-Oct-07, at 7:15 AM, coffeeho wrote:
>
> > I'm trying to implement the django-tagging app.  My "links" app has a
> > tags field.
>
> could you clarify which version of django you are using
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/


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



Re: Integrate xmpppy with django

2007-10-10 Thread Malcolm Tredinnick

On Wed, 2007-10-10 at 02:56 -0700, est wrote:
> Thank you Christoph.
> 
> Yes I have tried a independent daemon, but that's a bit complicated
> for a small site. Is there a simipler way?

There is no guarantee that any Django process is going to be long
running or only called once -- there will be repeated imports and
restarts over the lifetime of the server. Both of these things mean that
trying to control a single long-running process from something that runs
as a response to Django imports or a request is going to have design
problems.

So you are trying to solve your problem in a way that is going to have a
lot of problems in the future. Django handles the request/response
driven side of your website or application. Long running processes,
scheduled processes, offline processes -- all of these things should be
managed separately, often via a daemon as suggested earlier. Trying to
force control into Django really is going to be more pain that it's
worth.

Regards,
Malcolm



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



Re: Serving static media on the development server

2007-10-10 Thread Nikola Stjelja
Thank you Tylan your solution worked.

Here is the correct url pattern
(r'^assets/(.*)$', 'django.views.static.serve', {'document_root':
'c:/python_programi/cms/assets'}),

I made a mistake in the regular expression, plus  I've changed the directory
name from media to assets.

Blame it on my poor knowledge of regular expressions.

On 10/10/07, Taylan Pince <[EMAIL PROTECTED]> wrote:
>
>
>
> It seems like you have two issues here:
>
> > > Page not found:
> > > C:\Python25\lib\site-packages\django/contrib/admin/media\stil.css
>
> First, check your settings.py to make sure your admin media folder
> (ADMIN_MEDIA_PREFIX) and your application's media folder don't have
> the same name.
>
> > this is the code i used:
> >
> > urlpatterns = patterns('',
> > # Example:
> > # (r'^cms/', include(' cms.foo.urls')),
> >
> > # Uncomment this for admin:
> >  (r'^admin/', include('django.contrib.admin.urls')),
> >  (r'^$', 'cms.editor.views.index'),
> >  (r'^(?P\d+)/$', ' cms.editor.views.stranice'),
> >  (r'^mail/$', 'cms.editor.views.mail'),
> >  (r'^media/(?P.*)$', 'django.views.static.serve',
> > {'document_root': 'c:/python_programi/cms/media/'}),
> > )
>
> Let's say you use "media" for ADMIN_MEDIA_PREFIX, and "assets" for
> your application's static files, the code to include in your urls.py is:
>
> (r'^assets/(.*)$', 'django.views.static.serve', {'document_root':
> 'assets/'}),
>
> Note that the document_root property is relative to your django
> applications root, not your system root.
>
> Hope this helps.
>
> Taylan
>
>
> >
>


-- 
Please visit this site and play my RPG!

http://www.1km1kt.net/rpg/Marinci.php

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



Re: Flatpages

2007-10-10 Thread AniNair


Thank alot for the reply. I tried that, then django won't return 404
error and tinymce won't work too. django returns
[10/Oct/2007 18:04:44] "GET /admin/jsi18n/ HTTP/1.1" 200 803
Thats all. No ref to /media/js/tiny_mce/tiny_mce.js

Any ideas?


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



form_for_model should return TextareaWidget

2007-10-10 Thread Thomas Guettler

Hi,

How can I get a TextareaWidget with form_for_model()?

I have a solution, but it is too much code. You need to create
an own DB-Field.

Is there a better solution?

models.py:
text=dbfields.TextareaField(max_length=128, rows=4, cols=40, 
verbose_name="Text", blank=True)

dbfields.py:
class TextareaField(models.CharField):
rows=10
cols=40
def __init__(self, *args, **kwargs):
self.rows=kwargs.pop("rows", self.rows)
self.cols=kwargs.pop("cols", self.cols)
super(self.__class__, self).__init__(*args, **kwargs)

def formfield(self, **kwargs):
# from db/models/__init__.py/Field.formfield()
from django.utils.text import capfirst
defaults = {'required': not self.blank, 'label': 
capfirst(self.verbose_name), 'help_text': self.help_text}
defaults = {'max_length': self.max_length}
defaults = {'rows': self.rows, 'cols': self.cols}
defaults.update(kwargs)
return formfields.TextareaFormField(**defaults)

formfields.py:
class TextareaFormField(forms.CharField):
def __init__(self, *args, **kwargs):
kwargs["widget"]=forms.widgets.Textarea({"cols": kwargs.pop("cols"), 
"rows": kwargs.pop("rows")})
return super(self.__class__, self).__init__(*args, **kwargs)

 Thomas

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



Re: flatpages and 404s

2007-10-10 Thread [EMAIL PROTECTED]

Ah ha. never mind, i found the problem.

I have a context processor that is run on every page to determine if a
new flatpage needs to be created (we are using them in a help system).
Unfortunately, this was being run on the flatpag itself and couldn't
resolve the url as a view and so threw a 404.

Note to self, 'try' is your friend...

Loki


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



Re: Flatpages

2007-10-10 Thread peschler

Try to prepend a slash to your src attribute:


Should be
/media/js/tiny_mce/tiny_mce.js
not
media/js/tiny_mce/tiny_mce.js

hope that helps
pe

On 10 Okt., 13:50, AniNair <[EMAIL PROTECTED]> wrote:
> Hi,
> I am trying to add tinymce to flatpages in admin using
> change_from.html in admin/flatpages/flatpage.
> this is change_form.html
> {% extends "admin_copies/change_form.html" %}
> {% block extrahead %}{{ block.super }}
> 

Re: Serving static media on the development server

2007-10-10 Thread Taylan Pince


It seems like you have two issues here:

> > Page not found:
> > C:\Python25\lib\site-packages\django/contrib/admin/media\stil.css

First, check your settings.py to make sure your admin media folder  
(ADMIN_MEDIA_PREFIX) and your application's media folder don't have  
the same name.

> this is the code i used:
>
> urlpatterns = patterns('',
> # Example:
> # (r'^cms/', include(' cms.foo.urls')),
>
> # Uncomment this for admin:
>  (r'^admin/', include('django.contrib.admin.urls')),
>  (r'^$', 'cms.editor.views.index'),
>  (r'^(?P\d+)/$', ' cms.editor.views.stranice'),
>  (r'^mail/$', 'cms.editor.views.mail'),
>  (r'^media/(?P.*)$', 'django.views.static.serve',  
> {'document_root': 'c:/python_programi/cms/media/'}),
> )

Let's say you use "media" for ADMIN_MEDIA_PREFIX, and "assets" for  
your application's static files, the code to include in your urls.py is:

(r'^assets/(.*)$', 'django.views.static.serve', {'document_root':  
'assets/'}),

Note that the document_root property is relative to your django  
applications root, not your system root.

Hope this helps.

Taylan


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



weird bug encountered during testing

2007-10-10 Thread Ronald

Hi everyone,

i can use some help here.
Im doing some unittesting for my app (yep i finally decided to start
testing my code) and encountered a strange "bug".

basically, I follow the testing documentation and try to do a get
request and then test the response context using something similar to
this

self.assertEqual(len(response.context['customers']), 5)

the weird thing is that the above code works for a template that DOES
NOT extends from another template.

when my template extends from another template

extends 'base.html'

then the code

self.assertEqual(len(response.context['customers']), 5)

will not work. It will give ValueError exception complaining that list
indices must be integer.

closer investigation reveals that the response.context dictionary is
somehow transformed into a list of 2 identical dictionary.
so instead I need to do something like this

self.assertEqual(len(response.context[0]['customers']), 5)

Im not sure what happened here. i could be doing some weird stuff, or
a bug in my code or if this is the actual implementation from Django
itself.

Thanks

Ronald


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



Calling all Django / Python Developer

2007-10-10 Thread Jon

Hey all you Django Guru's!

I'm a recruitment consultant working within the interactive sector in
London.  One of my clients has an excellent opportunity for an
experienced Django / Python Developer.
Suitable candidates ideally will have previously worked for a tier 1
type consumer internet company.  Candidates must be experienced in
Open Source, Django, AJAX etc etc.
This individual should also be a talented front-end developer /
designer and familiar of working with: XHTML, XSLT, CSS and
Javascript.

This is a fantastic team for individuals to work in a dynamic
environment within a talented team.  Excellent rewards are on offer to
suitable individuals.

Anyone interested should get in touch with me either by phone or e
mail (0207 729 4771 / [EMAIL PROTECTED])


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



Re: Plz, I am just new to Python...

2007-10-10 Thread AniNair

unzip the trunk file downloaded to libs/site-packages/   and try
import django from idle. If it returns no errors, that's it == django
is installed.


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



Re: Totally Stumped - Authenticate and Login a user

2007-10-10 Thread JimR

Any Suggestions?

Thanks,
Jim


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



Re: Plz, I am just new to Python...

2007-10-10 Thread Chris Hoeppner

you'd also need a python interpreter, but since you talked about
site-packages, I guess that's done already ;) You might also want to
setup a database.

El mi�, 10-10-2007 a las 00:43 -0700, lispingng escribi�:
> actually django templates look more like php smarty templates.
> i also am from php and am new to django.
> i don't think installing django on windows is such a big deal.
> i just unzipped the tar and copied it to the python25\lib\site-packages
> \ folder
> and that was it (i think)
> 
> On Oct 4, 9:52 pm, John <[EMAIL PROTECTED]> wrote:
> > On Oct 4, 11:09 am, Emperor of thought <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Please i am just new to python and i will like to know how i can go
> > > about in web development. I am migrating from PHP and phyton web
> > > environment does not look very familiar.
> >
> > Python has a number of frameworks and libraries for web 
> > development.Djangois but one of your choices. I think it's a good choice.
> >
> > Note thatDjangois a framework. So, that means instead of writing a
> > file for each web page, you'll be writing:
> >
> > * a file for your models (classes),
> > * a file for your views (functions),
> > * a file mapping urls to view functions (a list), and
> > * somefilesfor your templates (html with some extra bits thrown in).
> > The templatefileslook like phpfiles, but with {% ... %} blocks in
> > them instead of  blocks.
> >
> > Then the framework takes care of having the right view get called
> > (which then grabs one of the templates) and returns the page to the
> > user that requested it.
> >
> > > I trieddownloadingDjangoand installing it on my windows looks very
> > > difficult. Plsease can anyone help me on how to installDjangoand how
> > > to go about starting web development in Phyton?
> >
> > I'm not sure of the details for doing it on MS Windows. GNU/Linux is a
> > good environment for development of all sorts. I recommend upgrading
> > to Ubuntu.
> >
> > ---John
> 
> 
> > 


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



Flatpages

2007-10-10 Thread AniNair

Hi,
I am trying to add tinymce to flatpages in admin using
change_from.html in admin/flatpages/flatpage.
this is change_form.html
{% extends "admin_copies/change_form.html" %}
{% block extrahead %}{{ block.super }}


{% endblock %}

 Django is returning error that
[10/Oct/2007 17:09:40] "GET /admin/flatpages/flatpage/1/media/js/
tiny_mce/tiny_m
ce.js HTTP/1.1" 404 3644
[10/Oct/2007 17:09:40] "GET /admin/flatpages/flatpage/1/media/js/
tiny_mce/textar
eas.js HTTP/1.1" 404 3647
The file tiny_mce.js and textareas.js are in location
media.js.tiny_mce   . Can anyone tell me why is django returning 404
error? Please help.


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



Re: Integrate xmpppy with django

2007-10-10 Thread est

Many thanks for you suggestion. But you see I am currently having
problem with integration, not XMPP.

I'll consider switch to pyxmpp when the integration is done.

On Oct 10, 5:59 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> If you insist on integratin Jabber/XMPP into your site, I'd suggest
> *NOT USING* xmpppy. This library is flawed in many ways and do not
> conform many standards published in XMPP RFC. Use pyxmpp (http://
> pyxmpp.jajcus.net/) instead. It is written by a member of Jabber board
> and is more compatible with official XMPP standard.
>
> On 10 Paź, 10:43, est <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi, all
>
> > I am writing a GoogleTalk bot for my django site, but I don't know
> > were to initiate a xmpppy Client object in Django. Should I put it in
> > my project's __init__.py ? I need the bot to be always online so where
> > can I write a GLOBAL, long survival object in Django? How can I make
> > xmpppy Client login only ONCE where django project starts?(I found
> > that __init__.py will be called several times during Django starting.)
>
> > Any info is appreciated, thank you all!- Hide quoted text -
>
> - Show quoted text -


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



NameError when following tutorial in djangobook.com/en/beta/chapter03/

2007-10-10 Thread drdukk

I'm new to python and django and I'm trying to follow the tutorial on
djangobook.com, but when i get to the step (chapter 3) where the first
piece of code should be executed (current_time) i get a NameError
telling me "name 'current_datetime' is not defined"

I'm running django 0.96 on python 2.5.1 on windows 2003.

I get the "It worked" screen fine.

I think I have all paths as they should be, my project is in
pythonpath, I can import my project, the url is mapped.

Any tips would be greatly appreciated, I can't seem to find anything
about it elsewhere (as it's apparently a very generic error).

Kind regards,

Drdukk


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



see indian nudu viedo and pics

2007-10-10 Thread harina

see indian nudu viedo and pics

http://chromoo.blogspot.com/


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



NameError when following tutorial in djangobook.com/en/beta/chapter03/

2007-10-10 Thread drdukk

I'm new to python and django and I'm trying to follow the tutorial on
djangobook.com, but when i get to the step (chapter 3) where the first
piece of code should be executed (current_time) i get a NameError
telling me "name 'current_datetime' is not defined"

I'm running django 0.96 on python 2.5.1 on windows 2003.

I get the "It worked" screen fine.

I think I have all paths as they should be, my project is in
pythonpath, I can import my project, the url is mapped.

Any tips would be greatly appreciated, I can't seem to find anything
about it elsewhere (as it's apparently a very generic error).

Kind regards,

Drdukk


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



NameError when following tutorial in djangobook.com/en/beta/chapter03/

2007-10-10 Thread drdukk

I'm new to python and django and I'm trying to follow the tutorial on
djangobook.com, but when i get to the step (chapter 3) where the first
piece of code should be executed (current_time) i get a NameError
telling me "name 'current_datetime' is not defined"

I'm running django 0.96 on python 2.5.1 on windows 2003.

I get the "It worked" screen fine.

I think I have all paths as they should be, my project is in
pythonpath, I can import my project, the url is mapped.

Any tips would be greatly appreciated, I can't seem to find anything
about it elsewhere (as it's apparently a very generic error).

Kind regards,

Drdukk


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



Re: RegexField and Admin interface

2007-10-10 Thread Nader

Thank you for your reaction at the first place! What I have understand
of it is that I have to define some class, in your case:
  class Property(models.Model):

and in this class a method (function) in which we can define our
regular expression :
 def isValidReferenceID0(self, field_data):
   p = re.compile(r'(^[\w-]*$)')
   if not (p.match(field_data['referenceID0'])):
   raise validators.ValidationError("The Reference
you entered is not Valid.")

After that we can use this function as an option in out model
attribute where we need that:

referenceID0 = models.CharField(maxlength=10,
validator_list=[isValidReferenceID0],
   unique=True,
verbose_name="Reference ID")

Would you like to tell me whether I have got it?

On Oct 10, 12:22 pm, oliver <[EMAIL PROTECTED]> wrote:
> Regex is done via a custom validator. works pretty simple. here is an
> example how i use to check if the entered data is a correct UK
> postcode (zip code)
>
> from django.core import validators
>
> you might need to import some thing else as well (import datetime,
> random, sha, re, os, Image, urllib thats all i use in this app)
>
> class Property(models.Model):
> def isValidUKPostcode(self, field_data):
> p = re.compile(r'^(GIR 
> 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HIK-Y][0-9](|
> [0-9]|[ABEHMNPRVWXY]))|[0-9][A-HJKSTUW]) [0-9][ABD-HJLNP-UW-Z]{2})$')
> if not p.match(field_data['postcode']):
> raise validators.ValidationError("You have to have a 
> space in the
> Postcode and all Capital letters.")
>
> def isValidReferenceID0(self, field_data):
> p = re.compile(r'(^[\w-]*$)')
> if not (p.match(field_data['referenceID0'])):
> raise validators.ValidationError("The Reference you 
> entered is not
> Valid.")
>
> These are 2 regex i use in my model to check if the post code is
> correct and if the refereceID0 field is correct.
>
> referenceID0 = models.CharField(maxlength=10,
> validator_list=[isValidReferenceID0], unique=True,
> verbose_name="Reference ID")
> postcode = models.CharField(maxlength=10,
> validator_list=[isValidUKPostcode], verbose_name="Post Code",
> help_text="Has to be in Capital letters and contain a space.")
>
> these are the fields in the model.
> I am not very good in regex and found this tool quite helpful
> regexCreator_v0_85 (google for it) a java regex builder.
>
> works pretty well in the standard admin.
> hope it helps.
>
> o
>
> On Oct 10, 7:40 am, Nader <[EMAIL PROTECTED]> wrote:
>
> > Hello
>
> > I use Django  0.96 and in one of model's field I have to define a
> > 'path' entry in which een Unix path (/usr/people/...)  can be given as
> > an input with validation naturally.
> > I would like to use Admin interface and have not found any Built-in
> > Filed of "RegexField" class to use it.
>
> > cla  ss MyModel(...):
> >password = modles.RegexField()
>
> > I can't do it because we don't have any "RegexField" attribute in
> > "Admin" class. I have
> > been looking for information about this problem and have not found any
> > solution.
> > Could you tell me how I can solve this problem?
>
> > Regards,
> > Nader


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



Re: RegexField and Admin interface

2007-10-10 Thread oliver

Regex is done via a custom validator. works pretty simple. here is an
example how i use to check if the entered data is a correct UK
postcode (zip code)

from django.core import validators

you might need to import some thing else as well (import datetime,
random, sha, re, os, Image, urllib thats all i use in this app)

class Property(models.Model):
def isValidUKPostcode(self, field_data):
p = re.compile(r'^(GIR 
0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HIK-Y][0-9](|
[0-9]|[ABEHMNPRVWXY]))|[0-9][A-HJKSTUW]) [0-9][ABD-HJLNP-UW-Z]{2})$')
if not p.match(field_data['postcode']):
raise validators.ValidationError("You have to have a 
space in the
Postcode and all Capital letters.")

def isValidReferenceID0(self, field_data):
p = re.compile(r'(^[\w-]*$)')
if not (p.match(field_data['referenceID0'])):
raise validators.ValidationError("The Reference you 
entered is not
Valid.")

These are 2 regex i use in my model to check if the post code is
correct and if the refereceID0 field is correct.

referenceID0 = models.CharField(maxlength=10,
validator_list=[isValidReferenceID0], unique=True,
verbose_name="Reference ID")
postcode = models.CharField(maxlength=10,
validator_list=[isValidUKPostcode], verbose_name="Post Code",
help_text="Has to be in Capital letters and contain a space.")

these are the fields in the model.
I am not very good in regex and found this tool quite helpful
regexCreator_v0_85 (google for it) a java regex builder.

works pretty well in the standard admin.
hope it helps.

o

On Oct 10, 7:40 am, Nader <[EMAIL PROTECTED]> wrote:
> Hello
>
> I use Django  0.96 and in one of model's field I have to define a
> 'path' entry in which een Unix path (/usr/people/...)  can be given as
> an input with validation naturally.
> I would like to use Admin interface and have not found any Built-in
> Filed of "RegexField" class to use it.
>
> cla  ss MyModel(...):
>password = modles.RegexField()
>
> I can't do it because we don't have any "RegexField" attribute in
> "Admin" class. I have
> been looking for information about this problem and have not found any
> solution.
> Could you tell me how I can solve this problem?
>
> Regards,
> Nader


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



flatpages and 404s

2007-10-10 Thread [EMAIL PROTECTED]

Hi all,

I have (as far as I am aware) installed the flatpages app correctly,
set up the MIDDLEWARE_CLASSES correctly, got a flatpages/default.html
template on my template path, got the leading and trailing slashes on
my flatpages (created via the admin interface) adn my SITE_ID is set
to the only site I have and i still get 404s when I try to view my
flatpages.

Currently I am using the development server, and I am using django
version  0.97-pre-SVN-6410.

I have tried appending the following to my urlconf, but it just come
with 'no flatpage matching query' :
  (r'^(.*)/$','django.contrib.flatpages.views.flatpage'),

My site is still currently set to 'example.com', although as i am
using the development the site is based off of localhost:8000 (just
for fun, I added this as a site, reset the SITE_ID in the settings.py
and made sure all of the flatpages had this as a site, made no
difference...)

So, any help would be greatly appreciated :)

Thanks

Loki


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



Re: Nested Inlines, dynamic forms, templates and all sorts of problems.

2007-10-10 Thread [EMAIL PROTECTED]

Hi yml,

On 9 Oct, 20:11, yml <[EMAIL PROTECTED]> wrote:
> In a very similar situation I have chosen option 2 for the following
> reasons:
>  * the code was much more simple, at least simpler to maintain for me
>  * Very hight control on the layout of the form.

Thanks for the reply. I think I'll do likewise; I realised that I can
still use newforms fragments for validation.

Regards,

Felix


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



Re: Integrate xmpppy with django

2007-10-10 Thread Jarek Zgoda

If you insist on integratin Jabber/XMPP into your site, I'd suggest
*NOT USING* xmpppy. This library is flawed in many ways and do not
conform many standards published in XMPP RFC. Use pyxmpp (http://
pyxmpp.jajcus.net/) instead. It is written by a member of Jabber board
and is more compatible with official XMPP standard.

On 10 Paź, 10:43, est <[EMAIL PROTECTED]> wrote:
> Hi, all
>
> I am writing a GoogleTalk bot for my django site, but I don't know
> were to initiate a xmpppy Client object in Django. Should I put it in
> my project's __init__.py ? I need the bot to be always online so where
> can I write a GLOBAL, long survival object in Django? How can I make
> xmpppy Client login only ONCE where django project starts?(I found
> that __init__.py will be called several times during Django starting.)
>
> Any info is appreciated, thank you 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Integrate xmpppy with django

2007-10-10 Thread est

Thank you Christoph.

Yes I have tried a independent daemon, but that's a bit complicated
for a small site. Is there a simipler way?

Simple is better.

On Oct 10, 5:23 pm, Christoph Rauch <[EMAIL PROTECTED]> wrote:
> est schrieb:> I am writing a GoogleTalk bot for my django site, but I don't 
> know
> > were to initiate a xmpppy Client object in Django. Should I put it in
> > my project's __init__.py ? I need the bot to be always online so where
> > can I write a GLOBAL, long survival object in Django? How can I make
>
> I wouldn't put it into __init__.py
>
> Not knowing xmpppy, this may or may not be simple:
>
> I would build a seperate daemon and send commands to it from inside
> your Django project. If you need the other way round, just import the
> required models in your xmpp client and put some logic there.
>
> That way you can just fire off commands to the daemon without having
> to worry about your connection. It's up to the daemon then.
>
> You can start the daemon completely separate of your webserver/Django
> project. Just make sure that Django can connect to the daemon, e.g.
> via unix domain sockets. Domain sockets are great, because you can
> restrict access to it with basic filesystem rights.
>
> Christoph


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



Re: Serving static media on the development server

2007-10-10 Thread Nikola Stjelja
On 10/10/07, cschand <[EMAIL PROTECTED]> wrote:
>
>
> You want add the style sheet still.css on admin control panel or
> application?


To an application. It be really helpfull if you have an idea what i've done
wrong. :)


On Oct 10, 11:21 am, "Nikola Stjelja" <[EMAIL PROTECTED]> wrote:
> > i'm a noob in Django, and I'm currently learning it. I tried to use
> style
> > sheets from an external css file but it didn't work. I copyed the code
> from
> > the djagno documentation page, I followed all the instructions but every
> > time I run a page insted of a nice green background i get this:
> > Page not found:
> > C:\Python25\lib\site-packages\django/contrib/admin/media\stil.css
> >
> > this is the code i used:
> >
> > urlpatterns = patterns('',
> > # Example:
> > # (r'^cms/', include('cms.foo.urls')),
> >
> > # Uncomment this for admin:
> >  (r'^admin/', include('django.contrib.admin.urls')),
> >  (r'^$', 'cms.editor.views.index'),
> >  (r'^(?P\d+)/$', 'cms.editor.views.stranice'),
> >  (r'^mail/$', 'cms.editor.views.mail'),
> >  (r'^media/(?P.*)$', 'django.views.static.serve',
> > {'document_root': 'c:/python_programi/cms/media/'}),
> > )
> >
> > and
> >
> > 
> >
> > TIA
> >
> > --
> > Please visit this site and play my RPG!
> >
> > http://www.1km1kt.net/rpg/Marinci.php
>
>
> >
>


-- 
Please visit this site and play my RPG!

http://www.1km1kt.net/rpg/Marinci.php

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



Re: Integrate xmpppy with django

2007-10-10 Thread Christoph Rauch

est schrieb:
> I am writing a GoogleTalk bot for my django site, but I don't know
> were to initiate a xmpppy Client object in Django. Should I put it in
> my project's __init__.py ? I need the bot to be always online so where
> can I write a GLOBAL, long survival object in Django? How can I make
I wouldn't put it into __init__.py

Not knowing xmpppy, this may or may not be simple:

I would build a seperate daemon and send commands to it from inside
your Django project. If you need the other way round, just import the
required models in your xmpp client and put some logic there.

That way you can just fire off commands to the daemon without having
to worry about your connection. It's up to the daemon then.

You can start the daemon completely separate of your webserver/Django
project. Just make sure that Django can connect to the daemon, e.g.
via unix domain sockets. Domain sockets are great, because you can
restrict access to it with basic filesystem rights.

Christoph


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



Re: Get model's attributes

2007-10-10 Thread xunSir

Now, it's OK!


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



Re: Serving static media on the development server

2007-10-10 Thread cschand

You want add the style sheet still.css on admin control panel or
application?

On Oct 10, 11:21 am, "Nikola Stjelja" <[EMAIL PROTECTED]> wrote:
> i'm a noob in Django, and I'm currently learning it. I tried to use style
> sheets from an external css file but it didn't work. I copyed the code from
> the djagno documentation page, I followed all the instructions but every
> time I run a page insted of a nice green background i get this:
> Page not found:
> C:\Python25\lib\site-packages\django/contrib/admin/media\stil.css
>
> this is the code i used:
>
> urlpatterns = patterns('',
> # Example:
> # (r'^cms/', include('cms.foo.urls')),
>
> # Uncomment this for admin:
>  (r'^admin/', include('django.contrib.admin.urls')),
>  (r'^$', 'cms.editor.views.index'),
>  (r'^(?P\d+)/$', 'cms.editor.views.stranice'),
>  (r'^mail/$', 'cms.editor.views.mail'),
>  (r'^media/(?P.*)$', 'django.views.static.serve',
> {'document_root': 'c:/python_programi/cms/media/'}),
> )
>
> and
>
> 
>
> TIA
>
> --
> Please visit this site and play my RPG!
>
> http://www.1km1kt.net/rpg/Marinci.php


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



Integrate xmpppy with django

2007-10-10 Thread est

Hi, all

I am writing a GoogleTalk bot for my django site, but I don't know
were to initiate a xmpppy Client object in Django. Should I put it in
my project's __init__.py ? I need the bot to be always online so where
can I write a GLOBAL, long survival object in Django? How can I make
xmpppy Client login only ONCE where django project starts?(I found
that __init__.py will be called several times during Django starting.)

Any info is appreciated, thank you 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Plz, I am just new to Python...

2007-10-10 Thread lispingng

actually django templates look more like php smarty templates.
i also am from php and am new to django.
i don't think installing django on windows is such a big deal.
i just unzipped the tar and copied it to the python25\lib\site-packages
\ folder
and that was it (i think)

On Oct 4, 9:52 pm, John <[EMAIL PROTECTED]> wrote:
> On Oct 4, 11:09 am, Emperor of thought <[EMAIL PROTECTED]>
> wrote:
>
> > Please i am just new to python and i will like to know how i can go
> > about in web development. I am migrating from PHP and phyton web
> > environment does not look very familiar.
>
> Python has a number of frameworks and libraries for web development.Djangois 
> but one of your choices. I think it's a good choice.
>
> Note thatDjangois a framework. So, that means instead of writing a
> file for each web page, you'll be writing:
>
> * a file for your models (classes),
> * a file for your views (functions),
> * a file mapping urls to view functions (a list), and
> * somefilesfor your templates (html with some extra bits thrown in).
> The templatefileslook like phpfiles, but with {% ... %} blocks in
> them instead of  blocks.
>
> Then the framework takes care of having the right view get called
> (which then grabs one of the templates) and returns the page to the
> user that requested it.
>
> > I trieddownloadingDjangoand installing it on my windows looks very
> > difficult. Plsease can anyone help me on how to installDjangoand how
> > to go about starting web development in Phyton?
>
> I'm not sure of the details for doing it on MS Windows. GNU/Linux is a
> good environment for development of all sorts. I recommend upgrading
> to Ubuntu.
>
> ---John


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



Re: Check if user is a member of group in template

2007-10-10 Thread äL

Great. Now it works how I expected.

See also 
http://www.djangoproject.com/documentation/templates_python/#extending-the-template-system
for further information.


On 9 Okt., 21:38, Ryan  Kanno <[EMAIL PROTECTED]> wrote:
> I think you're looking for something like this:
>
> http://www.djangosnippets.org/snippets/282/
>
> On Oct 9, 3:22 am, äL <[EMAIL PROTECTED]> wrote:
>
> > Inhttp://code.djangoproject.com/wiki/CookBookRequiredGroupLoginI
> > found how
> > to show a template only if the user is in a specific group (admin).
>
> > Now I would like to do the same in a template. How can I hide a link,
> > for example,
> > if the user is not in the admin group? I'm looking for something like
> > this:
>
> > {% ifequal user.group "admin" %}
> > Show detail
> > {% else %}
> > 
> > {% endifequal %}
>
> > Is there a django-command to achive this aim?


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



RegexField and Admin interface

2007-10-10 Thread Nader

Hello

I use Django  0.96 and in one of model's field I have to define a
'path' entry in which een Unix path (/usr/people/...)  can be given as
an input with validation naturally.
I would like to use Admin interface and have not found any Built-in
Filed of "RegexField" class to use it.

class MyModel(...):
   password = modles.RegexField()

I can't do it because we don't have any "RegexField" attribute in
"Admin" class. I have
been looking for information about this problem and have not found any
solution.
Could you tell me how I can solve this problem?

Regards,
Nader


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



Serving static media on the development server

2007-10-10 Thread Nikola Stjelja
i'm a noob in Django, and I'm currently learning it. I tried to use style
sheets from an external css file but it didn't work. I copyed the code from
the djagno documentation page, I followed all the instructions but every
time I run a page insted of a nice green background i get this:
Page not found:
C:\Python25\lib\site-packages\django/contrib/admin/media\stil.css

this is the code i used:

urlpatterns = patterns('',
# Example:
# (r'^cms/', include('cms.foo.urls')),

# Uncomment this for admin:
 (r'^admin/', include('django.contrib.admin.urls')),
 (r'^$', 'cms.editor.views.index'),
 (r'^(?P\d+)/$', 'cms.editor.views.stranice'),
 (r'^mail/$', 'cms.editor.views.mail'),
 (r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': 'c:/python_programi/cms/media/'}),
)

and



TIA

-- 
Please visit this site and play my RPG!

http://www.1km1kt.net/rpg/Marinci.php

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



Re: Get model's attributes

2007-10-10 Thread Ben Ford
Why would you need to do this?? The question as you've phrased it doesn't
make any sense...
Ben

On 10/10/2007, xunSir <[EMAIL PROTECTED]> wrote:
>
>
> class Address(models.Model):
>   name = models.CharField('uname', maxlength=20, unique=True)
>   mobile = models.CharField('umobile', maxlength=11)
>   room = models.CharField('uroom', maxlength=10)
>
>   class Admin:
> list_display = ('name', 'mobile', 'room')
> =
> objs = Address.objects.all()
>
> How to get :
>   1  ['name', 'mobile', 'room']
>   2  ['uname', 'umobile', 'uroom']
>   3  {'name':'uname', 'mobile':'umobile', 'room':'uroom'}
>
> Address's attributes are unfixed.
>
> "Class Amdin" let those come ture, but I am blind to see the English.
>
> ~~
> Thanks.
>
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+6281317958862

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



Re: Advanced search issues

2007-10-10 Thread Ben Ford
A good start would be to put that sql in get_min_rent into a queryset... I
it's queryset.select(). I'm not sure if you'll then be able to
order_by('min_rent') though...
Ben

On 10/10/2007, Dan <[EMAIL PROTECTED]> wrote:
>
>
> Hi
>
> I am trying to make an advanced search page where a user can list
> guest-houses based on several different criteria. As there can be many
> rooms in a house each with different availability and rent prices i am
> having problems constructing a filter for this.
>
> Models:
>
> class Property(models.Model):
>name = models.CharField(max_length=30, verbose_name=_('Property
> Name'))
>property_type = models.CharField(max_length=2,
> choices=PROPERTY_CHOICES)
>
>def get_available_rooms(self):
> return Room.objects.filter(property=self,
> available=True).count()
>
>def is_room_available(self):
> if self.get_available_rooms():
> return True
> else:
> return False
>
> def get_min_rent(self):
> from django.db import connection
> cursor = connection.cursor()
> cursor.execute("SELECT min(DISTINCT rent) FROM property_room
> AS r WHERE r.property_id = %s", [self.id])
> return cursor.fetchone()[0]
>
> class Room(models.Model):
> property = models.ForeignKey(Property, verbose_name=_('Property'))
> rent = models.DecimalField(max_digits=9, decimal_places=2)
> available = models.BooleanField()
> .
>
> So basically in the view i would like to do a filter on Property with
> the critera: property_type, min_rent, max_rent, is_room_available etc
> but this throws up an error as min_rent, max_rent, is_room_available
> are not fields in the database, I looked at the custom model managers
> and they seems to work but just for one custom criteria at a time.
>
> Could someone please recommend a good way to solve this issue so i can
> produce a queryset with all these search criteria, thanks.
>
> -Dan
>
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+6281317958862

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



Advanced search issues

2007-10-10 Thread Dan

Hi

I am trying to make an advanced search page where a user can list
guest-houses based on several different criteria. As there can be many
rooms in a house each with different availability and rent prices i am
having problems constructing a filter for this.

Models:

class Property(models.Model):
   name = models.CharField(max_length=30, verbose_name=_('Property
Name'))
   property_type = models.CharField(max_length=2,
choices=PROPERTY_CHOICES)
   
   def get_available_rooms(self):
return Room.objects.filter(property=self,
available=True).count()

   def is_room_available(self):
if self.get_available_rooms():
return True
else:
return False

def get_min_rent(self):
from django.db import connection
cursor = connection.cursor()
cursor.execute("SELECT min(DISTINCT rent) FROM property_room
AS r WHERE r.property_id = %s", [self.id])
return cursor.fetchone()[0]

class Room(models.Model):
property = models.ForeignKey(Property, verbose_name=_('Property'))
rent = models.DecimalField(max_digits=9, decimal_places=2)
available = models.BooleanField()
.

So basically in the view i would like to do a filter on Property with
the critera: property_type, min_rent, max_rent, is_room_available etc
but this throws up an error as min_rent, max_rent, is_room_available
are not fields in the database, I looked at the custom model managers
and they seems to work but just for one custom criteria at a time.

Could someone please recommend a good way to solve this issue so i can
produce a queryset with all these search criteria, thanks.

-Dan


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