Re: Django ORM - query help

2012-04-11 Thread Jani Tiainen

11.4.2012 23:47, David kirjoitti:

Thanks for your reply. I am grateful for your help. If you remember this 
question when you feel less sleepy I'd be very interested to see the inner join 
alternative :)

Thanks again



Well, after good night sleep I've some idea.

Something like should do the trick:

Log.objects.values('thing').annotate(deletion_date=Max('modified_on')).order_by('-deletion_date')

--

Jani Tiainen

--
You received this message because you are subscribed to the Google 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: ecommerce like openCart in php

2012-04-11 Thread Eugene MechanisM
I would recommend this shop http://tangentlabs.github.com/django-oscar/

четверг, 12 апреля 2012 г., 2:34:07 UTC+4 пользователь randa hisham написал:
>
>
> iam searching for an ecommerce  open source like OpenCart in php 
> -  - 
> Randa Hesham
> Software Developer
>
> Twitter:@ro0oraa 
> FaceBook:Randa Hisham 
>
> ٍ
>
> 

-- 
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/-/Qtw1T16F2WMJ.
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: ecommerce like openCart in php

2012-04-11 Thread Eugene MechanisM
https://github.com/RaD/dishop

четверг, 12 апреля 2012 г., 2:34:07 UTC+4 пользователь randa hisham написал:
>
>
> iam searching for an ecommerce  open source like OpenCart in php 
> -  - 
> Randa Hesham
> Software Developer
>
> Twitter:@ro0oraa 
> FaceBook:Randa Hisham 
>
> ٍ
>
> 

-- 
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/-/TMUAQ2LtgoYJ.
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: ecommerce like openCart in php

2012-04-11 Thread Timothy Makobu
Have a look around here http://djangopackages.com/grids/g/ecommerce/


On Thu, Apr 12, 2012 at 3:46 AM, Alec Taylor  wrote:

> [Maybe] Mezzanine?
>
> On Thu, Apr 12, 2012 at 10:35 AM, m1chael  wrote:
> > i think you're barking up the wrong tree miss Hisham
> >
> > On Wed, Apr 11, 2012 at 6:34 PM, Randa Hisham 
> wrote:
> >>
> >> iam searching for an ecommerce  open source like OpenCart in php
> >> -  -
> >> Randa Hesham
> >> Software Developer
> >>
> >> Twitter:@ro0oraa
> >> FaceBook:Randa Hisham
> >>
> >> ٍ
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> 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.
> >
>
> --
> You received this message because you are subscribed to the Google 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: ecommerce like openCart in php

2012-04-11 Thread Alec Taylor
[Maybe] Mezzanine?

On Thu, Apr 12, 2012 at 10:35 AM, m1chael  wrote:
> i think you're barking up the wrong tree miss Hisham
>
> On Wed, Apr 11, 2012 at 6:34 PM, Randa Hisham  wrote:
>>
>> iam searching for an ecommerce  open source like OpenCart in php
>> -  -
>> Randa Hesham
>> Software Developer
>>
>> Twitter:@ro0oraa
>> FaceBook:Randa Hisham
>>
>> ٍ
>>
>> --
>> You received this message because you are subscribed to the Google 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.
>

-- 
You received this message because you are subscribed to the Google 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: ecommerce like openCart in php

2012-04-11 Thread m1chael
i think you're barking up the wrong tree miss Hisham

On Wed, Apr 11, 2012 at 6:34 PM, Randa Hisham  wrote:
>
> iam searching for an ecommerce  open source like OpenCart in php
> -  -
> Randa Hesham
> Software Developer
>
> Twitter:@ro0oraa
> FaceBook:Randa Hisham
>
> ٍ
>
> --
> You received this message because you are subscribed to the Google 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: PostgreSQL Introspection Bug

2012-04-11 Thread akaariai
On Apr 11, 4:39 pm, Thomas Guettler  wrote:
> I fixed a postgreSQL introspection bug, but unfortunately it is still in 
> stage "new".
>
> Can someone please review it?
>
>    https://code.djangoproject.com/ticket/17785

I hope to find time to look at this. No promises, but added to my
rather long TODO list...

 - Anssi

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



ecommerce like openCart in php

2012-04-11 Thread Randa Hisham
iam searching for an ecommerce  open source like OpenCart in php
-  -
Randa Hesham
Software Developer

Twitter:@ro0oraa 
FaceBook:Randa Hisham 

ٍ

-- 
You received this message because you are subscribed to the Google 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: Is it a good practice to delegate views based on GET / POST?

2012-04-11 Thread John Yeukhon Wong
Thanks to both of you. Kevin, how would I do a regex mask for views?

Thanks.

On Wednesday, April 11, 2012 2:05:27 AM UTC-4, Kevin wrote:
>
> Separating GET and POST is normally used for RESTful web programming.  
> Which is becoming a very common practice is popular competing frameworks, 
> such as Rails.
>
> Personally I would prefer a more "native" way in Django to separate 
> GET/POST views.  I guess this could be done via a decorator or something.
>
> Another reason you may want to separate GET/POST is for security.  For 
> example, only letting some views accept POST requests, and basically shove 
> a big 403 message to users who attempt to POST to a view which otherwise 
> shouldn't accept a POST.  I normally limit this using the web server, so 
> POST requests will not even reach the web application if the component 
> doesn't even accept it.  I always have a mind set that the Internet is 
> never safe, and everybody is a hacker.  It's better to be safe, than sorry 
> that a malicious POST body reached your application.  An easy way to do 
> this on the server is to use a regex mask for views which will accept a 
> POST body, such as having an extension of ".do" or ".action".  If the view 
> doesn't have this special extension, then only allow GET requests to pass 
> through to WSGI.  You can also filter out headers and such on the server to 
> further protect your WSGI application from the outside world.  If you don't 
> have access to the server's configuration, well, then I'm sure the cloud 
> service you deployed to is "safe enough".
>
> On Tuesday, 10 April 2012 18:21:15 UTC-5, John Yeukhon Wong wrote:
>>
>> 3/4 down the page
>> http://www.djangobook.com/en/2.0/chapter08/
>>
>> urlpatterns = patterns('', # ... (r'^somepage/$', views.method_splitter, 
>> {'GET': views.some_page_get, 'POST': views.some_page_post}), # ... )
>>
>>
>> Is this a good practice at all? If I use the method splitter, my urls 
>> will look ugly. Or should I just separate based on the length of certain 
>> views? (If it's too long, break it into two, or use the delegator)
>>
>

-- 
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/-/AdCV-UuVdKIJ.
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 ORM - query help

2012-04-11 Thread David
Thanks for your reply. I am grateful for your help. If you remember this 
question when you feel less sleepy I'd be very interested to see the inner join 
alternative :)

Thanks again

-- 
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/-/VljxcahfvKQJ.
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: Saving test user as a foreign key in unit tests

2012-04-11 Thread jondbaker
Problem solved. Within my view I needed use the following:

def create_tasting(request):
if request.method =='POST':
form = TastingForm(request.POST)
if form.is_valid():
*obj = form.save(commit=False)*
*obj.author = request.user*
*obj.save()*
return HttpResponseRedirect('/tastings/')
else:
form = TastingForm()
return render_to_response('tastings/create.html', {
'form': form
}, context_instance=RequestContext(request))

-- 
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/-/Q6I4oSuCsTIJ.
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: Tutorial question regarding def _unicode_

2012-04-11 Thread Brandy
Yep..that's it. Thanks!

On Apr 11, 12:55 pm, Jonathan Baker 
wrote:
> The method should begin and end with two underscores: __unicode__(self):
>
>
>
>
>
> On Wed, Apr 11, 2012 at 11:30 AM, Brandy  wrote:
> > I am working through the tutorial and have already added the def
> > _unicode_ statements to my code. However, when running
> > Poll.objects.all(), I still get this output: []
>
> > Here is the code:
>
> > from django.db import models
>
> > 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_recently(self):
> > #               return self.pub_date >= timezone.now() -
> > #datetime.timedelta(days=1)
>
> > class Choice(models.Model):
> >        poll = models.ForeignKey(Poll)
> >        choice = models.CharField(max_length=200)
> >        votes = models.IntegerField()
> >        def _unicode_(self):
> >                return self.choice
>
> > Thank you for any help!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Jonathan D. Baker
> Web Developerhttp://jonathandbaker.com
> 303.257.4144

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



Saving test user as a foreign key in unit tests

2012-04-11 Thread jondbaker
I have a Tasting model with an 'author' field that is a ForeignKey to the 
User model. Within my unit test I'm attempting to create a test user, and 
pass that user object as the author of a test Tasting, but I keep getting 
the following error: "IntegrityError: tastings_tasting.author_id may not be 
NULL"

*models.py*
class Tasting(models.Model):
notes = models.TextField(blank=True)
author = models.ForeignKey(User, editable=False)

*forms.py*
class TastingForm(ModelForm):
class Meta:
model = Tasting

*views.py*
def create_tasting(request):
if request.method =='POST':
form = TastingForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/tastings/')
else:
form = TastingForm()
return render_to_response('tastings/create.html', {
'form': form
}, context_instance=RequestContext(request))

*test_views.py*
class TestPostCreateTasting(TestCase):
def test_auth_response_valid_data(self):
client = Client()
user = User.objects.create_user('test', 't...@test.com', 
'testPassword')
client.login(username='test', password='testPassword')
tasting = {
'notes': 'What a great beer',
'author': user,
}
response = client.post('/tastings/create/', tasting)
self.assertEquals(response.status_code, 200)
tastings = Tasting.objects.all()
self.assertEquals(len(tastings), 1)
client.logout()

-- 
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/-/tSmxysZVgYAJ.
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.



Python Library for Audio Files - Clipping mp3/ogg formats

2012-04-11 Thread BGMaster
Hi,

I know this isn't a django specific question, but does anyone know of
a good python library or module for clipping/cutting an mp3 or ogg
file at a specified start and stop time? The functionality I need is:

1) take file (example.mp3)
2) take start and stop times (hh:mm:ss, hh:mm:ss)
3) return new file with audio from given start and stop times

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: Tutorial question regarding def _unicode_

2012-04-11 Thread Gerald Klein
Have you resynced?

On Wed, Apr 11, 2012 at 12:30 PM, Brandy  wrote:

> I am working through the tutorial and have already added the def
> _unicode_ statements to my code. However, when running
> Poll.objects.all(), I still get this output: []
>
> Here is the code:
>
> from django.db import models
>
> 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_recently(self):
> #   return self.pub_date >= timezone.now() -
> #datetime.timedelta(days=1)
>
> class Choice(models.Model):
>poll = models.ForeignKey(Poll)
>choice = models.CharField(max_length=200)
>votes = models.IntegerField()
>def _unicode_(self):
>return self.choice
>
> Thank you for any help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

j...@zognet.com

708-599-0352


Linux registered user #548580

-- 
You received this message because you are subscribed to the Google 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: Tutorial question regarding def _unicode_

2012-04-11 Thread Babatunde Akinyanmi
I don't know if its because I'm reading this mail from my phone but
you should have

__unicode__() not _unicode_() ie is 2 underscores before and after not 1

On 4/11/12, Brandy  wrote:
> I am working through the tutorial and have already added the def
> _unicode_ statements to my code. However, when running
> Poll.objects.all(), I still get this output: []
>
> Here is the code:
>
> from django.db import models
>
> 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_recently(self):
> # return self.pub_date >= timezone.now() -
> #datetime.timedelta(days=1)
>
> class Choice(models.Model):
>   poll = models.ForeignKey(Poll)
>   choice = models.CharField(max_length=200)
>   votes = models.IntegerField()
>   def _unicode_(self):
>   return self.choice
>
> Thank you for any help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> 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.



Re: Tutorial question regarding def _unicode_

2012-04-11 Thread Jonathan Baker
The method should begin and end with two underscores: __unicode__(self):

On Wed, Apr 11, 2012 at 11:30 AM, Brandy  wrote:

> I am working through the tutorial and have already added the def
> _unicode_ statements to my code. However, when running
> Poll.objects.all(), I still get this output: []
>
> Here is the code:
>
> from django.db import models
>
> 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_recently(self):
> #   return self.pub_date >= timezone.now() -
> #datetime.timedelta(days=1)
>
> class Choice(models.Model):
>poll = models.ForeignKey(Poll)
>choice = models.CharField(max_length=200)
>votes = models.IntegerField()
>def _unicode_(self):
>return self.choice
>
> Thank you for any help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Jonathan D. Baker
Web Developer
http://jonathandbaker.com
303.257.4144

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



Tutorial question regarding def _unicode_

2012-04-11 Thread Brandy
I am working through the tutorial and have already added the def
_unicode_ statements to my code. However, when running
Poll.objects.all(), I still get this output: []

Here is the code:

from django.db import models

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_recently(self):
#   return self.pub_date >= timezone.now() -
#datetime.timedelta(days=1)

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

Thank you for any help!

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



Re: Django ORM - query help

2012-04-11 Thread Jani Tiainen
Hi,

You're not doing anything wrong. The catch is that since "Thing" can exist
without Log you will get outer join.

If you want to get along with inner join, you should turn query around and
start querying from Log model. I'm just too tired to think how it should be
done right now... =)


On Wed, Apr 11, 2012 at 5:28 PM, David  wrote:

> class Log(models.Model):
>thing = models.ForeignKey(Thing)
>context = models.CharField(max_length=255)
>action = models.CharField(max_length=255)
>modifier = models.ForeignKey(User, limit_choices_to={'groups__in':
> [2]})
>modified_on = models.DateTimeField(auto_now=True)
>
> class Thing(models.Model):
>prefix = models.CharField(max_length=50,choices=PREFIXES,
> blank=True)
>first_name = models.CharField(max_length=255)
>last_name = models.CharField(max_length=255)
>
> Hello,
>
> Given the above models, how can I achieve the following results:
>
> A unique "Thing" instance along with the last (in terms of date)
> modified_on instance (ideally with access to the other related fields
> such as modifier) from the "Log" model? I have tried using .annotate
> but it seems to result in a very ugly left outer join which makes me
> think I must be doing something wrong.
>
> Such as:
>
> last_modified =
>
> Thing.objects.select_related().annotate(deletion_date=Max('log__modified_on')).order_by('-
> deletion_date')
>
> Any assistance would be much appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.



how to submit data in django's database

2012-04-11 Thread Sophia
Hi all,

I have a question about how to enter data in django's database. I have the 
following Template, in which ' E ' is a variable that get the string:



This is my models.py in which I have a class named 'Company' and I want 
this variable 'E' be saved in 'Subject' :

class Company(models.Model):
Subject = models.CharField(max_length=30)
start_time = models.DateTimeField()
end_time = models.DateTimeField()

def __unicode__(self):
return self.Subject

Then in views.py I wrote something like this to save the variable in 
Subject field, it's incomplete, and I want you to help me about it :

def Text_Box(request):
T = request.GET.get(E,' ')
if T:
   # I don't know how to make an object of class 'Company' so then I 
save ' T ' in Company.Subject
 else:
return render_to_response("Base.html") # Base.html is my basic 
template file

I would really appreciate if you help me with it.
Thanks in advance.

Sophia



-- 
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/-/ChZdnVfKiYIJ.
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 ORM - query help

2012-04-11 Thread David
class Log(models.Model):
thing = models.ForeignKey(Thing)
context = models.CharField(max_length=255)
action = models.CharField(max_length=255)
modifier = models.ForeignKey(User, limit_choices_to={'groups__in':
[2]})
modified_on = models.DateTimeField(auto_now=True)

class Thing(models.Model):
prefix = models.CharField(max_length=50,choices=PREFIXES,
blank=True)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)

Hello,

Given the above models, how can I achieve the following results:

A unique "Thing" instance along with the last (in terms of date)
modified_on instance (ideally with access to the other related fields
such as modifier) from the "Log" model? I have tried using .annotate
but it seems to result in a very ugly left outer join which makes me
think I must be doing something wrong.

Such as:

last_modified =
Thing.objects.select_related().annotate(deletion_date=Max('log__modified_on')).order_by('-
deletion_date')

Any assistance would be much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Quick tutorial question

2012-04-11 Thread Mark Phillips
Check the bottom of tutorial #1 -

Wait a minute.  is, utterly, an unhelpful representation
of this object. Let's fix that by editing the polls model (in the
polls/models.py file) and adding a
__unicode__()
method
to both Poll and Choice:

class Poll(models.Model):
# ...
def __unicode__(self):
return self.question
class Choice(models.Model):
# ...
def __unicode__(self):
return self.choice

It's important to add
__unicode__()
methods
to your models, not only for your own sanity when dealing with the
interactive prompt, but also because objects' representations are used
throughout Django's automatically-generated admin.
Mark

On Tue, Apr 10, 2012 at 9:46 PM, oneroler  wrote:

> I'm working through the tutorial and was setting up the admin site for the
> polls app.  I noticed in the "Select Poll to Change" section that it was
> showing "poll object" rather than "what's up" or the question associated
> with the poll.  Same is true on the Choice area of admin, the dropdown for
> polls just shows a number of poll objects rather than the names.  I can't
> seem to find a difference in my code versus the tutorial.  Below is my
> code.  Any help would be appreciated.
>
> *mysite/polls/admin.py*
> from polls.models import Poll, Choice
> from django.contrib import admin
>
> class PollAdmin(admin.ModelAdmin):
> fieldsets = [
> (None,   {'fields': ['question']}),
> ('Date information', {'fields': ['pub_date'], 'classes':
> ['collapse']}),
> ]
>
> admin.site.register(Poll, PollAdmin)
> admin.site.register(Choice)
>
> *mysite/polls/models.py*
> from django.db import models
>
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
> class Choice(models.Model):
> poll = models.ForeignKey(Poll)
> choice = models.CharField(max_length=200)
> votes = models.IntegerField()*
>
> mysite/settings.py* (just the changed text)
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3', # Add
> 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
> 'NAME':
> '/Users/Sam/dev/django/mysite/mysite1.sqlite',  # Or
> path to database file if using sqlite3.
> '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.
> }
> }
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> # Uncomment the next line to enable the admin:
> 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> # 'django.contrib.admindocs',
> 'polls',
> )
>
> --
> 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/-/2-CC0B8PXvYJ.
> 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: Admin area hyperlinks to sub categories

2012-04-11 Thread Sandro Dutra
more:
https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/

2012/4/11 Sandro Dutra 

> # File: admin.py
> from django.contrib import admin
> from distribute.models import Categories
> (...)
> class CategoriesAdmin(admin.ModelAdmin):
> list_display = ['category']
> (...)
> (...)
> admin.site.register(Categories, CategoriesAdmin)
> (...)
>
>
> 2012/4/11 Swaroop Shankar V 
>
>> Hi,
>> Could anyone provide me a solution please? Thanks
>>
>> Regards,
>> Swaroop Shankar V
>>
>>
>>
>>
>> On Mon, Apr 9, 2012 at 2:53 PM, Swaroop Shankar V wrote:
>>
>>> Hi all,
>>> I have 2 models one is Category and another one is Book. Books will
>>> be assigned to a category. So on the admin area i want to display a link on
>>> the dashboard which will take the user to a page where all the categories
>>> will be listed. On clicking on to any of the category user should be taken
>>> to a page where the books assigned under that category is displayed. How
>>> can i accomplish the same.
>>>
>>> Thanks and Regards,
>>>
>>> Swaroop Shankar V
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> 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: Admin area hyperlinks to sub categories

2012-04-11 Thread Sandro Dutra
# File: admin.py
from django.contrib import admin
from distribute.models import Categories
(...)
class CategoriesAdmin(admin.ModelAdmin):
list_display = ['category']
(...)
(...)
admin.site.register(Categories, CategoriesAdmin)
(...)

2012/4/11 Swaroop Shankar V 

> Hi,
> Could anyone provide me a solution please? Thanks
>
> Regards,
> Swaroop Shankar V
>
>
>
>
> On Mon, Apr 9, 2012 at 2:53 PM, Swaroop Shankar V wrote:
>
>> Hi all,
>> I have 2 models one is Category and another one is Book. Books will
>> be assigned to a category. So on the admin area i want to display a link on
>> the dashboard which will take the user to a page where all the categories
>> will be listed. On clicking on to any of the category user should be taken
>> to a page where the books assigned under that category is displayed. How
>> can i accomplish the same.
>>
>> Thanks and Regards,
>>
>> Swaroop Shankar V
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> 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: Admin area hyperlinks to sub categories

2012-04-11 Thread Swaroop Shankar V
Hi,
Could anyone provide me a solution please? Thanks

Regards,
Swaroop Shankar V



On Mon, Apr 9, 2012 at 2:53 PM, Swaroop Shankar V wrote:

> Hi all,
> I have 2 models one is Category and another one is Book. Books will
> be assigned to a category. So on the admin area i want to display a link on
> the dashboard which will take the user to a page where all the categories
> will be listed. On clicking on to any of the category user should be taken
> to a page where the books assigned under that category is displayed. How
> can i accomplish the same.
>
> Thanks and Regards,
>
> Swaroop Shankar V
>
>

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



PostgreSQL Introspection Bug

2012-04-11 Thread Thomas Guettler

Hi,

I fixed a postgreSQL introspection bug, but unfortunately it is still in stage 
"new".

Can someone please review it?

  https://code.djangoproject.com/ticket/17785

 Thank you,
   Thomas Güttler

--
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.



Quick tutorial question

2012-04-11 Thread oneroler
I'm working through the tutorial and was setting up the admin site for the 
polls app.  I noticed in the "Select Poll to Change" section that it was 
showing "poll object" rather than "what's up" or the question associated 
with the poll.  Same is true on the Choice area of admin, the dropdown for 
polls just shows a number of poll objects rather than the names.  I can't 
seem to find a difference in my code versus the tutorial.  Below is my 
code.  Any help would be appreciated.

*mysite/polls/admin.py*
from polls.models import Poll, Choice
from django.contrib import admin

class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None,   {'fields': ['question']}),
('Date information', {'fields': ['pub_date'], 'classes': 
['collapse']}),
]

admin.site.register(Poll, PollAdmin)
admin.site.register(Choice)

*mysite/polls/models.py*
from django.db import models

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

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

mysite/settings.py* (just the changed text)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 
'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 
'/Users/Sam/dev/django/mysite/mysite1.sqlite',  # Or 
path to database file if using sqlite3.
'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.
}
}

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'polls',
)

-- 
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/-/2-CC0B8PXvYJ.
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.

<>

Need help with Django formsets

2012-04-11 Thread BeriK
I'm making a survey site with django. I am pretty newbie with django
so I apologize in advance if I can not explain well. My question
focuses on the following models:

class SurveyType(models.Model):

name = models.CharField(max_length=200)

def __unicode__(self):
return self.name

class Question(models.Model):

ANSWERTYPE_CHOICES = (
(u'T', u'Text'),
(u'R', u'Range'),
(u'M', u'Media'),
)

question = models.CharField(max_length=200)

surveytype = models.ForeignKey(SurveyType)

answertype = models.CharField(max_length=1,
choices=ANSWERTYPE_CHOICES)

order = models.IntegerField(default=0)

def __unicode__(self):
return self.question


class Survey(models.Model):

course = models.ForeignKey(Course)

surveytype = models.ForeignKey(SurveyType)

def __unicode__(self):
return u"%s %s" % (self.course, self.surveytype)

class Answer(models.Model):

answer = models.CharField(max_length=400)

survey = models.ForeignKey(Survey)

question = models.ForeignKey(Question)

def __unicode__(self):
return self.answer


Django receives survey id. With the survey id it gets the surveytype
and shows questions that must be displayed.

def survey(request, survey_id):
survey_data = get_object_or_404(Survey, pk=survey_id)
survey_type = survey_data.surveytype
questions = Question.objects.all().filter(surveytype =
survey_type).order_by('order')


I have read the django documentation about formsets but I don't
understand what I have to write in forms.py, so I can't call the form
in views.py to render de form in the template that shows the questions
and write the answers in the answer model.

Thanks in advance and sorry for my english.

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



Variations on a table for different clients?

2012-04-11 Thread Derek
Does anyone have any experience with working with systems where different
clients all need variations on the same basic table; there might be, say,
10 common fields, but each client will need an additional 2 or 3 that are
specific to them (and, possibly, not need 1 or 2 of the common ones).

What approaches or practices will help streamline work and prevent such
variations from becoming a headache to maintain?  (And yes, its likely to
be more than one table that will require these variations).

Thanks
Derek

-- 
You received this message because you are subscribed to the Google 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: Best approach for multiple sites in a single deployment?

2012-04-11 Thread Derek
That domain and page do not exist...

On Apr 10, 4:42 pm, Mario Gudelj  wrote:
> Hey man,
>
> See if this 
> helpshttp://tidbids.posterous.com/saas-with-django-and-postgresql-schemas
>
> Cheers,
>
> -m
>
> On 10 April 2012 21:53, Bernardo  wrote:
>
>
>
>
>
>
>
> > I would like to create a subdomain based authentication system, like the
> > one on 37signals, freshbooks, codebase, etc. The objective is to do
> > something like smaller but in far smaller scale (I suppose a maximum of
> > 100-1000 blogs). All other models (blog posts, comments, etc) already have
> > a foreign key to Site.
>
> > 1. How can I allow different users to have the same username in different
> > sites? How can I make so that when a user logs in, he logged in to a
> > specific site (logging on blog A does not log you to blog B).
>
> > For allowing the same username in different sites I guess I'd have to
> > write my own authentication backend and a new model for User, as I don't
> > see how the default User model would fit. Is this a good approach?
>
> > 2. Is there anyway to make the sites framework fetch the current site
> > based on the subdomain instead of the settings? Or am I seeing this the
> > wrong way?
>
> > My plan was to use a single deployment for everything and use the sites
> > framework, but as far as I've understood, the sites framework relies on the
> > settings.SITE_ID parameter, which would be the same for a single
> > deployment. What would be a good approach here? Creating a new settings
> > file for each new blog?
>
> > Many thanks in advance!
>
> >  --
> > 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/-/zQimMoWFGNUJ.
> > 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: Can't create a test suite for a Django app

2012-04-11 Thread Benedict Verheyen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

> Hi all,
> 
> I'm having trouble creating a test suite in Django 1.3.
> 
> Say I have an installed app in a directory called app_name. One of the
> files in that directory is foo.py which defines a class named Foo. I
> want to test that, so I also have a file that directory called
> foo_test.py which defines a class named FooTest. That file looks like:
> 
>   import unittest
>   import foo
> 
>   class FooTest(unittest.TestCase):
> def setUp(self):
>   self.foo_instance = foo.Foo()
> 
> ... etc
> 
> 
> Now down the line I'll have other test cases in other files, and I'll
> want to run them all as part of a test suite. So in the same directory
> app_name I created a file tests.py which will define the suite. At
> first I defined it like:
> 
> 
>   from django.test.simple import DjangoTestSuiteRunner
> 
>   def suite():
> runner = DjangoTestSuiteRunner()
> return runner.build_suite(['app_name'])
> 
> 
> Unfortunately, this fails because calling
> runner.build_suite(['app_name']) searches app_name for a tests.py
> file, executes suite(), and this continues recursively until the
> Python interpreter stops everything for exceeding the maximum
> recursion depth.
> 
> Changing runner.build_suite(['app_name']) to the following:
> 
>   runner.build_suite(['app_name.foo_test'])
>   runner.build_suite(['app_name.foo_test.FooTest'])
> 
> Leads to errors like "ValueError: Test label 'app_name.foo_test' does
> not refer to a test". And changing it to the following:
> 
>   runner.build_suite(['foo_test'])
>   runner.build_suite(['foo_test.FooTest'])
> 
> Leads to errors like "App with label foo_test could not be found".
> 
> I'm kind of out of ideas at this point. Any help would be very much
> appreciated!
> 
> Regards,
> Mike
> 

Hi,

to test Django using django manage.py, tests have to be in:
- - a file called tests.py in the app dir.
- - in the models.py file

I haven't tried with the DjangoTestSuiteRunner, but this is what I did
in a non Django module for testing. This is an excerpt from a test:

suite = unittest.TestSuite()
suite.addTests(doctest.DocTestSuite(ad))
suite.addTest(unittest.makeSuite(TestAdFunctions))

ad is the module I wanted to test (file is ad.py) and TestAdFunctions is derived
from unittest.TestCase.

Do you have an __init__.py?
If you put your test in a tests.py file, does it then work?

Regards,
Benedict







-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+FPW4ACgkQ6YPsX3Esu42ySACffT8at9sjXqWI5xujsNJzy9t4
N2IAoKmrwt4V9gdH5gChJe4fhIra340D
=lIuL
-END PGP SIGNATURE-

-- 
You received this message because you are subscribed to the Google 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: Tutorial issue with admin

2012-04-11 Thread Alexandr Aibulatov
You can add list_display = ['question', ] on your PollAdmin class.

2012/4/11 Romain Gaches :
> you just have to define a __unicode__ method [1] in your model
>
> [1]
> https://docs.djangoproject.com/en/1.4/ref/models/instances/#django.db.models.Model.__unicode__
>
>
> Le 11/04/2012 06:54, oneroler a écrit :
>
> I'm working on the tutorial and ran across an issue that I can't figure
> out.  In the admin site in "Select Polls to Change" instead of displaying
> the question associated with the poll (e.g. "What's up") it displays "poll
> object" for all polls.  I've attached a screen shot of the issue.  Below is
> my code.  Any help would be appreciated.
>
> mysite/polls.models.py
> from django.db import models
>
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
>
> class Choice(models.Model):
>     poll = models.ForeignKey(Poll)
>     choice = models.CharField(max_length=200)
>     votes = models.IntegerField()
>
> mysite/polls/admin.py
> from polls.models import Poll, Choice
> from django.contrib import admin
>
> class PollAdmin(admin.ModelAdmin):
>     fieldsets = [
>     (None,   {'fields': ['question']}),
>     ('Date information', {'fields': ['pub_date'], 'classes':
> ['collapse']}),
>     ]
>
> admin.site.register(Poll, PollAdmin)
> admin.site.register(Choice)
>
> mysite/settings.py
> DATABASES = {
>     'default': {
>     'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2',
> 'mysql', 'sqlite3' or 'oracle'.
>     'NAME':
> '/Users/Sam/dev/django/mysite/mysite1.sqlite',  # Or
> path to database file if using sqlite3.
>     '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.
>     }
> }
>
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
>     # Uncomment the next line to enable the admin:
>     'django.contrib.admin',
>     # Uncomment the next line to enable admin documentation:
>     # 'django.contrib.admindocs',
>     'polls',
> )
> --
> 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/-/r6d6l_4q6fUJ.
> 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.

-- 
You received this message because you are subscribed to the Google 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: Filtering ForeignKey Drop Down in Admin Interface

2012-04-11 Thread Святослав Б
Hi!

Override ModelAdmin get_form() method and filter your field.

class MyAdmin(admin.ModelAdmin):
def get_form(self, request, obj=None, **kwargs):
form = super(MyAdmin,self).get_form(request, obj,**kwargs)
form.base_fields['field'].queryset =
form.base_fields['field'].queryset.filter(user=request.user)
return form

2012/4/11 Setiaman Lee 

> Hi,
>
> I managed to set in the QuerySet of ModelAdmin  to only allow user to
> see their own record.
> But when the child model link to parent model using ForeignKey a Drop
> Down will be automatically created for the respective column.
> Is there anyway to filter the drop down to only show the records that
> has been created by the login user?
>
>
> Rgrds,
> Setiaman Lee.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.