question : Add HTTP-GET accessabilty to 'Poll', Based on samuraisam's django-json-rpc

2011-10-06 Thread bino oetomo


Dear All ...

Reff, samuraisam's django-json-rpc is at : 
https://github.com/samuraisam/django-json-rpc#readme


I try to implement that solution to my "Poll" app .. hope that it'll be 
accessible via simple HTTP-GET.


What I've done :
Below is mypoll/urls.py:
from django.conf.urls.defaults import *
from jsonrpc import jsonrpc_site
import mypoll.poll.views
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^json/browse/$', 'jsonrpc.views.browse', name="jsonrpc_browser"),
url(r'^json/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'),
(r'^json/(?P[a-zA-Z0-9.-_]+)$', jsonrpc_site.dispatch),
(r'^admin/', include(admin.site.urls)),
)
Below is mypoll/poll/views.py:
from jsonrpc import jsonrpc_method
from poll.models import *

@jsonrpc_method('poll.add', authenticated=True, safe=True)
def add_poll(request, question):
  p = Poll(question=question, pub_date=datetime.datetime.now())
  p.save()
  return p.__dict__

---Below is INSTALLED_APPS of mypoll/settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'poll',
'jsonrpc',
)
==
Next I test it with :
http://127.0.0.1:8000/jsonrpc/poll.add?username=bino&;password=123=TryJson

The result is :
-START--
Using the URLconf defined in mypoll.urls, Django tried these URL 
patterns, in this order:


   1. ^json/browse/$ [name='jsonrpc_browser']
   2. ^json/$ [name='jsonrpc_mountpoint']
   3. ^json/(?P[a-zA-Z0-9.-_]+)$
   4. ^admin/

The current URL, jsonrpc/poll.add, didn't match any of these.
-STOP---

Kindly please give me your enlightment to fix this problem

Sincerely
-bino-

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



Re: How to make Django pick new urls immediately

2011-10-06 Thread Babatunde Akinyanmi
With django, when a url is sent to the server, the work flow is that
urls.py is first run to check if an expression that matches the url
submitted is available in the pattern function. If available, it runs
the view function specified in the pattern. This just means that you
don't have to restart your server when you add a new url expression so
I suppose the "something" you did was to correct typosor you
could be more specific

On 10/6/11, Kayode Odeyemi  wrote:
> Hello,
>
> I don't know if I'm the only one experiencing this. I have multiple urls.py
> in different packages based on
> the similarities of the modules. Everytime I add a new url to urls.py, it
> doesn't take effect immediately. Always returning 404 until
> I have to do something... Can't remember what I did.
>
> Is anyone experiencing the same?
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



m2m ordering doesn't seem to work as expected

2011-10-06 Thread Knack
Hi guys,

from the docs I thought the following should work to get the
insertion_order as default (to be recognized by serialiser etc.). The
commeted lines are other unsuccessful attemps:

class Thingie(models.Model):
obj_id = models.CharField(max_length=32, primary_key=True)
children = models.ManyToManyField('Thingie', blank=True,
null=True,
  symmetrical=False,
through="OrderedThingieChild")

#class Meta:
#ordering = ["thingie_from__insertion_order"]

class ThingieChild(models.Model):
thingie_from = models.ForeignKey(Thingie,
related_name='thingie_from')
thingie_to = models.ForeignKey(Thingie, related_name='thingie_to')
insertion_order = models.IntegerField()

#class Meta:
#ordering = ["insertion_order"]

class OrderedThingieChild(ThingieChild):
class Meta:
ordering = ordering = ["insertion_order"]
proxy = True

# Usage:
# --
import uuid

def get_id():
return uuid.uuid1().hex

def test_m2m_ordering():
thing_1 = Thingie.objects.create(obj_id=get_id())

thing_2 = Thingie.objects.create(obj_id=get_id())
thing_3 = Thingie.objects.create(obj_id=get_id())
thing_4 = Thingie.objects.create(obj_id=get_id())

OrderedThingieChild.objects.create(thingie_from=thing_1,
thingie_to=thing_4,
insertion_order=2)
OrderedThingieChild.objects.create(thingie_from=thing_1,
thingie_to=thing_3,
insertion_order=1)
OrderedThingieChild.objects.create(thingie_from=thing_1,
thingie_to=thing_2,
insertion_order=0)

How can I specify the default ordering of m2m relations?

Cheers,

Jan

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



Porting BugFix #3615 (Can't define forward references in fixtures using MySQL with InnoDB) to Django 1.3.1

2011-10-06 Thread Kirill Panshin
Hey,

If you get this problem with your fixtures when loading them into
MySQL InnoDB,
you can use this forked branch of Django:

https://github.com/kipanshi/django/tree/1.3.1.1

To install via pip:

pip install -e git+git://github.com/kipanshi/
django.git@1.3.1.1#egg=django-1.3.1.1


-- Cheers, Ki

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



Re: hasNoProfanities validator - no longer exists?

2011-10-06 Thread william ratcliff
Simple filters run into problems like:

http://en.wikipedia.org/wiki/Scunthorpe_problem


William

On Thu, Oct 6, 2011 at 10:18 PM, robinne wrote:

> I've finally managed to get a basic validator to work on a model (I
> used validate_slug on a model field and was able to catch it as a
> ValidationError). After getting that to work I tried to then get the
> validator that I actually want to work, hasNoProfanities. I have found
> that the validator no longer exists. I think the Django 1.3 docs need
> to be updated but before I request that I wanted to be sure that this
> is the case. This is from the docs:
>
>
> https://docs.djangoproject.com/en/1.3/ref/settings/
>
> PROFANITIES_LIST
>
> Default: () (Empty tuple)
>
> A tuple of profanities, as strings, that will trigger a validation
> error when the hasNoProfanities validator is called.
>
>
> I guess you have to basically handle this on your own now, is that
> true?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



hasNoProfanities validator - no longer exists?

2011-10-06 Thread robinne
I've finally managed to get a basic validator to work on a model (I
used validate_slug on a model field and was able to catch it as a
ValidationError). After getting that to work I tried to then get the
validator that I actually want to work, hasNoProfanities. I have found
that the validator no longer exists. I think the Django 1.3 docs need
to be updated but before I request that I wanted to be sure that this
is the case. This is from the docs:


https://docs.djangoproject.com/en/1.3/ref/settings/

PROFANITIES_LIST

Default: () (Empty tuple)

A tuple of profanities, as strings, that will trigger a validation
error when the hasNoProfanities validator is called.


I guess you have to basically handle this on your own now, is that
true?

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



Re: Django image upload

2011-10-06 Thread Ian
So should I put it in a try/catch block to verify it's an image?

Also, how do I go about saving it as a different name (as the ID of
the model, for example)?

On Oct 6, 7:26 pm, Kurtis Mullins  wrote:
> ImageField uses PIL (Python Imaging Library) to verify if it's a valid
> image, if I understand it correctly.
>
>
>
>
>
>
>
> On Thu, Oct 6, 2011 at 6:21 PM, Ian  wrote:
> > Ah! Got it working! How do I make sure the files are only images?  Is
> > there a way to check the extension?  Also, how would I rename the
> > file?
>
> > Thanks!
>
> > On Oct 6, 3:46 pm, bazaarsoft  wrote:
> > > Noticed a couple of typos in my reply:
>
> > > > I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
>
> > > file, not folder
>
> > > > and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
>
> > > is actually 'pluginFiles/%Y/%m/%d/%H/%M/'
>
> > > jay
>
> > > On Oct 6, 2:41 pm, bazaarsoft  wrote:
>
> > > > > Also, I'm confused whether upload_to should be set in settings.py or
> > > > > models.py
>
> > > > It's actually a mix - if you have MEDIA_ROOT defined in settings.py,
> > > > then it will use that as the first part of the path. Then, what you
> > > > pass in the upload_to field will be appended to that. So, in my case,
> > > > I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
> > > > and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
> > > > What ultimately happens, then, is that the file gets stored here:
>
> > > > /Users/storefiles/pluginfiles/2011/10/06/02/38/somefile.zip
>
> > > > So, you must have at least one of those set and the path must be fully
> > > > write enabled for whatever process is running your Django app. For my
> > > > testing, I just made /Users/storefiles writable by everyone since I
> > > > don't really care about securing that directory on my dev Mac.
>
> > > > jay
>
> > > > On Oct 6, 1:08 pm, Ian  wrote:
>
> > > > > I can't seem to get it working.  It won't let my sync the database
> > > > > with this code:
> > > > > image = ImageField(upload_to=None[, max_length=100, **options])
>
> > > > > Also, I'm confused whether upload_to should be set in settings.py or
> > > > > models.py
>
> > > > > Thanks!
>
> > > > > On Oct 6, 6:11 am, BILLION Sébastien 
> > > > > wrote:
>
> > > > > > Hi,
>
> >http://www.nitinh.com/2009/02/django-example-filefield-and-imagefield/
>
> > > > > > It the same for ImageField
>
> > > > > > BILLION S�bastien
>
> > > > > > the Answer to the ultimate question of life, the universe and
> > everything
> > > > > > is 42
>
> > > > > >http://www.sebastienbillion.com/
>
> > > > > > Le 06/10/2011 05:22, Ian a �crit :
>
> > > > > > > Hey Everyone,
>
> > > > > > > I'm new to django, but I love it so far!
>
> > > > > > > I'm trying to figure out how to upload an image (restrict it to
> > images
> > > > > > > only) and resave it as a different name.
> > > > > > > Eventually, I'll want to upload it to S3, but for now, I'm just
> > > > > > > testing it on my computer with runserver (so I'm not sure where
> > it
> > > > > > > should be saving it).
>
> > > > > > > There are hundreds of tutorials for this online, but they are
> > either
> > > > > > > outdated or more complex than I'm looking for.
>
> > > > > > > Right now, I have a template with the form in it.  I'm not sure
> > where
> > > > > > > to go from there.
>
> > > > > > > Thanks so much!
> > > > > > > Sorry if this question is too basic!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Django image upload

2011-10-06 Thread Ian
So should I put it in a try/catch block to verify it's an image?

Also, how do I go about saving it as a different name (as the ID of
the model, for example)?

On Oct 6, 7:26 pm, Kurtis Mullins  wrote:
> ImageField uses PIL (Python Imaging Library) to verify if it's a valid
> image, if I understand it correctly.
>
>
>
>
>
>
>
> On Thu, Oct 6, 2011 at 6:21 PM, Ian  wrote:
> > Ah! Got it working! How do I make sure the files are only images?  Is
> > there a way to check the extension?  Also, how would I rename the
> > file?
>
> > Thanks!
>
> > On Oct 6, 3:46 pm, bazaarsoft  wrote:
> > > Noticed a couple of typos in my reply:
>
> > > > I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
>
> > > file, not folder
>
> > > > and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
>
> > > is actually 'pluginFiles/%Y/%m/%d/%H/%M/'
>
> > > jay
>
> > > On Oct 6, 2:41 pm, bazaarsoft  wrote:
>
> > > > > Also, I'm confused whether upload_to should be set in settings.py or
> > > > > models.py
>
> > > > It's actually a mix - if you have MEDIA_ROOT defined in settings.py,
> > > > then it will use that as the first part of the path. Then, what you
> > > > pass in the upload_to field will be appended to that. So, in my case,
> > > > I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
> > > > and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
> > > > What ultimately happens, then, is that the file gets stored here:
>
> > > > /Users/storefiles/pluginfiles/2011/10/06/02/38/somefile.zip
>
> > > > So, you must have at least one of those set and the path must be fully
> > > > write enabled for whatever process is running your Django app. For my
> > > > testing, I just made /Users/storefiles writable by everyone since I
> > > > don't really care about securing that directory on my dev Mac.
>
> > > > jay
>
> > > > On Oct 6, 1:08 pm, Ian  wrote:
>
> > > > > I can't seem to get it working.  It won't let my sync the database
> > > > > with this code:
> > > > > image = ImageField(upload_to=None[, max_length=100, **options])
>
> > > > > Also, I'm confused whether upload_to should be set in settings.py or
> > > > > models.py
>
> > > > > Thanks!
>
> > > > > On Oct 6, 6:11 am, BILLION Sébastien 
> > > > > wrote:
>
> > > > > > Hi,
>
> >http://www.nitinh.com/2009/02/django-example-filefield-and-imagefield/
>
> > > > > > It the same for ImageField
>
> > > > > > BILLION S�bastien
>
> > > > > > the Answer to the ultimate question of life, the universe and
> > everything
> > > > > > is 42
>
> > > > > >http://www.sebastienbillion.com/
>
> > > > > > Le 06/10/2011 05:22, Ian a �crit :
>
> > > > > > > Hey Everyone,
>
> > > > > > > I'm new to django, but I love it so far!
>
> > > > > > > I'm trying to figure out how to upload an image (restrict it to
> > images
> > > > > > > only) and resave it as a different name.
> > > > > > > Eventually, I'll want to upload it to S3, but for now, I'm just
> > > > > > > testing it on my computer with runserver (so I'm not sure where
> > it
> > > > > > > should be saving it).
>
> > > > > > > There are hundreds of tutorials for this online, but they are
> > either
> > > > > > > outdated or more complex than I'm looking for.
>
> > > > > > > Right now, I have a template with the form in it.  I'm not sure
> > where
> > > > > > > to go from there.
>
> > > > > > > Thanks so much!
> > > > > > > Sorry if this question is too basic!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Django image upload

2011-10-06 Thread Kurtis Mullins
ImageField uses PIL (Python Imaging Library) to verify if it's a valid
image, if I understand it correctly.

On Thu, Oct 6, 2011 at 6:21 PM, Ian  wrote:

> Ah! Got it working! How do I make sure the files are only images?  Is
> there a way to check the extension?  Also, how would I rename the
> file?
>
> Thanks!
>
> On Oct 6, 3:46 pm, bazaarsoft  wrote:
> > Noticed a couple of typos in my reply:
> >
> > > I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
> >
> > file, not folder
> >
> > > and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
> >
> > is actually 'pluginFiles/%Y/%m/%d/%H/%M/'
> >
> > jay
> >
> > On Oct 6, 2:41 pm, bazaarsoft  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > > Also, I'm confused whether upload_to should be set in settings.py or
> > > > models.py
> >
> > > It's actually a mix - if you have MEDIA_ROOT defined in settings.py,
> > > then it will use that as the first part of the path. Then, what you
> > > pass in the upload_to field will be appended to that. So, in my case,
> > > I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
> > > and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
> > > What ultimately happens, then, is that the file gets stored here:
> >
> > > /Users/storefiles/pluginfiles/2011/10/06/02/38/somefile.zip
> >
> > > So, you must have at least one of those set and the path must be fully
> > > write enabled for whatever process is running your Django app. For my
> > > testing, I just made /Users/storefiles writable by everyone since I
> > > don't really care about securing that directory on my dev Mac.
> >
> > > jay
> >
> > > On Oct 6, 1:08 pm, Ian  wrote:
> >
> > > > I can't seem to get it working.  It won't let my sync the database
> > > > with this code:
> > > > image = ImageField(upload_to=None[, max_length=100, **options])
> >
> > > > Also, I'm confused whether upload_to should be set in settings.py or
> > > > models.py
> >
> > > > Thanks!
> >
> > > > On Oct 6, 6:11 am, BILLION Sébastien 
> > > > wrote:
> >
> > > > > Hi,
> >
> > > > >
> http://www.nitinh.com/2009/02/django-example-filefield-and-imagefield/
> >
> > > > > It the same for ImageField
> >
> > > > > BILLION S�bastien
> >
> > > > > the Answer to the ultimate question of life, the universe and
> everything
> > > > > is 42
> >
> > > > >http://www.sebastienbillion.com/
> >
> > > > > Le 06/10/2011 05:22, Ian a �crit :
> >
> > > > > > Hey Everyone,
> >
> > > > > > I'm new to django, but I love it so far!
> >
> > > > > > I'm trying to figure out how to upload an image (restrict it to
> images
> > > > > > only) and resave it as a different name.
> > > > > > Eventually, I'll want to upload it to S3, but for now, I'm just
> > > > > > testing it on my computer with runserver (so I'm not sure where
> it
> > > > > > should be saving it).
> >
> > > > > > There are hundreds of tutorials for this online, but they are
> either
> > > > > > outdated or more complex than I'm looking for.
> >
> > > > > > Right now, I have a template with the form in it.  I'm not sure
> where
> > > > > > to go from there.
> >
> > > > > > Thanks so much!
> > > > > > Sorry if this question is too basic!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Django image upload

2011-10-06 Thread Ian
Ah! Got it working! How do I make sure the files are only images?  Is
there a way to check the extension?  Also, how would I rename the
file?

Thanks!

On Oct 6, 3:46 pm, bazaarsoft  wrote:
> Noticed a couple of typos in my reply:
>
> > I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
>
> file, not folder
>
> > and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
>
> is actually 'pluginFiles/%Y/%m/%d/%H/%M/'
>
> jay
>
> On Oct 6, 2:41 pm, bazaarsoft  wrote:
>
>
>
>
>
>
>
> > > Also, I'm confused whether upload_to should be set in settings.py or
> > > models.py
>
> > It's actually a mix - if you have MEDIA_ROOT defined in settings.py,
> > then it will use that as the first part of the path. Then, what you
> > pass in the upload_to field will be appended to that. So, in my case,
> > I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
> > and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
> > What ultimately happens, then, is that the file gets stored here:
>
> > /Users/storefiles/pluginfiles/2011/10/06/02/38/somefile.zip
>
> > So, you must have at least one of those set and the path must be fully
> > write enabled for whatever process is running your Django app. For my
> > testing, I just made /Users/storefiles writable by everyone since I
> > don't really care about securing that directory on my dev Mac.
>
> > jay
>
> > On Oct 6, 1:08 pm, Ian  wrote:
>
> > > I can't seem to get it working.  It won't let my sync the database
> > > with this code:
> > > image = ImageField(upload_to=None[, max_length=100, **options])
>
> > > Also, I'm confused whether upload_to should be set in settings.py or
> > > models.py
>
> > > Thanks!
>
> > > On Oct 6, 6:11 am, BILLION Sébastien 
> > > wrote:
>
> > > > Hi,
>
> > > >http://www.nitinh.com/2009/02/django-example-filefield-and-imagefield/
>
> > > > It the same for ImageField
>
> > > > BILLION S�bastien
>
> > > > the Answer to the ultimate question of life, the universe and everything
> > > > is 42
>
> > > >http://www.sebastienbillion.com/
>
> > > > Le 06/10/2011 05:22, Ian a �crit :
>
> > > > > Hey Everyone,
>
> > > > > I'm new to django, but I love it so far!
>
> > > > > I'm trying to figure out how to upload an image (restrict it to images
> > > > > only) and resave it as a different name.
> > > > > Eventually, I'll want to upload it to S3, but for now, I'm just
> > > > > testing it on my computer with runserver (so I'm not sure where it
> > > > > should be saving it).
>
> > > > > There are hundreds of tutorials for this online, but they are either
> > > > > outdated or more complex than I'm looking for.
>
> > > > > Right now, I have a template with the form in it.  I'm not sure where
> > > > > to go from there.
>
> > > > > Thanks so much!
> > > > > Sorry if this question is too basic!

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



Adding calculated field depending on admin form and inlines/related models

2011-10-06 Thread graeme
I want to store the result of an expensive calculation in my model.

It should be caculated if the the current value is null.

It should also be calculated if requested on the admin form (I added a
Boolean field to the form for this purpose).

The problem is that the calculation requires values from related
models that are Inlines in the admin.

I cannot get the values from the related models in the form, so I
cannot see how to do the calculation there.

I cannot find a signal, or another way, of doing the calculation after
all the related models have been saved. I could call it using signales
on the related models, but then its called many times. That and the
need to modify and resave what I just saved seems a little clumsy.

 Even if I can solve that, it still has no way of knowing if the
Boolean in the form was ticked or not (it does not match a field in
the model, so its value is not saved).

So where can I get values from the admin modelform, AND the inlines?
Or the saved models and the modelform?

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



Re: show image

2011-10-06 Thread Cal Leeming [Simplicity Media Ltd]
Please don't expect any type of serious response if you don't even bother to
put effort into your question.

For future reference, please see -
https://code.djangoproject.com/wiki/UsingTheMailingList

Maybe re-post your question in the form of a question, and you might get a
response.

Cal

On Thu, Oct 6, 2011 at 9:58 PM, electrocoder  wrote:

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

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



Re: Django tutorial, cannot add "polls" to admin

2011-10-06 Thread Ser5
Ahhh, after heavy digging of the internet and gazing at example app 
"django-registration" I discovered that I have missed one thing - I didn't 
include "polls" in INSTALLED_APPS. After adding it I finally got "Polls" in 
the Django admin.

But anyway, thank you for trying to help me =)

Seems like that my problem is solved now and I'm ready to meet next ones =)

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



show image

2011-10-06 Thread electrocoder
how do user image thumbnail django admin panel?

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



Your Impressions on DjangoCMS

2011-10-06 Thread colinta
I would love to hear some professional opinions on how easy it is to
create, maintain and support a DjangoCMS-based website.  The only
curve ball is that the client will need customizable forms.  Otherwise
it's a pretty standard site.

Very recently - last week - the company I work for announced that we
are switching from PHP, where we have built a robust lovely framework
(in PHP, though, so ug) and really whiz-bang-neat CMS (very drag-and-
droppy, clients love it).  We've settled on Python+Django as our new
stack, where we will call upon the resources of the open-source
community so that we can focus on *building sites* rather than adding
features and bug fixing our internal framework.

But the question remains open whether we should build this *next*
project using our tried-and-true framework & CMS, or whether we'll use
DjangoCMS for the first time.

So whaddya say!  Any thoughts?  Strong opinions one way or the other?
I will really appreciate the insight.

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



Re: Django tutorial, cannot add "polls" to admin

2011-10-06 Thread Yaşar Arabacı
How does your urls.py look like? Did you uncomment admin related things in
there?

2011/10/6 Ser5 

> Hi! Help me please to solve one tutorial problem.
>
> Now I'm reading the 2nd part of the tutorial and have stuck with adding
> polls app to the Django admin.
> Everything worked fine in the tutorial until I reached "Make the poll app
> modifiable in the admin" part.
>
> Here is the link to the tutorial page I'm currently at:
> https://docs.djangoproject.com/en/1.3/intro/tutorial02/
>
> I have already added admin.py file and now have mysite/polls directory with
> the following content:
> ModeLastWriteTime Length Name
> - -- 
> -a---06.10.2011 23:54 94 admin.py
> -a---07.10.2011  0:21609 models.py
> -a---06.10.2011 23:39   1478 models.pyc
> -a---06.10.2011 23:13399 tests.py
> -a---06.10.2011 23:13 27 views.py
> -a---06.10.2011 23:13  0 __init__.py
> -a---06.10.2011 23:19150 __init__.pyc
>
> admin.py contains this:
> ---
> from polls.models import Poll
> from django.contrib import admin
>
> admin.site.register(Poll)
> ---
>
>
> If this can help, models.py have this content:
> ---
> from django.db import models
> import datetime
>
>
>
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
> def __unicode__(self):
> return self.question
>
> def was_published_today(self):
> return self.pub_date.date() == datetime.date.today()
>
>
>
> class Choice(models.Model):
> poll = models.ForeignKey(Poll)
> choice = models.CharField(max_length=200)
> votes = models.IntegerField()
>
> def __unicode__(self):
> return self.choice
> ---
>
>
>
> I restarted the Django development server several times.
> And I'm looking here http://127.0.0.1:8000/admin/ for the "poll" app to
> appear. But it doesn't =( Still only "Auth" and "Sites" here.
>
> Tell me please - did I miss something? Or did the tutorial miss something?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/c0WVz5UjgFUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



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



Re: How to make Django pick new urls immediately

2011-10-06 Thread Yaşar Arabacı
maybe you should restart the server? And, do you include new urls in your
root url config?

2011/10/6 Kayode Odeyemi 

> Hello,
>
> I don't know if I'm the only one experiencing this. I have multiple urls.py
> in different packages based on
> the similarities of the modules. Everytime I add a new url to urls.py, it
> doesn't take effect immediately. Always returning 404 until
> I have to do something... Can't remember what I did.
>
> Is anyone experiencing the same?
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



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



Re: Django image upload

2011-10-06 Thread bazaarsoft
Noticed a couple of typos in my reply:

> I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,

file, not folder

> and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.

is actually 'pluginFiles/%Y/%m/%d/%H/%M/'

jay

On Oct 6, 2:41 pm, bazaarsoft  wrote:
> > Also, I'm confused whether upload_to should be set in settings.py or
> > models.py
>
> It's actually a mix - if you have MEDIA_ROOT defined in settings.py,
> then it will use that as the first part of the path. Then, what you
> pass in the upload_to field will be appended to that. So, in my case,
> I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
> and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
> What ultimately happens, then, is that the file gets stored here:
>
> /Users/storefiles/pluginfiles/2011/10/06/02/38/somefile.zip
>
> So, you must have at least one of those set and the path must be fully
> write enabled for whatever process is running your Django app. For my
> testing, I just made /Users/storefiles writable by everyone since I
> don't really care about securing that directory on my dev Mac.
>
> jay
>
> On Oct 6, 1:08 pm, Ian  wrote:
>
>
>
>
>
>
>
> > I can't seem to get it working.  It won't let my sync the database
> > with this code:
> > image = ImageField(upload_to=None[, max_length=100, **options])
>
> > Also, I'm confused whether upload_to should be set in settings.py or
> > models.py
>
> > Thanks!
>
> > On Oct 6, 6:11 am, BILLION Sébastien 
> > wrote:
>
> > > Hi,
>
> > >http://www.nitinh.com/2009/02/django-example-filefield-and-imagefield/
>
> > > It the same for ImageField
>
> > > BILLION S�bastien
>
> > > the Answer to the ultimate question of life, the universe and everything
> > > is 42
>
> > >http://www.sebastienbillion.com/
>
> > > Le 06/10/2011 05:22, Ian a �crit :
>
> > > > Hey Everyone,
>
> > > > I'm new to django, but I love it so far!
>
> > > > I'm trying to figure out how to upload an image (restrict it to images
> > > > only) and resave it as a different name.
> > > > Eventually, I'll want to upload it to S3, but for now, I'm just
> > > > testing it on my computer with runserver (so I'm not sure where it
> > > > should be saving it).
>
> > > > There are hundreds of tutorials for this online, but they are either
> > > > outdated or more complex than I'm looking for.
>
> > > > Right now, I have a template with the form in it.  I'm not sure where
> > > > to go from there.
>
> > > > Thanks so much!
> > > > Sorry if this question is too basic!

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



Re: Django image upload

2011-10-06 Thread bazaarsoft
> Also, I'm confused whether upload_to should be set in settings.py or
> models.py

It's actually a mix - if you have MEDIA_ROOT defined in settings.py,
then it will use that as the first part of the path. Then, what you
pass in the upload_to field will be appended to that. So, in my case,
I have "MEDIA_ROOT = '/Users/storefiles/' in my settings.py folder,
and the upload_to param in my model set to 'pluginFiles/%Y/%m/%H/%M/'.
What ultimately happens, then, is that the file gets stored here:

/Users/storefiles/pluginfiles/2011/10/06/02/38/somefile.zip

So, you must have at least one of those set and the path must be fully
write enabled for whatever process is running your Django app. For my
testing, I just made /Users/storefiles writable by everyone since I
don't really care about securing that directory on my dev Mac.

jay

On Oct 6, 1:08 pm, Ian  wrote:
> I can't seem to get it working.  It won't let my sync the database
> with this code:
> image = ImageField(upload_to=None[, max_length=100, **options])
>
> Also, I'm confused whether upload_to should be set in settings.py or
> models.py
>
> Thanks!
>
> On Oct 6, 6:11 am, BILLION Sébastien 
> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> >http://www.nitinh.com/2009/02/django-example-filefield-and-imagefield/
>
> > It the same for ImageField
>
> > BILLION S�bastien
>
> > the Answer to the ultimate question of life, the universe and everything
> > is 42
>
> >http://www.sebastienbillion.com/
>
> > Le 06/10/2011 05:22, Ian a �crit :
>
> > > Hey Everyone,
>
> > > I'm new to django, but I love it so far!
>
> > > I'm trying to figure out how to upload an image (restrict it to images
> > > only) and resave it as a different name.
> > > Eventually, I'll want to upload it to S3, but for now, I'm just
> > > testing it on my computer with runserver (so I'm not sure where it
> > > should be saving it).
>
> > > There are hundreds of tutorials for this online, but they are either
> > > outdated or more complex than I'm looking for.
>
> > > Right now, I have a template with the form in it.  I'm not sure where
> > > to go from there.
>
> > > Thanks so much!
> > > Sorry if this question is too basic!

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



Have different databases using SQLite

2011-10-06 Thread Lars Ruoff
Hi,

i'm having the Django database set up like so:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'D:\Users\Max\Projects\my4x\data\my4x.db',
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

I see that the database contains a lot of Django-related stuff (tables
with auth_ and django_ prefixes).
Is there a way i can seperate the Django stuff from my apps model
database?
What I'd prefer is to have two different databases (files), with one
containing the Django stuff and the other my own models.
Reason is that i develop a game and the database stores the game state
for a given time step. Ideally, i would like to have a different game
database file for each time step so i can go back in time when i like.

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



How to make Django pick new urls immediately

2011-10-06 Thread Kayode Odeyemi
Hello,

I don't know if I'm the only one experiencing this. I have multiple urls.py
in different packages based on
the similarities of the modules. Everytime I add a new url to urls.py, it
doesn't take effect immediately. Always returning 404 until
I have to do something... Can't remember what I did.

Is anyone experiencing the same?

-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

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



How to do equivalent of LEFT JOIN ON in Django (returning all Left rows, when Right item may not exist)

2011-10-06 Thread Attempting Django
Hi guys, can anyone please give me an example of how to do equivalent
of a LEFT JOIN ON in Django?? I am trying to return every row from one
table on the left, with any matches in a foreign table on the right
(there will be only one or NULL match possible). The issue I'm having
is showing left table data when there is a NULL on the right. Thanks!

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



Re: how to access a foreignKey with multiple constraints

2011-10-06 Thread msbuck
I accidently hit Send before I was finished.

the development server validates this model, but I can't seem to
figure out how to access the last_name and first_name fields in the
template. When I do the following:

{{object.last_name}}

I get a Template Syntax Error. Caught ValueError while rendering:
invalid literal for int() with base 10: "Smith"

Is there any way around this short of modifying the legacy database?
If I can't find a way around this, my organization will most likely
not start using Django since the initial push is to use it for some
legacy db to implement reports and form.

Thanks!

On Oct 6, 1:55 pm, msbuck  wrote:
> I have a legacy Oracle database which I'm trying to model. I used
> inspectdb which did a good job. However, a few of my tables contain
> two fields which combine to form a foreign key constraint. In other
> words the legacy database was created like this:
>
> CREATE TABLE "MY_TABLE"
> ("TRACKING_ID" NUMBER NOT NULL ENABLE,
>  "LAST_NAME" VARCHAR(50 BYTE) NOT NULL ENABLE,
>  "FIRST_NAME" VARCHAR(50 BYTE) NOT NULL ENABLE
> CONSTRAINT 'EMP_REF_FK" FOREIGN KEY ("LAST NAME", "FIRST NAME")
> REFERENCES "EMPLOYEE_REF"("LAST_NAME, "FIRST_NAME") ENABLE
>
> The EMPLOYEE_REF table has a primary key and the last name and first
> name fields.
>
> The models  I'm using is:
>
> class EmployeeRef(models.Model):
>     employee_ref_id = models.IntegerField(primary_key=True)
>     last_name = models.CharField(max_length=50)
>     first_name = models.CharField(max_length=50)
>
> class MyTable(models.Model):
>     hour_tracking_id = models.DecimalField(max_digits=10,
> decimal_places=0, primary_key=True)
>     last_name = models.ForeignKey(EmployeeRef, db_column='last_name',
> related_name='employee.last_name')
>     first_name = models.ForeignKey(EmployeeRef,
> db_column='first_name', related_name='employee.first_name')

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



how to access a foreignKey with multiple constraints

2011-10-06 Thread msbuck
I have a legacy Oracle database which I'm trying to model. I used
inspectdb which did a good job. However, a few of my tables contain
two fields which combine to form a foreign key constraint. In other
words the legacy database was created like this:

CREATE TABLE "MY_TABLE"
("TRACKING_ID" NUMBER NOT NULL ENABLE,
 "LAST_NAME" VARCHAR(50 BYTE) NOT NULL ENABLE,
 "FIRST_NAME" VARCHAR(50 BYTE) NOT NULL ENABLE
CONSTRAINT 'EMP_REF_FK" FOREIGN KEY ("LAST NAME", "FIRST NAME")
REFERENCES "EMPLOYEE_REF"("LAST_NAME, "FIRST_NAME") ENABLE

The EMPLOYEE_REF table has a primary key and the last name and first
name fields.

The models  I'm using is:

class EmployeeRef(models.Model):
employee_ref_id = models.IntegerField(primary_key=True)
last_name = models.CharField(max_length=50)
first_name = models.CharField(max_length=50)

class MyTable(models.Model):
hour_tracking_id = models.DecimalField(max_digits=10,
decimal_places=0, primary_key=True)
last_name = models.ForeignKey(EmployeeRef, db_column='last_name',
related_name='employee.last_name')
first_name = models.ForeignKey(EmployeeRef,
db_column='first_name', related_name='employee.first_name')

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



Default model manager and .objects usage in django itself

2011-10-06 Thread Guilherme Salgado
Hi there,

I'm changing an existing app to add support for private objects which
are accessible only to certain users. In order to make it hard to
accidentally leak private data in case we forget to update one or more
places to use the new (privacy-aware) API, I've changed the plain
manager (.objects) to return only public objects and added a new
manager (.all_objects), which has the new API that takes a user and
returns only the objects (including the private ones) the user is
allowed to see.

The .all_objects manager is set as the default manager and I was under
the impression that would be enough to avoid breaking any django
features when used with private objects (e.g. validation of unique
constraints, ModelFormSet, etc) as most things seem to use the default
manager.

However, I've just found that
django.views.generic.create_update.lookup_object() (which is used in
the update_object() generic view) uses .objects directly and because
of that it doesn't work for my private objects. I'm now wondering if
there's a reason for that function to use .objects directly instead of
using the default manager. Also, if there is a reason for that, does
anyone know of other things that won't work with my private objects?

Thanks in advance!
Guilherme

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



Django tutorial, cannot add "polls" to admin

2011-10-06 Thread Ser5
Hi! Help me please to solve one tutorial problem.

Now I'm reading the 2nd part of the tutorial and have stuck with adding 
polls app to the Django admin.
Everything worked fine in the tutorial until I reached "Make the poll app 
modifiable in the admin" part.

Here is the link to the tutorial page I'm currently at:
https://docs.djangoproject.com/en/1.3/intro/tutorial02/

I have already added admin.py file and now have mysite/polls directory with 
the following content:
ModeLastWriteTime Length Name
- -- 
-a---06.10.2011 23:54 94 admin.py
-a---07.10.2011  0:21609 models.py
-a---06.10.2011 23:39   1478 models.pyc
-a---06.10.2011 23:13399 tests.py
-a---06.10.2011 23:13 27 views.py
-a---06.10.2011 23:13  0 __init__.py
-a---06.10.2011 23:19150 __init__.pyc

admin.py contains this:
---
from polls.models import Poll
from django.contrib import admin

admin.site.register(Poll)
---


If this can help, models.py have this content:
---
from django.db import models
import datetime



class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __unicode__(self):
return self.question

def was_published_today(self):
return self.pub_date.date() == datetime.date.today()



class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()

def __unicode__(self):
return self.choice
---



I restarted the Django development server several times.
And I'm looking here http://127.0.0.1:8000/admin/ for the "poll" app to 
appear. But it doesn't =( Still only "Auth" and "Sites" here.

Tell me please - did I miss something? Or did the tutorial miss something?

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



Re: Django image upload

2011-10-06 Thread Ian
I can't seem to get it working.  It won't let my sync the database
with this code:
image = ImageField(upload_to=None[, max_length=100, **options])

Also, I'm confused whether upload_to should be set in settings.py or
models.py

Thanks!

On Oct 6, 6:11 am, BILLION Sébastien 
wrote:
> Hi,
>
> http://www.nitinh.com/2009/02/django-example-filefield-and-imagefield/
>
> It the same for ImageField
>
> BILLION S�bastien
>
> the Answer to the ultimate question of life, the universe and everything
> is 42
>
> http://www.sebastienbillion.com/
>
> Le 06/10/2011 05:22, Ian a �crit :
>
>
>
>
>
>
>
> > Hey Everyone,
>
> > I'm new to django, but I love it so far!
>
> > I'm trying to figure out how to upload an image (restrict it to images
> > only) and resave it as a different name.
> > Eventually, I'll want to upload it to S3, but for now, I'm just
> > testing it on my computer with runserver (so I'm not sure where it
> > should be saving it).
>
> > There are hundreds of tutorials for this online, but they are either
> > outdated or more complex than I'm looking for.
>
> > Right now, I have a template with the form in it.  I'm not sure where
> > to go from there.
>
> > Thanks so much!
> > Sorry if this question is too basic!

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



Re: Class Views

2011-10-06 Thread Vijay Khemlani
It should be "render_to_response", not "render_to_reponse", a spelling
problem maybe?

On Thu, Oct 6, 2011 at 12:53 PM, CrabbyPete  wrote:

> I have the following class defined
>
> class TeamView(TemplateResponseMixin, View):
>template_name = 'team.html'
>
>def get(self, request):
>if 'team' in request.GET:
>team = Team.objects.get(id = request.GET['team'])
>form = TeamForm(  )
>else:
>team = None
>form = TeamForm()
>
>return self.render_to_response({'form':form, 'team':team})
>
>def post(self, request):
>form = TeamForm(request.POST)
>
>if not form.is_valid():
>return self.render_to_reponse({'form': form})
>...
>
> When I call the self.render_to_response in the get it works fine, but
> when I call it in the post
> I get 'TeamView' object has no attribute 'render_to_reponse'
>
> Any suggestions what I am doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Class Views

2011-10-06 Thread CrabbyPete
I have the following class defined

class TeamView(TemplateResponseMixin, View):
template_name = 'team.html'

def get(self, request):
if 'team' in request.GET:
team = Team.objects.get(id = request.GET['team'])
form = TeamForm(  )
else:
team = None
form = TeamForm()

return self.render_to_response({'form':form, 'team':team})

def post(self, request):
form = TeamForm(request.POST)

if not form.is_valid():
return self.render_to_reponse({'form': form})
...

When I call the self.render_to_response in the get it works fine, but
when I call it in the post
I get 'TeamView' object has no attribute 'render_to_reponse'

Any suggestions what I am doing wrong?

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



Re: static app on development server

2011-10-06 Thread brian
Nevermind.  My ide doesn't do auto server restarts so django wasn't
getting restarted.

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



static app on development server

2011-10-06 Thread brian
I can't get the static files to be served from an app dir.

I have myApp/static/styles2.css

The template myApp\templates\myApp\ver1\tmpl.html has

{% load static %}



In the settings file I have STATICFILES_FINDERS →
'django.contrib.staticfiles.finders.AppDirectoriesFinder'

In the url I have urlpatterns += staticfiles_urlpatterns().

Any suggestions of what I'm doing wrong?  I eventually want the css to
be:  myApp/static/myApp/ver1/styles.css

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



Re: How to get topics user replied?

2011-10-06 Thread Javier Guerra Giraldez
On Thu, Oct 6, 2011 at 9:41 AM, David.D  wrote:
> It work:
>
> Topic.objects.filter(pk__in=[comment.content_object.pk for comment in
> Comment.objects.filter(user__exact = request.user)])


or:

Topic.objets.filter (comments__user=request.user)

if you add a 'reverse generic relation' field to Topic:

class Topic(models.Model):
...
comments = generic.GenericRelation(Comment)

it won't add to the database fields, it just helps Django to build the
reverse relation

-- 
Javier

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



Re: How to get topics user replied?

2011-10-06 Thread David.D
It work:

Topic.objects.filter(pk__in=[comment.content_object.pk for comment in
Comment.objects.filter(user__exact = request.user)])



On Oct 6, 9:13 pm, "David.D"  wrote:
> class Topic(models.Model):
>     title = models.CharField(max_length=100)
>     body  = models.TextField(_('body'), max_length=TEXT_MAX_LENGTH)
>     user  = models.ForeignKey(User, related_name='topic_user',
> editable=False)
>     ...
>
> I use 'django.contrib.comments' to reply a topic. How to get topics
> user replied?
>
> Thanks.

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



Re: Helping someone move from Joomla to Django

2011-10-06 Thread Greg Maruszeczka
On Thu, 6 Oct 2011 06:12:21 -0700 (PDT)
graeme  wrote:

> Joomla may have those shortcomings, but its not the only alternative.
> If someone likee PHP, already knows PHP or has to use PHP, there are
>  a lot of PHP fraeworks: from light ones, to ones feature comparable
> to
> Django (although I do not know of any framework that can match
> Django Admin).
> 
> The best answer to the original question may be to persuade him to try
> a better PHP CMS or framework. I am looking at some myself at the
> moment.
> 

+1

Joomla sucks IMHO and not a great example of PHP-based framework/CMS.

FWIW I think Symfony is a pretty good PHP framework. Uses OOP,
alternative ORMs and a pretty good admin interface right out of the box.
I found moving from it to Django relatively easy...

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



How to get topics user replied?

2011-10-06 Thread David.D
class Topic(models.Model):
title = models.CharField(max_length=100)
body  = models.TextField(_('body'), max_length=TEXT_MAX_LENGTH)
user  = models.ForeignKey(User, related_name='topic_user',
editable=False)
...

I use 'django.contrib.comments' to reply a topic. How to get topics
user replied?

Thanks.

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



Re: Helping someone move from Joomla to Django

2011-10-06 Thread graeme
Joomla may have those shortcomings, but its not the only alternative.
If someone likee PHP, already knows PHP or has to use PHP, there are
 a lot of PHP fraeworks: from light ones, to ones feature comparable
to
Django (although I do not know of any framework that can match
Django Admin).

The best answer to the original question may be to persuade him to try
a better PHP CMS or framework. I am looking at some myself at the
moment.

On Oct 6, 1:22 pm, Kevin  wrote:
> I might say just 'WOW!'...  I just took some time to go over the
> Joomla documentations to see what I was up against.  Why do developers
> even use this thing?  Sure maybe the frontend is nice and polished,
> but the backend looks horrible, at least compared to Django.  Django
> code looks much more cleaner, and what's up with this statement at the
> top of almost every page:
>
> 

That is in case someone tries to execute the file directly rather than
through
the rest of Joomla. Its standard for PHP. Its a fallback for missing/
bad server configuration.
 Its the price for being able to run some  scripts without loading
your framework (or only chosen bits of it) simply by creating them in
the right place in the filesystem.


>
> The template system is not really a template system, but rather a hack
> and uses PHP inline to implement functionality.  There appears to be
> some template tags, but aren't compatible with web authoring software,
> as the tag use < and >.

PHP is a template system :) I rather like that.

>
> There doesn't seem to be an ORM of any kind, or lack thereof an
> example for it.  The database example I stumbled upon in the
> documentation uses RAW SQL code.  This can be prone to security issues
> if not properly coded and filtered.

There are PHP ORMs and frameworks that use them. Joomla,
unfortunately,
does not use one of them.

>
> Django really needs to be advertised more, and perhaps an easier
> method to deploy and manage templates/apps.  I can see how Joomla has
> the community it has, installing templates and components(as they call
> them) are very simple and mostly pain-free.

Agreed.

PHP is also very easy and cheap to host. I can run a small PHP site
on reliable hosting for $1 a month. The cost matters to people running
lots of
sites, or kids who are tomorrows developers, and for hobby sites. Lots
of
people are also more inclined to try something their existing hosting
supports.

>
> Does Django have an app which makes managing templates and apps and
> the settings.py file easy for novice users?  I, myself am able to use
> Django quite fully, but for new users who might be looking for an
> alternative from other frameworks, should have a good solution for
> this.
>
> The ability for new developers to easily "dive in" and test drive
> Django will be a nice bonus.  Given that a good chunk of the world
> uses Windows on their desktop PCs, a nice easy way to get a Django
> development environment up and running should be looked into.  I
> recently found a nice website(which is no longer there),
> instantdjango.com, they provided a nice self-extracting 7zip EXE file
> with a contained django environment.  A batch file launched the
> command prompt with the correct python environment variables set, it
> was rather nice.  There needs to be an official django release of such
> a development environment.  I still have a copy of the downloaded
> environment if anybody wants to check it out/distribute it amongst
> friends:
>
> http://c18321.r21.cf1.rackcdn.com/django.exe
>
> I can see plenty of users moving over to Django if they just saw how
> much easier it is to code in Django.
>
> On Sep 29, 4:42 am, Baurzhan Ismagulov  wrote:
>
>
>
> > On Wed, Sep 28, 2011 at 11:19:30PM -0700, Derek wrote:
> > > > How would you recommend I go about this task of moving my friend
> > > > over to a Django/Python based system over a Joomla/PHP based system?
> > ...
> > > > He is requesting some other interesting features, which apparently
> > > >someoneelse is working on implementing, and it's actually taking this
> > > > other person a few days, or maybe weeks to add. Where I know I can
> > > > implement it in Django in a matter of hours.
> > ...
> > > > What is everyone elses opinions on development in Django verses a
> > > > rival CMS such as Joomla?
>
> > If I had to add features or integrate stuff, I'd stay away from Joomla
> > (or any heavyweight CMS like Zope / Plone, for that matter). Can you
> > implement or at least prototype a few URLs in Django? In that way you
> > could answer your question about templates and demonstrate the
> > advantages to your friends.
>
> > If you don't 
> > succeed,http://groups.google.com/group/django-users/browse_thread/thread/4981...
> > could be an option.
>
> > With kind regards,
> > --
> > Baurzhan Ismagulovhttp://www.kz-easy.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send 

Re: Randomly clearing database tables

2011-10-06 Thread msbuck
The behavior I was seeing was as if the tests where run without using
manage.py. My app tests at this point are very simple. I use a fixture
to load data to do the view tests but don't explictly delete anything
from the tables.

I did basically what you suggested. You can set up the environment
variables that PyDev uses for unit tests and it can be different from
the regular running environment so I'm setting it to an explicit
settings.py module where sqlite3 is used.

I need to learn more about how PyDev runs it's unit tests. That will
be my next step.

Thanks for the advice.


On Oct 5, 12:09 pm, Ian Kelly  wrote:
> On Tue, Oct 4, 2011 at 2:28 PM, msbuck  wrote:
> > Below is the settings. I am fairly new to python unit testing so my
> > understanding of things could be better. But right now, if I select
> > Run As -> Python Unit Test will my project is selected, it runs all of
> > my Django tests and clobbers my working db as a result. The test
> > runner also appears to be ignoring my @skipUnless decorators that
> > should prevent db tests from running if settings.IS_TEST is set to
> > False. I'm getting frustrated again!
>
> I haven't used PyDev, but I would imagine it's probably importing the
> management commands and running them programmatically, rather than
> simply trying to run manage.py.  That would explain why your IS_TEST
> is False.  According to the docs, PyDev has a DJANGO_SETTINGS_MODULE
> variable.  I suggest setting that to an alternate settings.py that
> contains your test settings.
>
> I still can't see any reason why the tests would be flushing your
> tables, though.  Does it happen when you issue manage.py test (using
> the oracle backend) as well, or only from PyDev?  Could there be
> something in your app tests that might be causing the flush?

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



Re: Field exists but django tells me "is not defined"

2011-10-06 Thread Daniel Roseman
On Thursday, 6 October 2011 13:00:11 UTC+1, gregory semah wrote:
>
> Sorry my mistake again... 
>
> I mean when i write "Projet.objects.filter(fact!=None)" instead of 
> "Projet.objects.filter(fact=None)" 
>
> Thanks 
>
>
You can't use != in filter, as it's a function call. You need to do 
`filter(fact__isnull=False)` or `exclude(fact=None)`.
--
DR. 

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



Re: Field exists but django tells me "is not defined"

2011-10-06 Thread gregory semah
Ok isolved with
projet = Projet.objects.filter(fact__isnull=False)

Everything 's back to normal :)

On 6 oct, 14:00, gregory semah  wrote:
> Sorry my mistake again...
>
> I mean when i write "Projet.objects.filter(fact!=None)" instead of
> "Projet.objects.filter(fact=None)"
>
> Thanks
>
>
>
>
>
>
>
>
>
> > > Hi All,
>
> > > I'm dealing with really weird problem
>
> > > My model
> > > class Projet(models.Model):
> > >       ...
> > >       fact = models.PositiveIntegerField('Numéro de
> > > Facture',null=True,blank=True)
> > >       ...
> > >       ...
>
> > > A simple view from this model is
> > > def facture(request, id=None):
> > >      projet = Projet.objects.all()
>
> > > So as far as I am, everything worked as expected
> > > Now I wanted to change
> > > projet = Projet.objects.all()     to    projet =
> > > Projet.objects.filter(fact=None)
> > > it will send projet filtered as expected (all projects with no number
> > > assigned to the fact field) to template
> > > So the template display this as expected...
>
> > > Now, when I want to filter only projets with a assigned number to the
> > > fact field its return
>
> > > NameError at /facture/
> > > global name 'fact' is not defined
>
> > > Have i missed something?
> > > I'm used with this kind of operation with django , but right now I'm a
> > > bit lost...
>
> > > Thanks in advance
>
> > > Gregory Sémah

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



Re: Field exists but django tells me "is not defined"

2011-10-06 Thread gregory semah
Sorry my mistake again...

I mean when i write "Projet.objects.filter(fact!=None)" instead of
"Projet.objects.filter(fact=None)"

Thanks
>
>
>
>
>
>
> > Hi All,
>
> > I'm dealing with really weird problem
>
> > My model
> > class Projet(models.Model):
> >       ...
> >       fact = models.PositiveIntegerField('Numéro de
> > Facture',null=True,blank=True)
> >       ...
> >       ...
>
> > A simple view from this model is
> > def facture(request, id=None):
> >      projet = Projet.objects.all()
>
> > So as far as I am, everything worked as expected
> > Now I wanted to change
> > projet = Projet.objects.all()     to    projet =
> > Projet.objects.filter(fact=None)
> > it will send projet filtered as expected (all projects with no number
> > assigned to the fact field) to template
> > So the template display this as expected...
>
> > Now, when I want to filter only projets with a assigned number to the
> > fact field its return
>
> > NameError at /facture/
> > global name 'fact' is not defined
>
> > Have i missed something?
> > I'm used with this kind of operation with django , but right now I'm a
> > bit lost...
>
> > Thanks in advance
>
> > Gregory Sémah

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



Re: Field exists but django tells me "is not defined"

2011-10-06 Thread gregory semah
I mean when i write "Projet.objects.filter(fact!=None)" instead of
"Projet.objects.filter(fact!=None)"

The NameError appears

Thanks

On 6 oct, 13:54, gregory semah  wrote:
> Hi All,
>
> I'm dealing with really weird problem
>
> My model
> class Projet(models.Model):
>       ...
>       fact = models.PositiveIntegerField('Numéro de
> Facture',null=True,blank=True)
>       ...
>       ...
>
> A simple view from this model is
> def facture(request, id=None):
>      projet = Projet.objects.all()
>
> So as far as I am, everything worked as expected
> Now I wanted to change
> projet = Projet.objects.all()     to    projet =
> Projet.objects.filter(fact=None)
> it will send projet filtered as expected (all projects with no number
> assigned to the fact field) to template
> So the template display this as expected...
>
> Now, when I want to filter only projets with a assigned number to the
> fact field its return
>
> NameError at /facture/
> global name 'fact' is not defined
>
> Have i missed something?
> I'm used with this kind of operation with django , but right now I'm a
> bit lost...
>
> Thanks in advance
>
> Gregory Sémah

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



Field exists but django tells me "is not defined"

2011-10-06 Thread gregory semah
Hi All,

I'm dealing with really weird problem

My model
class Projet(models.Model):
  ...
  fact = models.PositiveIntegerField('Numéro de
Facture',null=True,blank=True)
  ...
  ...

A simple view from this model is
def facture(request, id=None):
 projet = Projet.objects.all()

So as far as I am, everything worked as expected
Now I wanted to change
projet = Projet.objects.all() toprojet =
Projet.objects.filter(fact=None)
it will send projet filtered as expected (all projects with no number
assigned to the fact field) to template
So the template display this as expected...

Now, when I want to filter only projets with a assigned number to the
fact field its return

NameError at /facture/
global name 'fact' is not defined

Have i missed something?
I'm used with this kind of operation with django , but right now I'm a
bit lost...


Thanks in advance

Gregory Sémah

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



cache_page: force reload

2011-10-06 Thread Thomas Guettler
Hi,

up to now cache_page ignores "pragma no-cache" (shift-ctrl-r in firefox).

I think this ticket should be looked at again:

https://code.djangoproject.com/ticket/10225#comment:5
Cache middleware does not honor "Cache-Control: no-cache" in request headers

{{{
A normal reload (F5 or ctrl-r) does not set the request header "Pragma: 
no-cache". Only shift-ctrl-r or ctrl-f5 sets it.
The current implementation (ignoring pragma no-cache) does not help you, if 
someone wants to bring your site down. I
think this is a valid ticket and pragma no-cache should not be ignored.

BTW, if you are a developer and want to force a reload, you can add a 
query-string:  http:///foo/?x

If you are afraid of denial of service attacks, an attacker could send you a 
different query-string in every request!
}}}

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



Re: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 10:09:05AM +0100, Cal Leeming [Simplicity Media Ltd] 
wrote:
>Chris -
>The only thing I can say, is that you've been given some really good
>advice on this thread so far.

Yes, I'm not complaining at all, the feedback has all been very helpful.
I'm just rather impatient when I start trying to use something new.  :-)

So, thank you everyone who has replied, I do appreciate all the help.

 and I will continue through the tutorials.  :-)

-- 
Chris Green

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



Re: Question about Signals : How to get the Primary Key Value ?

2011-10-06 Thread bino oetomo

On 10/06/2011 05:11 PM, Daniel Roseman wrote:


The instance is in, well, the `instance` argument. You get it from there.
--
DR.


Thankyou ...
I got it by ---> print obj.pk

Sincerely
-bino-

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



Re: weird behavoir of Excel

2011-10-06 Thread Cal Leeming [Simplicity Media Ltd]
Hi Patrick,

As a quick fix, you can put "=" at the start of each field, and it should
force the data to not 'auto format' (YMMV).

Cal

On Thu, Oct 6, 2011 at 10:13 AM, Szabo, Patrick (LNG-VIE) <
patrick.sz...@lexisnexis.at> wrote:

>  Hi, 
>
> ** **
>
> I’m creating an EXCEL-Sheet out of Django with the following code:
>
> ** **
>
> response = render_to_response(*'reportsexcel.html'*, {*'produkte'*:
> dict(buch_pool), *'gesamt_string'*:gesamt_string}
> ,context_instance=RequestContext(request))
>
> filename = *"report.xls"*
>
> response[*'Content-Disposition'*] = *'attachment; filename='*+filename
>
> response[*'Content-Type'*] = *'application/vnd.ms-excel; charset=utf-8'*
>
> * *
>
> This works fine for the most part but there is a strange behaviour that i
> don’t understand. 
>
> On the webpage i have a table that looks like this:
>
> ** **
>
> Produkt   10:20
>
> Produkt2 04:30
>
> ** **
>
> Now in EXCEL this becomes
>
> ** **
>
> Produkt   10:20:00
>
> Produkt2 04:30
>
> ** **
>
> This behaviour appears to be completely random.
>
> ** **
>
> Does anyone have an idea on how to controll this !?
>
> ** **
>
> I could create the sheet completly manual with xlwt but that seems a lot of
> coding for such a small task.
>
> ** **
>
> cheers
>
>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>
>  **
>
> Ing. Patrick Szabo
> XSLT Developer
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at
>
> Tel.: 00431 534521573
>
> Fax: +43 (1) 534 52 - 146
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django image upload

2011-10-06 Thread BILLION Sébastien

Hi,

http://www.nitinh.com/2009/02/django-example-filefield-and-imagefield/

It the same for ImageField

BILLION Sébastien

the Answer to the ultimate question of life, the universe and everything 
is 42


http://www.sebastienbillion.com/ 

Le 06/10/2011 05:22, Ian a écrit :

Hey Everyone,

I'm new to django, but I love it so far!

I'm trying to figure out how to upload an image (restrict it to images
only) and resave it as a different name.
Eventually, I'll want to upload it to S3, but for now, I'm just
testing it on my computer with runserver (so I'm not sure where it
should be saving it).

There are hundreds of tutorials for this online, but they are either
outdated or more complex than I'm looking for.

Right now, I have a template with the form in it.  I'm not sure where
to go from there.

Thanks so much!
Sorry if this question is too basic!



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



Re: Question about Signals : How to get the Primary Key Value ?

2011-10-06 Thread Daniel Roseman

On Thursday, 6 October 2011 10:10:09 UTC+1, bino wrote:
>
> Dear All ..
>
>  From the basic tutorial of "Polls",
> I add this lines to model.py
> START
> from django.db.models.signals import post_save
>
> def do_something(sender, **kwargs):
>  print "==START==="
>  print "Called by : " , sender
>  print "This is KWARGS :"
>  print kwargs
>  obj = kwargs['instance']
>  print "This is instances :"
>  print obj
>  print "=DONE"
>
> post_save.connect(do_something, sender=Poll)
> ---Stop--
>
> And from the debug console while I add a new record, here is what I got :
>
> ==START===
> Called by : 
> This is KWARGS :
> {'raw': False, 'signal':  0x8ddab6c>, 'instance': , 'created': True}
> This is instances :
> WhatsUp ?
> =DONE
>
> My question : How to het the primary key of involved object/instance 
> (the "id" Column in table) ?
> When I try to use --> print Poll.id
> It raise traceback that state (more/less) : Model 'Poll' have no object 
> named 'id'
>
> Kindly please give me your enlightment
>
> Sincerely
> -bino-
>

The instance is in, well, the `instance` argument. You get it from there.
--
DR. 

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



Re: Question about Signals : How to get the Primary Key Value ?

2011-10-06 Thread BILLION Sébastien

hi,

obj.id ?

BILLION Sébastien

the Answer to the ultimate question of life, the universe and everything 
is 42


http://www.sebastienbillion.com/ 

Le 06/10/2011 11:10, bino oetomo a écrit :

Dear All ..

From the basic tutorial of "Polls",
I add this lines to model.py
START
from django.db.models.signals import post_save

def do_something(sender, **kwargs):
print "==START==="
print "Called by : " , sender
print "This is KWARGS :"
print kwargs
obj = kwargs['instance']
print "This is instances :"
print obj
print "=DONE"

post_save.connect(do_something, sender=Poll)
---Stop--

And from the debug console while I add a new record, here is what I got :

==START===
Called by : 
This is KWARGS :
{'raw': False, 'signal': 0x8ddab6c>, 'instance': , 'created': True}

This is instances :
WhatsUp ?
=DONE

My question : How to het the primary key of involved object/instance 
(the "id" Column in table) ?

When I try to use --> print Poll.id
It raise traceback that state (more/less) : Model 'Poll' have no 
object named 'id'


Kindly please give me your enlightment

Sincerely
-bino-



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



weird behavoir of Excel

2011-10-06 Thread Szabo, Patrick (LNG-VIE)
Hi, 

 

I'm creating an EXCEL-Sheet out of Django with the following code:

 

response = render_to_response('reportsexcel.html', {'produkte':
dict(buch_pool), 'gesamt_string':gesamt_string}
,context_instance=RequestContext(request))

filename = "report.xls"

response['Content-Disposition'] = 'attachment; filename='+filename

response['Content-Type'] = 'application/vnd.ms-excel; charset=utf-8'

 

This works fine for the most part but there is a strange behaviour that
i don't understand. 

On the webpage i have a table that looks like this:

 

Produkt   10:20

Produkt2 04:30

 

Now in EXCEL this becomes

 

Produkt   10:20:00

Produkt2 04:30

 

This behaviour appears to be completely random.

 

Does anyone have an idea on how to controll this !?

 

I could create the sheet completly manual with xlwt but that seems a lot
of coding for such a small task.

 

cheers


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 





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



Question about Signals : How to get the Primary Key Value ?

2011-10-06 Thread bino oetomo

Dear All ..

From the basic tutorial of "Polls",
I add this lines to model.py
START
from django.db.models.signals import post_save

def do_something(sender, **kwargs):
print "==START==="
print "Called by : " , sender
print "This is KWARGS :"
print kwargs
obj = kwargs['instance']
print "This is instances :"
print obj
print "=DONE"

post_save.connect(do_something, sender=Poll)
---Stop--

And from the debug console while I add a new record, here is what I got :

==START===
Called by : 
This is KWARGS :
{'raw': False, 'signal': 0x8ddab6c>, 'instance': , 'created': True}

This is instances :
WhatsUp ?
=DONE

My question : How to het the primary key of involved object/instance 
(the "id" Column in table) ?

When I try to use --> print Poll.id
It raise traceback that state (more/less) : Model 'Poll' have no object 
named 'id'


Kindly please give me your enlightment

Sincerely
-bino-

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



Re: Beginner a bit lost - need some pointers please

2011-10-06 Thread Cal Leeming [Simplicity Media Ltd]
Chris -

The only thing I can say, is that you've been given some really good advice
on this thread so far.

These lists are really meant to be a "nudge in the right direction" rather
than a "fully fledged training experience" [1].

There are plenty of django projects on Github which show a fully working
project [2].

Once you've got your head around how Django works - one thing you might want
to consider would be posting your feedback here, and making suggestions on
how it could be improved.

Cal

[1] https://code.djangoproject.com/wiki/UsingTheMailingList
[2] https://github.com/akosma/django-blog-engine/

On Thu, Oct 6, 2011 at 10:00 AM, Chris G  wrote:

> On Thu, Oct 06, 2011 at 11:01:13AM +0530, kenneth gonsalves wrote:
> > On Wed, 2011-10-05 at 23:02 +0100, Chris G wrote:
> > > OK, so there isn't a single simple answer.  However it would still be
> > > really nice to see a complete two or three page django site with a
> > > database behind it fully implemented as an example.
> > >
> > >
> >
> > this is as simple as it gets
> > https://bitbucket.org/lawgon/django-addition/overview
>
> Too simple for me, it doesn't run.
>
>chris$ python manage.py runserver
>Error: No module named addition.addnums
>chris$
>
> My own working through the tutorial does though:-
>
>chris$ python manage.py runserver
>Validating models...
>0 errors found
>
>Django version 1.2.3, using settings 'djdb1.settings'
>Development server is running at http://127.0.0.1:8000/
>Quit the server with CONTROL-C.
>
>
> --
> Chris Green
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 01:14:37AM -0700, Daniel Roseman wrote:
>  On Wednesday, 5 October 2011 20:55:33 UTC+1, Chris Green wrote:
> 
>  I'm an experienced programmer (started around 1971 or so!) and I've done
>  lots of things over the years, much of my background is in Unix
>  (Solaris).
>  In the last few years I have done quite a lot of web related stuff.
> 
>  I'm trying to get my mind round django.  I have it installed on my
>  unbuntu server, it works, I've worked through tutorials 1 and 2 and a
>  bit of 3.  I can get the admin screens up and the basics of the polls
>  example work.
> 
>  However two rather basic things still elude me:-
> 
>  Where/how do I actually start creating the top level/page of a web
>  site?   Do I just open vi and create some HTML and embed django
>  code?  That seems unlikely but I can't see anywhere that tells me
>  what the code that creates a django site looks like and/or where it
>  resides.   An actual example of a two or three page working django
>  based web site would be a huge help.
> 
>You *really* need to do the tutorial. If you think that "creating HTML and
>embedding Django code" is how it works, then you haven't read it. That's
>not how it works at all.

I was semi joking, I realise that this *isn't* how it works but so far
I'm not at all clear how it does work.

-- 
Chris Green

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



Re: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 11:01:13AM +0530, kenneth gonsalves wrote:
> On Wed, 2011-10-05 at 23:02 +0100, Chris G wrote:
> > OK, so there isn't a single simple answer.  However it would still be
> > really nice to see a complete two or three page django site with a
> > database behind it fully implemented as an example.
> > 
> > 
> 
> this is as simple as it gets
> https://bitbucket.org/lawgon/django-addition/overview

Too simple for me, it doesn't run.

chris$ python manage.py runserver
Error: No module named addition.addnums
chris$ 

My own working through the tutorial does though:-

chris$ python manage.py runserver
Validating models...
0 errors found

Django version 1.2.3, using settings 'djdb1.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.


-- 
Chris Green

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



Re: Beginner a bit lost - need some pointers please

2011-10-06 Thread Kevin
For that it's worth, I deploy my Django projects using Nginx and
FastCGI.  I find this solution to be working rather nicely, Nginx
takes care of serving all the static content really fast and passes
the app requests to Django.  It's really quick and easy to set-up
too.  I prefer Nginx as I can better control what gets through from
the browser to the Django application.  Say, if I don't want some URLs
to accept POST data, or not pass certain header information.  I can
also use Nginx to graph apps from different frameworks together into
one domain name, I think Apache2 can do this as well.

On Oct 6, 3:14 am, Daniel Roseman  wrote:
> > On Wednesday, 5 October 2011 20:55:33 UTC+1, Chris Green wrote:
>
> I'm an experienced programmer (started around 1971 or so!) and I've done
>
>
>
>
>
>
>
>
>
> > lots of things over the years, much of my background is in Unix (Solaris).
> > In the last few years I have done quite a lot of web related stuff.
>
> > I'm trying to get my mind round django.  I have it installed on my
> > unbuntu server, it works, I've worked through tutorials 1 and 2 and a
> > bit of 3.  I can get the admin screens up and the basics of the polls
> > example work.
>
> > However two rather basic things still elude me:-
>
> >     Where/how do I actually start creating the top level/page of a web
> >     site?   Do I just open vi and create some HTML and embed django
> >     code?  That seems unlikely but I can't see anywhere that tells me
> >     what the code that creates a django site looks like and/or where it
> >     resides.   An actual example of a two or three page working django
> >     based web site would be a huge help.
>
> You *really* need to do the tutorial. If you think that "creating HTML and
> embedding Django code" is how it works, then you haven't read it. That's not
> how it works at all.
>
> If you want to see some working Django sites, look 
> athttp://www.djangosites.org/with-source/- but none of them will make much
> sense until you've got the basics.
>
> >     I can't see anywhere that seems to tell me the issues involved with
> >     moving from using the built in web server to using apache2 (or
> >     whatever, I have apache2 on my system).
>
> Don't worry about this yet. Learn Django first, then worry about deployment.
>
> --
> DR.
>
>
>
>
>
>
>
>

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



Re: Helping someone move from Joomla to Django

2011-10-06 Thread Kevin
I might say just 'WOW!'...  I just took some time to go over the
Joomla documentations to see what I was up against.  Why do developers
even use this thing?  Sure maybe the frontend is nice and polished,
but the backend looks horrible, at least compared to Django.  Django
code looks much more cleaner, and what's up with this statement at the
top of almost every page:



If I had to place that in all my source code, I'd go crazy!  You
shouldn't need to use such a thing in sane programming.

If you look at how they built their MVC implementation, it's rather
messy and very confusing.  On top of that, Django documentation and
tutorials are much more better organized.  I couldn't a non-HelloWorld
example, such as even a Poll example which Django uses.

The template system is not really a template system, but rather a hack
and uses PHP inline to implement functionality.  There appears to be
some template tags, but aren't compatible with web authoring software,
as the tag use < and >.

There doesn't seem to be an ORM of any kind, or lack thereof an
example for it.  The database example I stumbled upon in the
documentation uses RAW SQL code.  This can be prone to security issues
if not properly coded and filtered.

Django really needs to be advertised more, and perhaps an easier
method to deploy and manage templates/apps.  I can see how Joomla has
the community it has, installing templates and components(as they call
them) are very simple and mostly pain-free.

Does Django have an app which makes managing templates and apps and
the settings.py file easy for novice users?  I, myself am able to use
Django quite fully, but for new users who might be looking for an
alternative from other frameworks, should have a good solution for
this.

The ability for new developers to easily "dive in" and test drive
Django will be a nice bonus.  Given that a good chunk of the world
uses Windows on their desktop PCs, a nice easy way to get a Django
development environment up and running should be looked into.  I
recently found a nice website(which is no longer there),
instantdjango.com, they provided a nice self-extracting 7zip EXE file
with a contained django environment.  A batch file launched the
command prompt with the correct python environment variables set, it
was rather nice.  There needs to be an official django release of such
a development environment.  I still have a copy of the downloaded
environment if anybody wants to check it out/distribute it amongst
friends:

http://c18321.r21.cf1.rackcdn.com/django.exe

I can see plenty of users moving over to Django if they just saw how
much easier it is to code in Django.

On Sep 29, 4:42 am, Baurzhan Ismagulov  wrote:
> On Wed, Sep 28, 2011 at 11:19:30PM -0700, Derek wrote:
> > > How would you recommend I go about this task of moving my friend
> > > over to a Django/Python based system over a Joomla/PHP based system?
> ...
> > > He is requesting some other interesting features, which apparently
> > >someoneelse is working on implementing, and it's actually taking this
> > > other person a few days, or maybe weeks to add. Where I know I can
> > > implement it in Django in a matter of hours.
> ...
> > > What is everyone elses opinions on development in Django verses a
> > > rival CMS such as Joomla?
>
> If I had to add features or integrate stuff, I'd stay away from Joomla
> (or any heavyweight CMS like Zope / Plone, for that matter). Can you
> implement or at least prototype a few URLs in Django? In that way you
> could answer your question about templates and demonstrate the
> advantages to your friends.
>
> If you don't 
> succeed,http://groups.google.com/group/django-users/browse_thread/thread/4981...
> could be an option.
>
> With kind regards,
> --
> Baurzhan Ismagulovhttp://www.kz-easy.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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: post_add signal for non m2m

2011-10-06 Thread bino oetomo

On 10/06/2011 01:16 PM, bino oetomo wrote:

Dear All ..

I read https://docs.djangoproject.com/en/1.2/topics/signals/
Looks like there is no "post_add" signal can be catched by listener 
function.


Please ignore my previous post.
I found the solution here :
http://www.chrisdpratt.com/2008/02/16/signals-in-django-stuff-thats-not-documented-well/

I have another question, but I'll post in seperate thread

Thankyou

sincerely
-bino-

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



Re: Beginner a bit lost - need some pointers please

2011-10-06 Thread Daniel Roseman

>
> On Wednesday, 5 October 2011 20:55:33 UTC+1, Chris Green wrote:
>
I'm an experienced programmer (started around 1971 or so!) and I've done
> lots of things over the years, much of my background is in Unix (Solaris).
> In the last few years I have done quite a lot of web related stuff.
>
> I'm trying to get my mind round django.  I have it installed on my
> unbuntu server, it works, I've worked through tutorials 1 and 2 and a
> bit of 3.  I can get the admin screens up and the basics of the polls
> example work.
>
> However two rather basic things still elude me:-
>
> Where/how do I actually start creating the top level/page of a web
> site?   Do I just open vi and create some HTML and embed django
> code?  That seems unlikely but I can't see anywhere that tells me
> what the code that creates a django site looks like and/or where it
> resides.   An actual example of a two or three page working django
> based web site would be a huge help.
>

You *really* need to do the tutorial. If you think that "creating HTML and 
embedding Django code" is how it works, then you haven't read it. That's not 
how it works at all.

If you want to see some working Django sites, look at 
http://www.djangosites.org/with-source/ - but none of them will make much 
sense until you've got the basics.
 

> I can't see anywhere that seems to tell me the issues involved with
> moving from using the built in web server to using apache2 (or
> whatever, I have apache2 on my system).
>

Don't worry about this yet. Learn Django first, then worry about deployment.

--
DR.

>
>

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



Re: Report tool is supported for django .

2011-10-06 Thread Alexey Luchko

I need to make a report with django .
This report supports (chart , export PDF, Excell ...,)
please give me some recommendations with tool i must use for this case.


To produce printable reports, you can try 
http://pypi.python.org/pypi/PythonReports/.


--
Regards,
Alexey.

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



post_add signal for non m2m

2011-10-06 Thread bino oetomo

Dear All ..

I read https://docs.djangoproject.com/en/1.2/topics/signals/
Looks like there is no "post_add" signal can be catched by listener 
function.


Is that true ?
I need to do some jobs each time a record is added to a model.
This model is not m2m, it's just a parent or child of one-2-many model.
post_add will :  do a http GET call to kannel sendsms interface

How to achieve this ?

Kindly please give me your enlightment.

Sincerely
-bino-

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