Re: Image upload not working in newforms admin?

2008-05-17 Thread Graham Dumpleton

On May 17, 5:18 am, mw <[EMAIL PROTECTED]> wrote:
> I'm having nothing but tons of trouble right now with the image field
> upload.  I don't know what the problem is for sure, yet, but yeah I
> think that I'm willing to say that the ImageField isn't as easy to get
> working as it should be :-/
>
> I think my problem may be OS X related and having to do with OS X's
> Apache andmod_pythonbeing 64 bit while my PIL is something else, but
> I need to verify that PIL is, in fact, 32 bit still.

Determining if PIL .so is fully fat is easy, just use the 'file'
command on it.

So, find where PIL is installed, find the .so files in the package and
go:

  file *.so

If it is fully fat, you will get something like:

$ file /usr/libexec/apache2/mod_wsgi.so
/usr/libexec/apache2/mod_wsgi.so:   Mach-O universal binary
with 4 architectures
/usr/libexec/apache2/mod_wsgi.so (for architecture ppc7400): Mach-O
bundle ppc
/usr/libexec/apache2/mod_wsgi.so (for architecture ppc64): Mach-O 64-
bit bundle ppc64
/usr/libexec/apache2/mod_wsgi.so (for architecture i386): Mach-O
bundle i386
/usr/libexec/apache2/mod_wsgi.so (for architecture x86_64): Mach-O 64-
bit bundle

If you only see a line for i386, then only Intel 32 bit and would not
work on Intel 64 bit under Apache/mod_python/mod_wsgi.

For further related information see:

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

Graham

> On May 16, 1:06 pm, Brandon Taylor <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
>
> > I can't get the newforms admin to upload images. I have PIL and JPEG
> > support installed. My selftest on PIL reports that JPEG is supported,
> > along with PNG, but when I try to upload, I get:
>
> > Upload a valid image. The file you uploaded was either not an image or
> > a corrupted.
>
> > I can confirm that it *is* a JPEG, and it was working before I
> > switched to newforms-admin :)
>
> > Thoughts? Anyone experiencing something similar? I'm sure its a
> > problem with PIL and no Django, but have no clue as to where to start
> > to debug this.
>
> > TIA,
> > Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



FileField not working, however ImageField is.

2008-05-17 Thread Rodrigo Culagovski

I have a FileField in a model that's not working. When I try to upload
a file via the admin site, nothing is uploaded and I get a validation
error (as if I hadn't filled in the field). In the same application
but different model, I have ImageFields that work fine. I changed the
'upload_to' parameter to be the same as the ImageFields', in case
there was a permission or other file system problem with the directory
I was uploading to, but it still doesn't work.


Here's the model, the relevant field is "archivo". Using trunk.

is_texto = validators.RequiredIfOtherFieldEquals('tipo','Texto')
is_link = validators.RequiredIfOtherFieldEquals('tipo','Link')
is_archivo = validators.RequiredIfOtherFieldEquals('tipo','Archivo')

class Pagina(models.Model):
titulo = models.CharField(max_length=200)
bajada = models.TextField(blank=True)
cuerpo = models.TextField(validator_list=[is_texto], blank=True,
help_text="""necesario para tipo = 'Texto'""")
fecha_creacion = models.DateTimeField(auto_now_add=True)
fecha_modificacion = models.DateTimeField(auto_now=True)
tipo = models.CharField(max_length=200, choices = pagina_choices,
default = "Texto")
padre = models.ForeignKey('self', verbose_name="Subpágina de",
blank = True, null = True, related_name = 'subpaginas')
link = models.URLField(validator_list = [is_link], blank=True,
help_text = """necesario para tipo = 'Link'""")
archivo = models.FileField(upload_to = "articulos", validator_list
= [is_archivo], blank=True, help_text="""necesario para tipo =
'Archivo'""")
orden = models.IntegerField()
ruta = models.CharField(max_length=1000, editable = False)
color = models.CharField(max_length=100, choices = color_choices,
blank=True, validator_list=[is_root],
help_text="Sólo para páginas de nivel 1")
menu_principal = models.BooleanField(
blank=True,
help_text="Sólo para páginas de nivel 1")

def save(self):
super(Pagina, self).save()
self.ruta = self.root()
for subpage in self.subpaginas.all():
subpage.save()
super(Pagina, self).save()

def root(self):
if self.padre:
return self.padre.root() + "/" + slugger(self.titulo)
return slugger(self.titulo)



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



Re: sell dunk.gucci,prada,Adidas,rift,Puma,Gucci,Prada,Timberland.Ice,D,Adio,Armani,DC,ES,Lacoste,4US,Converse

2008-05-17 Thread BBNIKE


www.bbnike.com  ,We are a leading company that wholesales
shoes :Nike,Jordan,dunk,shox,max,air force
one,james,dunk.gucci,prada,Adidas,rift,Puma,Gucci,Prada,Timberland.Ice,D,Adio,Armani,DC,ES,Lacoste,
4US,Converse,bape.chanel,hongan,tods,richmond,eneruie,dsquared,diesel.armant,dior,ice
cream,kids shoes,women shoes,
jeans : bape,Diesel,Rock,Seven,red monkey,Evisu,lee,D,True
religion,bape,antik,jack
jones,armani,kepasa,apple,bbc,levi's,guess,cocobongo,only,replay,on
line,MNG hoodies,polo,red monkey,evsiu ,Richmond ,
clothes : lrg hoodies,face coat,ed hardy,prada
jackets,bbc,a,akademiks,hurberry,d,polo,rock rupblic,bape,NFL
jersey .NBA jersey ,MLB jersey ,NHL jersey ,lacoste
shirts,sweater,jacket lacoste hat, new are caps,glasses,and
ipod ,MP4,LV,GUCCI,Chanel,fendi ,bags.
If you want to order more newer products,Any question please feel
free

On May 18, 2:32 am, BBNIKE <[EMAIL PROTECTED]> wrote:
> www.bbnike.com ,We are a leading company that wholesales
> shoes :Nike,Jordan,dunk,shox,max,air force
> one,james,dunk.gucci,prada,Adidas,rift,Puma,Gucci,Prada,Timberland.Ice,D,­Adio,Armani,DC,ES,Lacoste,
> 4US,Converse,bape.chanel,hongan,tods,richmond,eneruie,dsquared,diesel.arman­t,dior,ice
> cream,kids shoes,women shoes,
> jeans : bape,Diesel,Rock,Seven,red monkey,Evisu,lee,D,True
> religion,bape,antik,jack
> jones,armani,kepasa,apple,bbc,levi's,guess,cocobongo,only,replay,on
> line,MNG hoodies,polo,red monkey,evsiu ,Richmond ,
> clothes : lrg hoodies,face coat,ed hardy,prada
> jackets,bbc,a,akademiks,hurberry,d,polo,rock rupblic,bape,NFL
> jersey .NBA jersey ,MLB jersey ,NHL jersey ,lacoste
> shirts,sweater,jacket lacoste hat, new are caps,glasses,and
> ipod ,MP4,LV,GUCCI,Chanel,fendi ,bags.
> If you want to order more newer products,Any question please feel free
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Latest IT Books

2008-05-17 Thread Dilani Reddy
   - Core Java 2 - Volume II - Advanced Features, 7th
E...
   - Creating Games In C++ - A Step By Step Guide
(2006...
   - Cryptography In C And C++
(2001)
   - Core Java 2 - Volume I - Fundamentals, 7th
Edition...
   - CSharp Cookbook, 2nd Edition
(2006)
   - CSS - The Missing Manual
(2006)
   - CSS - The Definitive Guide, 3rd Edition
(2006)
   - Computer Security Basics, 2nd Edition
(2006)
   - Cisco IOS Cookbook, 2nd Edition
(2006)
   - C By Example
(1999)
   - Building Secure Servers With Linux
(2002)
   - Applied C++ - Practical Techniques For Building
Be...
   - Auction Templates Starter Kit
(2006)
   - Adobe Photoshop CS2 Breakthroughs
(2005)
   - Adobe InDesign CS2 How-Tos - 100 Essential
Techniq...
   - Adobe Encore DVD 2.0 Classroom In A Book
(2006)
   - Access 2007 - The Missing Manual
(2006)
   - Absolute Beginner's Guide To Upgrading And Fixing
...
   - A Practical Guide To Linux Commands, Editors, And
...
   - 101 Reasons To Switch To The Mac
(2006)



-- 
Visit my site - Download Free Computer Books - An online Bookshelf

http://bookstube.blogspot.com
http://systemhelp4u.blogspot.com

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



Re: Caching: Memcached vs locmem

2008-05-17 Thread Brian

On May 17, 7:37 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I managed to get memcached up and running in about 5 minutes, so
> whilst it does involve more setup than locmem I wouldn't say it's
> difficult to the point of not being worth doing.

Thanks for that. I'll likely give it a try.

> Memcached is basically more efficient in general and supports
> clustering which makes it much better for scalability

But if you aren't clustering, say you have only a single server, is
there an advantage?

I turned on locmem today, but I don't think it is working. How can I
tell? I looked at my site with two browsers, one logged into admin,
and the other as anonymous. I made changes to the site as admin, and
the anonymous guy picked them up immediately.

Here are my settings:

CACHE_BACKEND = 'locmem:///?timeout=3600'
CACHE_MIDDLEWARE_SECONDS = 3600
CACHE_MIDDLEWARE_KEY_PREFIX = ''
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False

MIDDLEWARE_CLASSES = (
'django.middleware.cache.CacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching: Memcached vs locmem

2008-05-17 Thread [EMAIL PROTECTED]

I managed to get memcached up and running in about 5 minutes, so
whilst it does involve more setup than locmem I wouldn't say it's
difficult to the point of not being worth doing.

Memcached is basically more efficient in general and supports
clustering which makes it much better for scalability

On May 16, 8:20 pm, Brian <[EMAIL PROTECTED]> wrote:
> Can someone run down the differences between using Memcached vs
> locmem?
>
> The docs indicate Memcached is "the best" solution, but seems
> considerably harder to setup. Just curious what the trade-offs are.
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



10 Reasons why PCs crash

2008-05-17 Thread Dilani Reddy
10 Reasons why PCs crash 

Fatal error: the system has become unstable or is busy," it says. "Enter to
return to Windows or press Control-Alt-Delete to restart your computer. If
you do this you will lose any unsaved information in all open applications."

You have just been struck by the Blue Screen of Death. Anyone who uses Mcft
Windows will be familiar with this. What can you do? More importantly, how
can you prevent it happening? Click here To
Read

-- 
Visit my site - Download Free Computer Books - An online Bookshelf

http://bookstube.blogspot.com
http://systemhelp4u.blogspot.com

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



Re: Admin : Select category -> show subcategory

2008-05-17 Thread Diego Ucha

You need to set a Subcategory as default when this field is loaded by
the field Category?
Sorry Martyn, i didn't get your doubt, could you elaborate more?

On May 13, 2:23 am, martyn <[EMAIL PROTECTED]> wrote:
> It's true, I don't know for what reason I changed this before posting,
> but I've seen the error to, correct it and, no way.
> But I made a error on my urls,
> this /admin/boutique/produit/getsubcategory/ was not the same as
> urls.py, so I had no response.
>
> Now I've got another question. I've never used jQuery and I'm also new
> to django.
> I can't find the way to don't repeat my self on loading my object and
> show the subcategory with jQuery.
>
> On load
> 1- Load the results for the current category
> 2- Select the current subcategory
>
> 
> $(function(){
>   $("select#id_categorie").change(function(){
> $.getJSON("/admin/boutique/produit/getsubcategory/",{id: $
> (this).val()}, function(j){
>  var options = '';
>   for (var i = 0; i < j.length; i++) {
> options += '';
>   for (var i = 0; i < j.length; i++) {
> options += '

Accept paypal www tradertrade com supply nike jordan shoes airforce one shoes nike air max ltd 90 95 97 87 89 tnshoes

2008-05-17 Thread www.tradertrade.com

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



TypeError: Cannot resolve keyword 'slug' into field

2008-05-17 Thread Brian

I've searched for this, but people think it is either fixed or very
hard to reproduce. In my case it is 100% reproducible, and I wonder if
it is my own fault.

I have a model for a mp3 set (a set of mp3s). Individual mp3's are
associated with the set via a Foreign key.

I recently added a slug field to the mp3 after the fact, and I think I
have manually added it to the MySQL database to match what Django
thinks should be there. Now, when I try to edit a mp3 set in the admin
page and hit save, I always get:

TypeError at /django/admin/band/mp3_set/3/
Cannot resolve keyword 'slug' into field. Choices are: mp3, id, date,
title, text

Here are the models:

class Mp3_Set(models.Model):
   date = models.DateField(auto_now_add = True, editable = False)
   title = models.CharField(max_length = 64)
   text = models.TextField()

   def __unicode__(self):
  return self.title

   class Admin:
  list_filter = ('date', )
  list_display = ('title', 'date')

   class Meta:
  ordering = ('date', )
  verbose_name = "MP3 Set"

class Mp3(models.Model):
   mp3_set = models.ForeignKey(Mp3_Set, edit_inline = models.TABULAR,
num_in_admin = 5, num_extra_on_change = 5)
   title = models.CharField(max_length = 64, core = True)
   desc = models.CharField(max_length = 128, blank = True)
   file = models.FileField(upload_to = 'mp3s/%Y/%m/%d/')
   slug = models.SlugField(unique = True, prepopulate_from = ('title',
'desc'))

   def __unicode__(self):
  return self.title

   class Admin:
  pass

   class Meta:
  ordering = ('title', )
  verbose_name = "MP3"

And here is the export SQL for the two tables:

CREATE TABLE `band_mp3_set` (
  `id` int(11) NOT NULL auto_increment,
  `date` date NOT NULL,
  `title` varchar(64) collate latin1_general_ci NOT NULL,
  `text` longtext collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
AUTO_INCREMENT=4 ;

CREATE TABLE `band_mp3` (
  `id` int(11) NOT NULL auto_increment,
  `mp3_set_id` int(11) NOT NULL,
  `title` varchar(64) collate latin1_general_ci NOT NULL,
  `desc` varchar(128) collate latin1_general_ci NOT NULL,
  `file` varchar(100) collate latin1_general_ci NOT NULL,
  `slug` varchar(50) collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `band_mp3_slug` (`slug`),
  KEY `band_mp3_mp3_set_id` (`mp3_set_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
AUTO_INCREMENT=11 ;


Here is a trace back:
Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views
\decorators.py" in _checklogin
  62. return view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views
\main.py" in change_stage
  334. errors = manipulator.get_validation_errors(new_data)
File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in
get_validation_errors
  62. errors.update(field.get_validation_errors(new_data))
File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in
get_validation_errors
  379. self.run_validator(new_data, validator)
File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in
run_validator
  369. validator(new_data.get(self.field_name, ''),
new_data)
File "C:\Python25\Lib\site-packages\django\utils\functional.py" in
_curried
  55. return _curried_func(*(args+moreargs), **dict(kwargs,
**morekwargs))
File "C:\Python25\Lib\site-packages\django\db\models\fields
\__init__.py" in manipulator_validator_unique
  47. old_obj = self.manager.get(**{lookup_type: field_data})
File "C:\Python25\Lib\site-packages\django\db\models\manager.py" in
get
  69. return self.get_query_set().get(*args, **kwargs)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in get
  261. obj_list = list(clone)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
__iter__
  114. return iter(self._get_data())
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
_get_data
  486. self._result_cache = list(self.iterator())
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
iterator
  180. select, sql, params = self._get_sql_clause()
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
_get_sql_clause
  501. joins2, where2, params2 = self._filters.get_sql(opts)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
get_sql
  723. joins2, where2, params2 = val.get_sql(opts)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
get_sql
  774. return 

How does one use model data in forms?

2008-05-17 Thread Kenneth McDonald

For example, I want foreign keys to show up as popup lists. Also, I'd  
like to get the date widget in a user form the same as it is in the  
Admin interface. These are broad questions, so I guess the real  
question is, "Where do I read how to do this". Haven't found it in the  
book yet.

Thanks,
Ken

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



Re: Any examples of django order-processing systems out there?

2008-05-17 Thread Peter Rowell

You might want to look at Satchmo. I think it's at 0.7 right now.
http://groups.google.com/group/satchmo-users
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: loaddata .. columns app_label, model are not unique

2008-05-17 Thread Carl Karsten

patch submitted:

http://code.djangoproject.com/ticket/7254

Carl K

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



sell dunk.gucci,prada,Adidas,rift,Puma,Gucci,Prada,Timberland.Ice,D,Adio,Armani,DC,ES,Lacoste,4US,Converse

2008-05-17 Thread BBNIKE

www.bbnike.com  ,We are a leading company that wholesales
shoes :Nike,Jordan,dunk,shox,max,air force
one,james,dunk.gucci,prada,Adidas,rift,Puma,Gucci,Prada,Timberland.Ice,D,Adio,Armani,DC,ES,Lacoste,
4US,Converse,bape.chanel,hongan,tods,richmond,eneruie,dsquared,diesel.armant,dior,ice
cream,kids shoes,women shoes,
jeans : bape,Diesel,Rock,Seven,red monkey,Evisu,lee,D,True
religion,bape,antik,jack
jones,armani,kepasa,apple,bbc,levi's,guess,cocobongo,only,replay,on
line,MNG hoodies,polo,red monkey,evsiu ,Richmond ,
clothes : lrg hoodies,face coat,ed hardy,prada
jackets,bbc,a,akademiks,hurberry,d,polo,rock rupblic,bape,NFL
jersey .NBA jersey ,MLB jersey ,NHL jersey ,lacoste
shirts,sweater,jacket lacoste hat, new are caps,glasses,and
ipod ,MP4,LV,GUCCI,Chanel,fendi ,bags.
If you want to order more newer products,Any question please feel free
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Secure file access with contrib.auth

2008-05-17 Thread John Hensley

You can do this with Apache. You need to add mod_xsendfile 
(http://tn123.ath.cx/mod_xsendfile/ 
) to your Apache config, then control access to the files with a  
Django view. A quick search of this group turns up references to  
mod_xsendfile, but no example view, so here's what it might look like  
for your project:

@login_required
def sendfile(request, id):
 project_file = get_object_or_404(ProjectFile, id=id)

 if not (request.user.is_staff or request.user in  
project_file.project.members.all()):
 return HttpResponseForbidden('No. Sorry.')

 response = HttpResponse()
 response['X-Sendfile'] =  os.path.join(settings.MEDIA_ROOT,  
project_file.file)
 content_type, encoding =  
mimetypes.guess_type(project_file.get_file_url())
 if not content_type:
 content_type = 'application/octet-stream'
 response['Content-Type'] = content_type
 response['Content-Length'] = project_file.get_file_size()
 response['Content-Disposition'] = 'attachment; filename="%s"' %  
os.path.basename(project_file.get_file_url())
 return response

You get the idea.

The Apache config denies access to the upload subdirectory altogether;  
mod_xsendfile overrides that when it sees the X-Sendfile header in the  
response from the Django view. You get to use Django for the complex  
authorization, then it lets Apache handle the grunt work of shipping  
the file. Pretty nice; I thought this might have been the requirement  
that finally pushed me over to nginx or lighty, but not yet

John

On May 15, 2008, at 7:38 PM, Julien wrote:

>
> Hi,
>
> I'm building a website where users can create projects and upload
> files for their projects. I already have a system in place so that
> only members of a project can access the project related pages. Now,
> I'd like it to be more secure by only giving access to the files of a
> project to its members.
>
> It appears to me that simply serving the files with Apache is not
> enough. Does Django provide a way to achieve that? Does it mean I'll
> have to serve the files with 'static.serve' with a layer of
> authorization checking?
>


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



Re: How best to place multiple orders from same screen?

2008-05-17 Thread John Hensley

Malcolm has a good how-to for this:

http://www.pointy-stick.com/blog/2008/01/06/django-tip-complex-forms/

On May 17, 2008, at 12:16 PM, Kenneth McDonald wrote:

> I'm designing an order system wherein each order will be an object.
> However, most customers will typically want to order more than one
> thing at once. To make things easier for the user, I'd like to allow
> them to enter, say, up to 5 orders on the same screen. Each order will
> then be stored as a record in the database.


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



Any examples of django order-processing systems out there?

2008-05-17 Thread Kenneth McDonald

Just wondering, it's always nice to see how others have done things.

Thanks,
Ken

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



How best to place multiple orders from same screen?

2008-05-17 Thread Kenneth McDonald

I'm designing an order system wherein each order will be an object.  
However, most customers will typically want to order more than one  
thing at once. To make things easier for the user, I'd like to allow  
them to enter, say, up to 5 orders on the same screen. Each order will  
then be stored as a record in the database.

I'm wondering the best way to do this. My guess right now is to have a  
custom view that has the necessary logic, but I'm also a complete  
newbie at Django, so any better suggestions would be most appreciated.

Thanks,
Ken

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



Re: How to use a string in filter()

2008-05-17 Thread M.Ganesh

caustic wrote:
>
> On May 17, 9:13 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
>   
>> Hi All,
>>
>> I am back with another query
>>
>> I have this (generic) view function
>>
>> --8><
>> def object_list(request, object, filter_string = None):
>> if filter_string:
>> object_list = object.objects.filter(filter_string)
>> else:
>> object_list = object.objects.all()
>>
>> return render_to_response(object.__name__ + '_list.html',
>>   {object.__name__ + '_list': object_list},
>>   RequestContext(request))
>> --8><
>>
>> Now this function works when I don't pass on the filter_string, and I
>> get the entire object list. But when I pass on a value for filter_string
>> (say 'entity=2') I get this error :
>>
>> 'unicode' object has no attribute 'get_sql'
>>
>> How do I pass strings to filter_string and get a filtered object list?
>> 
> You cannot. You should pass either an instance of django.db.models.Q
> or a set of keyword arguments.
> This means you should change code in the object_list caller to do
> something like this:
>
> object_list(request, model.Object, Q(entity=2))
>   
Hmm. I'll have to read about Q objects...

Thanks for the pointer

Regards Ganesh


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



Re: Setting up multiple sites

2008-05-17 Thread Horst Gutmann

You could still connect to the same database from both sites but
distinct the content that should *not* be shared using a site_id. For
stuff like that the django.contrib.sites framework should be quite
useful :-)

http://www.djangoproject.com/documentation/sites/

- Horst

On Sat, May 17, 2008 at 3:41 PM, Greg Lindstrom <[EMAIL PROTECTED]> wrote:
> I am ready to deploy my first Django site on the web and am looking at
> starting another.  Are there any collective thoughts on whether I
> should add the new app to my existing Django project or start an
> entire new project?  I don't want to get site data mixed together, but
> I will have a number of common tables and methods ("Person", and
> "Address" come to mind).  I figure I could have different entries for
> each site in my urls.py file and then simply install what I would need
> for a particular site.  I have not figured out how to handle the
> "models" and "Views" files.
>
> Is it simply better to have separate projects?
>
> Thanks,
> --greg
>
> >
>

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



Re: Problems with generic.GenericForeignKey()

2008-05-17 Thread Josh

Ah, I see. Thanks, I'll give that a shot.

On Mar 28, 6:52 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Mar 28, 9:16 pm, Josh <[EMAIL PROTECTED]> wrote:
>
> > I've determined that the problem is with the get(). If I just create
> > the objects without first checking to see if it already exists,
> > there's no problem.
>
> > So I guess my question is now this: what's the best way to avoid
> > duplicates here?
>
> You can't use the dynamically-generated content_object field as a
> lookup. However, you can use content_type and object_id, since these
> are explicitly declared in your model. So something like this will
> work:
>
> model = ContentType.objects.get_for_model(match)
> obj = WordedItem.objects.get(content_type=model, object_id=match.id,
> word=word)
>
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



hasNoProfanities doesn't work

2008-05-17 Thread Dan Kelley

Hi.  I'm using the latest development version (svn'd today).

I think I'm missing something on hasNoProfanities.  I have the following in
my model:


from django.core import validators
...
content = models.TextField(validator_list=[validators.hasNoProfanities])


and in my settings.py file I have

PROFANITIES_LIST = (...) # I have not shown the words here, to avoid
spreading profanities


but when I use the site, with profane words, nothing happens.  Do I have to
do something extra?  (Should I do a manual call to the validator somehow,
e.g. after cleaning the data?)

I'm sorry to post a newbie question.  I guess the thing is that I don't
really know how to use *any* validator.
-- 
View this message in context: 
http://www.nabble.com/hasNoProfanities-doesn%27t-work-tp17291988p17291988.html
Sent from the django-users mailing list archive at Nabble.com.

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



Setting up multiple sites

2008-05-17 Thread Greg Lindstrom

I am ready to deploy my first Django site on the web and am looking at
starting another.  Are there any collective thoughts on whether I
should add the new app to my existing Django project or start an
entire new project?  I don't want to get site data mixed together, but
I will have a number of common tables and methods ("Person", and
"Address" come to mind).  I figure I could have different entries for
each site in my urls.py file and then simply install what I would need
for a particular site.  I have not figured out how to handle the
"models" and "Views" files.

Is it simply better to have separate projects?

Thanks,
--greg

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



Re: How to add an object with relations to other objects

2008-05-17 Thread Richard Dahl

You can always just pass the id of A into the template for creating  
the B and have it submitted along with the form.  Then after you save  
the B you will have to get the A and save the instance of B to its  
relation.
-richard


On May 17, 2008, at 3:02 AM, jabbercat wrote:

>
> Hello,
>
> the answer for question 1 I already find out, thank you.
>
> According to question 2, I'm not meaning without a relation between A
> and B. There must be a relation between them. So I describe my problem
> again in a more understandable way, I hope.
>
> I have two models A and B with an one(A)-to-many(B) relationship.
>
> So I want to build a view for adding a B, which is related to a A. For
> that I have a link in another view. That Link contains the ID of A. So
> in the new view I knew the ID of A, which should be related with the
> new B. How I get B related with A? (Ok, by setting the attribute,
> but...) How can I do that by using form_for_model() according to my
> database model? The User don't have the choice to manipulate the ID of
> A or something like that. There shouldn't be a field for the ID!
>
> On 16 Mai, 22:52, "Richard Dahl" <[EMAIL PROTECTED]> wrote:
>> For the first question, the db-api doc should provide this and more
>> information, as I am not sure I completely understand, but here goes
>> (assuming the following models):
>>
>> class B(models.Model):
>>attribute = char()...
>>
>> class A(models.Model):
>>attribute = char()...
>>bs = m2m(B)
>>
>> in your view to get all of the B(s) related to a given A
>>
>> a = A.objects.get(pk=1)
>> b = a.bs.all()
>>
>> if you want to get all of the Bs that are related to 'any' A:
>> b = B.objects.filter(a__isnull = False)
>>
>> for question 2, I am not sure what you mean, if you mean can you  
>> create a B
>> without relating it to an A? sure, a related A is not required by  
>> B.  If you
>> do not want to require a B for A just set 'blank=True, null=True'  
>> in the M2M
>> field definition in A.
>>
>> Not sure if this helps, your original post was somewhat confusing,  
>> if you
>> post relevant snippets from your models you may get more intelligent
>> responses than my intellectual meanderings.
>> -richard
>>
>> On 5/16/08, jabbercat <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>
>>
>>
>>
>>> Hello,
>>
>>> it's my frist time I'm using this Group.
>>
>>> My Problems:
>>> I have a class A and a class B with a one(A)-to-many(B) relationship
>>> between them.
>>
>>> My first question: Is there an efficient way to get in a template  
>>> all
>>> instances of B, which are related to an instance of A, when i only
>>> knew an instance of A? Something like a special attribute, or
>>> something like that?
>>
>>> My second question: I want to use form_for_model(), because of my
>>> database-driver design. But how can I add an instance of B so that  
>>> the
>>> relation to an instance of A is also saved, without specify the
>>> foreign key id of A explicitly?
>>
>>> I hope you understand what I meen.
> >


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



Re: How to use a string in filter()

2008-05-17 Thread caustic



On May 17, 9:13 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am back with another query
>
> I have this (generic) view function
>
> --8><
> def object_list(request, object, filter_string = None):
> if filter_string:
> object_list = object.objects.filter(filter_string)
> else:
> object_list = object.objects.all()
>
> return render_to_response(object.__name__ + '_list.html',
>   {object.__name__ + '_list': object_list},
>   RequestContext(request))
> --8><
>
> Now this function works when I don't pass on the filter_string, and I
> get the entire object list. But when I pass on a value for filter_string
> (say 'entity=2') I get this error :
>
> 'unicode' object has no attribute 'get_sql'
>
> How do I pass strings to filter_string and get a filtered object list?
You cannot. You should pass either an instance of django.db.models.Q
or a set of keyword arguments.
This means you should change code in the object_list caller to do
something like this:

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



Getting FK-Value without knowing the name of the field

2008-05-17 Thread mwebs

Hello,

I need something like this:

modelObject.fk// returns the FK-value of the modelObject


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



Re: Dynamic lookup

2008-05-17 Thread mwebs

Thank you Scott and Ronny!

This was a great help.

On 17 Mai, 13:20, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote:
> On Sat, May 17, 2008 at 6:11 PM, mwebs <[EMAIL PROTECTED]> wrote:
> > I am using something like this:
>
> > model.objects.filter(field = variable)
>
> > Is it possible to pass the field that is used for the lookup
> > dynamically, so that field is also a variable ?
>
> It's python kwargs (keyword arguments). You can do this:
>
> dictionary = {field1: val1, field2: val2}
> model.objects.filter(**dictionary)
>
> Ronny
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic lookup

2008-05-17 Thread Ronny Haryanto

On Sat, May 17, 2008 at 6:11 PM, mwebs <[EMAIL PROTECTED]> wrote:
> I am using something like this:
>
> model.objects.filter(field = variable)
>
> Is it possible to pass the field that is used for the lookup
> dynamically, so that field is also a variable ?

It's python kwargs (keyword arguments). You can do this:

dictionary = {field1: val1, field2: val2}
model.objects.filter(**dictionary)

Ronny

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



Re: Dynamic lookup

2008-05-17 Thread Scott Moonen
Toni, you can do this, for example:

fieldname1 = "field"
fieldname2 = "field2__ge"
model.objects.filter(**{ fieldname : variable, fieldname2 : variable2})

  -- Scott

On Sat, May 17, 2008 at 7:11 AM, mwebs <[EMAIL PROTECTED]> wrote:

>
> Hello,
>
> I am using something like this:
>
> model.objects.filter(field = variable)
>
> Is it possible to pass the field that is used for the lookup
> dynamically, so that field is also a variable ?
>
> Thanks, Toni
> >
>


-- 
http://scott.andstuff.org/  |  http://truthadorned.org/

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



Dynamic lookup

2008-05-17 Thread mwebs

Hello,

I am using something like this:

model.objects.filter(field = variable)

Is it possible to pass the field that is used for the lookup
dynamically, so that field is also a variable ?

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



Re: ForeignKey information at runtime

2008-05-17 Thread mwebs

I found the soultion:

news._meta.fields[x].get_internal_type()

this returns 'ForeignKey' if the field is a FK.



On 17 Mai, 12:06, mwebs <[EMAIL PROTECTED]> wrote:
> Thank you,
>
> thats exactly what I was looking for.
> But how can I test if a field is a ForeignKey?
>
> On 17 Mai, 11:01, Matthias Kestenholz <[EMAIL PROTECTED]> wrote:
>
> > On Sat, 2008-05-17 at 00:59 -0700, mwebs wrote:
> > > Hi,
>
> > > is there any possibility to get the field from a model instance that
> > > speciefies a foreignkey-relationship.
>
> > > something like this:
>
> > > news.__foreignKey__   # returns 'category'
>
> > Just inspect news._meta.fields, you'll find what you need there.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ForeignKey information at runtime

2008-05-17 Thread mwebs

Thank you,

thats exactly what I was looking for.
But how can I test if a field is a ForeignKey?

On 17 Mai, 11:01, Matthias Kestenholz <[EMAIL PROTECTED]> wrote:
> On Sat, 2008-05-17 at 00:59 -0700, mwebs wrote:
> > Hi,
>
> > is there any possibility to get the field from a model instance that
> > speciefies a foreignkey-relationship.
>
> > something like this:
>
> > news.__foreignKey__   # returns 'category'
>
> Just inspect news._meta.fields, you'll find what you need there.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ForeignKey information at runtime

2008-05-17 Thread Matthias Kestenholz

On Sat, 2008-05-17 at 00:59 -0700, mwebs wrote:
> Hi,
> 
> is there any possibility to get the field from a model instance that
> speciefies a foreignkey-relationship.
> 
> something like this:
> 
> news.__foreignKey__   # returns 'category'

Just inspect news._meta.fields, you'll find what you need there.

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



Re: Add column to generated ManyToMany table and access from admin

2008-05-17 Thread Russell Keith-Magee

On Sat, May 17, 2008 at 2:19 AM, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> However, I would really like to add a column to the join table,
> "order", so I can use the admin of my Page class to add Items and
> define their order on that particular page. Is there a way to do this?

At present, this isn't possible. However, it is the subject of ticket
#6095, which is under development. This includes some support for
editing in the admin, but if you read the comments associated with
that ticket, you'll find that there are some difficulties associated
with the problem.

[1] http://code.djangoproject.org/ticket/6095

Yours,
Russ Magee %-)

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



Re: Problem with : Updating multiple objects at once

2008-05-17 Thread Russell Keith-Magee

On Sat, May 17, 2008 at 12:10 AM, mwebs <[EMAIL PROTECTED]> wrote:
>
> News.objects.filter(sequence__gt =  msequence).update(sequence =
> sequence-1)
...
> Is there any possibility to solve this problem without iterating over
> all results with News.objects.filter(sequence__gt =  msequence) and
> setting the new sequence manually in each iteration?

At present, there is no way to do internal references like this (i.e.,
build a query based on other fields in the same query). There have
been some suggestions on how this might be implemented, but in the
meantime, the only solution is to use a raw SQL query.

Yours,
Russ Magee %-)

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



Re: How to add an object with relations to other objects

2008-05-17 Thread jabbercat

Hello,

the answer for question 1 I already find out, thank you.

According to question 2, I'm not meaning without a relation between A
and B. There must be a relation between them. So I describe my problem
again in a more understandable way, I hope.

I have two models A and B with an one(A)-to-many(B) relationship.

So I want to build a view for adding a B, which is related to a A. For
that I have a link in another view. That Link contains the ID of A. So
in the new view I knew the ID of A, which should be related with the
new B. How I get B related with A? (Ok, by setting the attribute,
but...) How can I do that by using form_for_model() according to my
database model? The User don't have the choice to manipulate the ID of
A or something like that. There shouldn't be a field for the ID!

On 16 Mai, 22:52, "Richard Dahl" <[EMAIL PROTECTED]> wrote:
> For the first question, the db-api doc should provide this and more
> information, as I am not sure I completely understand, but here goes
> (assuming the following models):
>
> class B(models.Model):
> attribute = char()...
>
> class A(models.Model):
> attribute = char()...
> bs = m2m(B)
>
> in your view to get all of the B(s) related to a given A
>
> a = A.objects.get(pk=1)
> b = a.bs.all()
>
> if you want to get all of the Bs that are related to 'any' A:
> b = B.objects.filter(a__isnull = False)
>
> for question 2, I am not sure what you mean, if you mean can you create a B
> without relating it to an A? sure, a related A is not required by B.  If you
> do not want to require a B for A just set 'blank=True, null=True' in the M2M
> field definition in A.
>
> Not sure if this helps, your original post was somewhat confusing, if you
> post relevant snippets from your models you may get more intelligent
> responses than my intellectual meanderings.
> -richard
>
> On 5/16/08, jabbercat <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > it's my frist time I'm using this Group.
>
> > My Problems:
> > I have a class A and a class B with a one(A)-to-many(B) relationship
> > between them.
>
> > My first question: Is there an efficient way to get in a template all
> > instances of B, which are related to an instance of A, when i only
> > knew an instance of A? Something like a special attribute, or
> > something like that?
>
> > My second question: I want to use form_for_model(), because of my
> > database-driver design. But how can I add an instance of B so that the
> > relation to an instance of A is also saved, without specify the
> > foreign key id of A explicitly?
>
> > I hope you understand what I meen.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ForeignKey information at runtime

2008-05-17 Thread mwebs

Hi,

is there any possibility to get the field from a model instance that
speciefies a foreignkey-relationship.

something like this:

news.__foreignKey__   # returns 'category'


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



Re: Get table name at runtime

2008-05-17 Thread mwebs

Perfect!

that is what I was searching for!!!
Thanks, Toni

On 17 Mai, 09:50, Matthias Kestenholz <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On Sat, 2008-05-17 at 00:44 -0700, mwebs wrote:
> > Hi,
>
> > is there any possibility to get the db table name of a model instance
> > at runtime
> >  (news.get_table_name())?
>
> Yes:
> News._meta.db_table and news_object._meta.db_table both work.
>
> I think that _meta is an implementation detail however, therefore I
> don't know if you can rely on the _meta attribute. I don't see a reason
> why it should go away or be renamed however, so you are probably safe
> using it.
>
> --http://spinlock.ch/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Get table name at runtime

2008-05-17 Thread Matthias Kestenholz

Hi,

On Sat, 2008-05-17 at 00:44 -0700, mwebs wrote:
> Hi,
> 
> is there any possibility to get the db table name of a model instance
> at runtime
>  (news.get_table_name())?

Yes:
News._meta.db_table and news_object._meta.db_table both work.

I think that _meta is an implementation detail however, therefore I
don't know if you can rely on the _meta attribute. I don't see a reason
why it should go away or be renamed however, so you are probably safe
using it.

-- 
http://spinlock.ch/blog/

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



Get table name at runtime

2008-05-17 Thread mwebs

Hi,

is there any possibility to get the db table name of a model instance
at runtime
 (news.get_table_name())?


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



How to add custom user fields to UserCreationForm?

2008-05-17 Thread matimba



I am already using UserCreationForm in my view to register users --
all OK.
Now I want to add  custom user fields  in my Profile model to my
registration form.
I already created a Profile model linked and linked it to User model.

What do I need to do to get the Profile fields in my template?

Below for relevant code (all working -- except I can't get my Profile
model.

What do I need to change in my view and/or template?

Many Thanks
Liam





### model ###

from django.contrib.auth.models import User

class Profile(models.Model):
user = models.ForeignKey(User, unique=True)
location  = models.CharField(max_length=60)


### view ###

def signup(request):
form = UserCreationForm()
if request.method == 'POST':
data = request.POST.copy()# comment is available here
#debug.on
errors = form.get_validation_errors(data)
if not errors:
# save the new user
new_user = form.save(data)
username = request.POST['username']
password = request.POST['password1']
new_user = auth.authenticate(username=username,
password=password)
auth.login(request, new_user)
return HttpResponseRedirect("/update_success/")
else:
data, errors = {}, {}
form = oldforms.FormWrapper(form, data, errors)
return render_to_response("registration/register.html",{'form' :
form})


### register.html ###

{% extends "base.html" %}

{% block title %}{% endblock %}


{% block content %}



  Create an account
  
{% if form.error_dict %}
  Please correct the errors below.
{% endif %}

{% if form.username.errors %}
  {{ form.username.html_error_list }}
{% endif %}
Username: {{ form.username }}

{% if form.password1.errors %}
  {{ form.password1.html_error_list }}
{% endif %}
Password: {{ form.password1 }}

{% if form.password2.errors %}
  {{ form.password2.html_error_list }}
{% endif %}
Password (again):
{{ form.password2 }}

comment: {{ form2.comment }}


  

{% endblock %}

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



Integrating plug-in with stand-alone site.

2008-05-17 Thread LMZ

Having a plug-in, want to write some code for that plug-in, that can
help simple, flexible future integration with some stand-alone django
site.

Under term "Integrating" I mean, first of all "User authentication/
registration/management"

my thoughts:
create

from django.contrib.auth.models import User
class PluginProfile(User):
[...]

and in that model add necessary plug-in fields. Also create a set of
decorators like @login_required, to grant/denied access to different
views.

How would you do that?

Cheers, Alexandr.


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



Re: How does one express that a primary key is made of a combination of _two_ fields?

2008-05-17 Thread Matthias Kestenholz

Hi Ken,

On Sat, 2008-05-17 at 01:38 -0500, Kenneth McDonald wrote:
> Just as the subject says, nothing more to ask :-)
> 

Short answer: You don't.

Longer answer:
http://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys

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



Re: Problem with abstract model class

2008-05-17 Thread Matthias Kestenholz

On Fri, 2008-05-16 at 14:51 -0700, Legioneer wrote:
> It looks that this is not the case. The problem seems to be more
> general. When I add abstract=True to ANY model I receive the same
> error. Example:
> 
> class OrderItem(models.Model):
> num = models.IntegerField(default=1)
> timestamp = models.DateTimeField(auto_now=True)
> 
> class Meta:
> abstract = True
> 

%s(class)s will not do what you want:

>>> '%s(class)s' % {'class': 'WhatEver'}
"{'class': 'WhatEver'}(class)s"
>>> '%(class)s' % {'class': 'WhatEver'}
'WhatEver'


Are you sure your django version is recent enough? The queryset-refactor
branch merge did not happen a long time ago, an old subversion checkout
or even a released django version (f.e. 0.96.1) won't do.


-- 
http://spinlock.ch/blog/

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



How does one express that a primary key is made of a combination of _two_ fields?

2008-05-17 Thread Kenneth McDonald

Just as the subject says, nothing more to ask :-)

Thanks,
Ken



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