Re: Random 404 instead of 301 for URLs without trailing slash

2016-09-19 Thread Frederik Elwert
Hi Michal,

Am Freitag, 16. September 2016 18:40:11 UTC+2 schrieb Michal Petrucha:
>
> Hi Frederik, 
>
> On Fri, Sep 16, 2016 at 09:01:53AM -0700, Frederik Elwert wrote: 
> > Hello, 
> > 
> > I am running a site that uses Django 1.8 and Django CMS 3.2. The site is 
> > deployed using gunicorn and nginx. Now I noticed a strange, hard to 
> debug 
> > issue: When accessing a URL without trailing slash, I expect a redirect 
> to 
> > the correct URL with the trailing slash appended, as per the 
> APPEND_SLASH 
> > setting. This usually works, but sometimes I get a 404 instead of the 
> > correct 301. I can reproduce this using curl: 
> > 
> > $ curl -I http://khk.ceres.rub.de/en/research/focus-groups/notions 
> > HTTP/1.1 404 NOT FOUND 
> > Server: nginx/1.6.2 
> > Date: Fri, 16 Sep 2016 15:54:40 GMT 
> > Content-Type: text/html 
> > Connection: keep-alive 
> > x-xss-protection: 1; mode=block 
> > Content-Language: en 
> > x-content-type-options: nosniff 
> > Vary: Cookie 
> > X-Frame-Options: SAMEORIGIN 
> > Set-Cookie: django_language=en; expires=Sat, 16-Sep-2017 15:54:40 GMT; 
> > Max-Age=31536000; Path=/ 
> > 
> > $ curl -I http://khk.ceres.rub.de/en/research/focus-groups/notions 
> > HTTP/1.1 301 MOVED PERMANENTLY 
> > Server: nginx/1.6.2 
> > Date: Fri, 16 Sep 2016 15:54:42 GMT 
> > Content-Type: text/html; charset=utf-8 
> > Connection: keep-alive 
> > x-xss-protection: 1; mode=block 
> > Content-Language: en 
> > x-content-type-options: nosniff 
> > Vary: Cookie 
> > Location: http://khk.ceres.rub.de/en/research/focus-groups/notions/ 
> > X-Frame-Options: SAMEORIGIN 
> > Set-Cookie: django_language=en; expires=Sat, 16-Sep-2017 15:54:42 GMT; 
> > Max-Age=31536000; Path=/ 
> > 
> > I am a bit clueless why this behaviour is so unpredictable. Any ideas 
> what 
> > might be going on here, or how to trace this? 
>
> APPEND_SLASH only applies to URLs that do not match any URL pattern. 
> It is possible that you have a catch-all urlpattern that happens to 
> match your URL without a trailing slash, and then raise an explicit 
> 404 – this might happen, for instance, if you're using something like 
> a wiki application, or a custom handler for flatpages, included under 
> a particular URL prefix


Thanks for your reply! APPEND_SLASH seemed to have an effect, but indeed, 
it might be Django-CMS hat mimics the behaviour. I still don’t understand 
why this behaviour is so unpredictable, but I’ll ask again on the Django 
CMS group.

Thanks again,
Frederik

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9eea8237-7488-45ee-b57d-74a2fea47d8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue using django-admin

2016-09-19 Thread Tim Graham
Did you install it as described at 
https://docs.djangoproject.com/en/dev/topics/install/#installing-the-development-version
 
?

On Sunday, September 18, 2016 at 10:10:50 PM UTC-4, PARTH VERMA wrote:
>
> Hello everyone,
>
> I am new to Django and just cloned it. I am getting error running 
> django-admin commands, the error says: "-bash: django-admin: command not 
> found". 
> However, 'python -m django --version' this commands works just fine, 
> returning the current version of Django (1.11). Can someone please help me 
> out...
>
> P.S. I am using OS X
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6a88e602-4fb5-4ecc-abdb-11bb8767678d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting FK field in list view

2016-09-19 Thread RompePC
Hi again, I didn't have time to try it until now, but I just realized that 
maybe I asked the wrong way. What I wanna do is to render the widget 
associated to that FK in the panel, not its name. So I need to pass the 
field or its rendered content to the context, but I don't know how to do 
get it.

El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic coues 
escribió:
>
> Have you tried something like author__name ? Assuming a model with an 
> author foreign key. 
>
> 2016-09-16 8:56 GMT+02:00 RompePC >: 
> > I would like to pass to the list display view a FK field of the admin 
> form 
> > (like the ones when adding a new row). But I don't see the way of doing 
> it, 
> > although I've searched along many properties of the model admin to get 
> it. 
> > 
> > Anyone did something like that before? 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue using django-admin

2016-09-19 Thread Bharathi Raja
As said in docs 

 , 
your django version may be different, check your system $PATH or try 
symlinking

On Monday, September 19, 2016 at 7:40:50 AM UTC+5:30, PARTH VERMA wrote:
>
> Hello everyone,
>
> I am new to Django and just cloned it. I am getting error running 
> django-admin commands, the error says: "-bash: django-admin: command not 
> found". 
> However, 'python -m django --version' this commands works just fine, 
> returning the current version of Django (1.11). Can someone please help me 
> out...
>
> P.S. I am using OS X
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2b706bc5-91e0-4e49-b252-e02df7fbb753%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django filters with Foreign Key

2016-09-19 Thread Ali khan
I've tried many ways but it ends with the same error that says:

Cannot query "alikhan": Must be "User" instance.

Where alikhan is admin user I've created with createsuperuser.

Hate to bother you again but please advise.

Regards,
Ali

On Sun, Sep 18, 2016 at 11:08 PM, James Schneider 
wrote:

> On Sep 18, 2016 10:22 PM, "Ali khan"  wrote:
> >
> > Thank you for your kind response James.
> >
> > I must be doing something wrong but I thought that importing different
> models and assigning them with variable may had help me to filter it out. I
> will try your suggestion first to save your valued time and then will post
> with result.
> >
> > Let me add a field for the seller in my "Orders" model like "seller =
> models.ForeignKey(Seller)" and then filter it out.
> > But I tried that before still as per your suggestion I will do that
> again.
> > Thanks again.
> >
>
> Once you do that, you can filter the orders with something like this:
>
> orders = Order.objects.filter(seller__user=user)
>
> Inside of the filter function you defined. The way you are currently doing
> it, you'll end up with Seller objects rather than Order objects.
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciX6N3eQOnb5dP877WM0FEgj%
> 2BAjt-QfT6anwE5jNMafx3Q%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAXvsYmSxGvDyJf0-SXeJ8eeC2Unqs5u9Ph7-3jnH4V0xSetCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting FK field in list view

2016-09-19 Thread ludovic coues
I looked into it after my first reply and my suggestion was wrong.

If you want to display the value of a foreign key object's property in
the admin page to select an object to change, you can add a callable
to list_display.
For exemple, ` list_display = ('title', lambda o: getattr(o.author,
"name", "-"),) `. The callable will get one argument, an instance of
the model.

If you want to display a field to change a property of a foreign key
object, I haven't found a way. Best option might be a inline model
admin.

2016-09-19 12:24 GMT+02:00 RompePC :
> Hi again, I didn't have time to try it until now, but I just realized that
> maybe I asked the wrong way. What I wanna do is to render the widget
> associated to that FK in the panel, not its name. So I need to pass the
> field or its rendered content to the context, but I don't know how to do get
> it.
>
> El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic coues
> escribió:
>>
>> Have you tried something like author__name ? Assuming a model with an
>> author foreign key.
>>
>> 2016-09-16 8:56 GMT+02:00 RompePC :
>> > I would like to pass to the list display view a FK field of the admin
>> > form
>> > (like the ones when adding a new row). But I don't see the way of doing
>> > it,
>> > although I've searched along many properties of the model admin to get
>> > it.
>> >
>> > Anyone did something like that before?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to django-users...@googlegroups.com.
>> > To post to this group, send email to django...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> >
>> > https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>>
>> Cordialement, Coues Ludovic
>> +336 148 743 42
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTar-rUXwSoZgTMfeAYtRb6Ji-j_zjSKZDmRGEAP4Gs2cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django filters with Foreign Key

2016-09-19 Thread Ali khan
I just got it done.

Thanks.

On Mon, Sep 19, 2016 at 4:19 AM, Ali khan  wrote:

> I've tried many ways but it ends with the same error that says:
>
> Cannot query "alikhan": Must be "User" instance.
>
> Where alikhan is admin user I've created with createsuperuser.
>
> Hate to bother you again but please advise.
>
> Regards,
> Ali
>
> On Sun, Sep 18, 2016 at 11:08 PM, James Schneider  > wrote:
>
>> On Sep 18, 2016 10:22 PM, "Ali khan"  wrote:
>> >
>> > Thank you for your kind response James.
>> >
>> > I must be doing something wrong but I thought that importing different
>> models and assigning them with variable may had help me to filter it out. I
>> will try your suggestion first to save your valued time and then will post
>> with result.
>> >
>> > Let me add a field for the seller in my "Orders" model like "seller =
>> models.ForeignKey(Seller)" and then filter it out.
>> > But I tried that before still as per your suggestion I will do that
>> again.
>> > Thanks again.
>> >
>>
>> Once you do that, you can filter the orders with something like this:
>>
>> orders = Order.objects.filter(seller__user=user)
>>
>> Inside of the filter function you defined. The way you are currently
>> doing it, you'll end up with Seller objects rather than Order objects.
>>
>> -James
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CA%2Be%2BciX6N3eQOnb5dP877WM0FEgj%2BAjt-
>> QfT6anwE5jNMafx3Q%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAXvsYk0SN23WotK_ikG7foEHMKYYN7pLzrYLJmPtm-MVRYORw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: authenticate user on post request returns 403-regarding

2016-09-19 Thread sabari rangan
the view is

@api_view(['POST'])
def example(request):
return Response({'usernmae': 
request.user.username},status=status.HTTP_200_OK)


when i print the content of response object it shows 
b'{"detail":"CSRF Failed: CSRF cookie not set."}'

it happens only when i set sessionid cookie in client side

On Monday, September 19, 2016 at 1:34:58 AM UTC+5:30, James Schneider wrote:
>
> On Sep 18, 2016 12:56 PM, "sabari rangan"  > wrote:
> >
> > i am using django.contrib.auth module for authentication system in my 
> django rest framework app, when i post data i couldn't able to authenticate 
> the user it return 403 response code . but during get request it works 
> fine. i have attached the sessionid in cookies in both above. kindly help 
> me with this i got stuck.
> >
>
> Can you post the relevant Django views for the GET and POST requests?
>
> -James
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/74c79247-46d3-4b8b-9ed5-e195d646bd53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to populate self._reverse_dict with a default language code ?

2016-09-19 Thread Etienne Robillard
I created a ticket and patch for this issue: 
https://code.djangoproject.com/ticket/27243


I guess my urlpatterns was improperly configured... However, the real 
problem was that reverse() didn't


handle fully qualified module names.

Regards,

Etienne


Le 2016-09-18 à 19:14, Mike Dewhirst a écrit :

On 18/09/2016 11:07 PM, Etienne Robillard wrote:

Hi,

Actually the issue is that the self._reverse_dict type isn't 
containing any key.


You will need to examine class RegexURLResolver(LocaleRegexProvider) 
in django/core/urlresolver.py where self._reverse_dict is declared and 
populated to see where your problem might have arisen.


In that source you will see that self._reverse_dict is a dict and so 
either of the suggestions below should work.


I suspect the language code you are looking for is not being properly 
formatted. For example, in my settings.py I have LANGUAGE_CODE = 
'en-au' which seems to work for me so I think that is a reasonable 
format for it.


Cheers

Mike






Le 2016-09-14 à 20:33, Mike Dewhirst a écrit :

On 14/09/2016 11:43 PM, Etienne Robillard wrote:

Hi,

Is there a way to populate self._reverse_dict to contain a default 
language_code in case

the setting USE_I18N is set to False?


return self._reverse_dict.get("language_code", defaultlanguagecode)

or

try:
languagecode = failing_routine()
except KeyError:
languagecode = defaultlanguagecode






See: http://dpaste.com/3Q1NHXA

Regards,

Etienne







--
Etienne Robillard
tkad...@yandex.com
http://www.isotopesoftware.ca/

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/19903221-0cf7-f410-89ee-6293497c7034%40yandex.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting FK field in list view

2016-09-19 Thread RompePC
Yep, the second one is what I wanna do. Althrough they aren't inlines, but 
like FK filter choices in the list view (not the default ones).
It's hard to understand, I know it can be done, but don't know how. Will 
keep searching and throw some light here when done.

El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
escribió:
>
> I looked into it after my first reply and my suggestion was wrong. 
>
> If you want to display the value of a foreign key object's property in 
> the admin page to select an object to change, you can add a callable 
> to list_display. 
> For exemple, ` list_display = ('title', lambda o: getattr(o.author, 
> "name", "-"),) `. The callable will get one argument, an instance of 
> the model. 
>
> If you want to display a field to change a property of a foreign key 
> object, I haven't found a way. Best option might be a inline model 
> admin. 
>
> 2016-09-19 12:24 GMT+02:00 RompePC >: 
> > Hi again, I didn't have time to try it until now, but I just realized 
> that 
> > maybe I asked the wrong way. What I wanna do is to render the widget 
> > associated to that FK in the panel, not its name. So I need to pass the 
> > field or its rendered content to the context, but I don't know how to do 
> get 
> > it. 
> > 
> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic coues 
> > escribió: 
> >> 
> >> Have you tried something like author__name ? Assuming a model with an 
> >> author foreign key. 
> >> 
> >> 2016-09-16 8:56 GMT+02:00 RompePC : 
> >> > I would like to pass to the list display view a FK field of the admin 
> >> > form 
> >> > (like the ones when adding a new row). But I don't see the way of 
> doing 
> >> > it, 
> >> > although I've searched along many properties of the model admin to 
> get 
> >> > it. 
> >> > 
> >> > Anyone did something like that before? 
> >> > 
> >> > -- 
> >> > You received this message because you are subscribed to the Google 
> >> > Groups 
> >> > "Django users" group. 
> >> > To unsubscribe from this group and stop receiving emails from it, 
> send 
> >> > an 
> >> > email to django-users...@googlegroups.com. 
> >> > To post to this group, send email to django...@googlegroups.com. 
> >> > Visit this group at https://groups.google.com/group/django-users. 
> >> > To view this discussion on the web visit 
> >> > 
> >> > 
> https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
>  
>
> >> > For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> 
> >> 
> >> -- 
> >> 
> >> Cordialement, Coues Ludovic 
> >> +336 148 743 42 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f56c0962-e591-4fcb-9b84-6652d9c0a2f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie to Novice – Using Admin DateTime Picker in your Form

2016-09-19 Thread Nate Granatir
I just installed Django Daterange Filter 1.3.0 
(https://github.com/DXist/django-daterange-filter) on a Django 1.9 project. 
Took a little CSS fiddling to get it to display properly with Grappelli, 
but other than that it worked like a charm.

Nate


On Thursday, March 19, 2009 at 8:37:56 AM UTC-5, Paul Nema wrote:
>
> I've noticed many people new to Django (and sometimes also new to Python) 
> often post the same/similar questions in various forums. How to I get 
> something to work and/or do you have an example for X. As I've also 
> experienced this problem I've decided to post my little solution. Its not 
> the only way to do this, just the way I did it. Hopefully this will provide 
> the answer people are searching for or at least get them started. I guess 
> it will also serve as a quick code review by those so inclined to comment.
>
>
> You've probably heard of DRY but I think something is missing. There 
> should also be a Don't Repeat Other's Work (DROW) when they already solved 
> the problem. Thus another motivation to post this.  On a side note there is 
> a bit of debate out there about using the Django AdminDateWidget verse 
> other solutions (Jquery, etc). Your decision to make but why increase 
> dependencies when you don't have to.
>
>
> As I'm still learning Django everything in the code below may not be 
> required but I'm listing it anyway. You may need to modify to your 
> particular environment.  As I don't have a blog to post this I'm sending it 
> to this group. I'm open to any suggestions for a better place to post this.
>
>
> For this example I will focus on adding a date picker for date of birth 
> (dob) and a date time picker for sponsor sign date (sponsor_sign_date). Key 
> items are in *Bold*.
>
>
> Another reference to adding the AdminDateTime widget is here: 
> http://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form
>
>
>
>
> ---
>
> My top level (django-admin.py startproject izbo) directory Structure:
>
> mylogin@LX-D620:~/dev/izbo$ ll
>
> drwxrwxr-x 2 mylogin mylogin 4096 2009-03-17 10:52 account/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:53 add/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 04:34 adjudicator/ 
>
> drwxrwxr-x 2 mylogin mylogin 4096 2009-03-18 09:43 application/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 10:06 contract/ 
>
> drwxrwxrwx 2 mylogin mylogin 4096 2009-03-18 09:49 DB/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:51 employer/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 04:34 entity/ 
>
> -rw-r--r-- 1 mylogin mylogin 207 2009-03-08 04:54 exclude 
>
> drwxrwxrwx 2 mylogin mylogin 4096 2009-03-18 10:06 gzbo/ 
>
> -rw-r--r-- 1 mylogin mylogin 0 2009-01-06 04:55 __init__.py 
>
> -rw-r--r-- 1 mylogin mylogin 546 2009-01-06 04:55 manage.py 
>
> drwxrwxrwx 5 mylogin mylogin 4096 2009-02-08 12:35 media/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:53 member/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:52 note/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-02-20 12:47 search/ 
>
> -rw-r--r-- 1 mylogin mylogin 4192 2009-03-05 23:39 settings.py 
>
> drwxrwxrwx12 mylogin mylogin 4096 2009-03-16 11:48 templates/ 
>
> -rw-r--r-- 1 mylogin mylogin 2118 2009-03-16 11:16 urls.py 
>
>
> --
>
> Media directory Listing:
>
> mylogin@LX-D620:~/dev/izbo/media$ ll 
>
> total 12 
>
> drwxr-xr-x 5 mylogin mylogin 4096 2009-03-18 10:56 admin/ 
>
> drwxrwxrwx 2 mylogin mylogin 4096 2009-02-07 15:45 css/ 
>
> drwxrwxrwx 2 mylogin mylogin 4096 2009-01-27 10:07 images/ 
>
> lrwxrwxrwx 1 mylogin mylogin 36 2009-03-18 11:07 img -> 
> /home/mylogin/dev/izbo/media/admin/img/ 
>
>
> * Note: admin/ is 'cp -r' of directory 
> /usr/lib/python2.5/site-packages/django/contrib/admin/media.  Then I linked 
> the img directory.
>
>
>
> 
>
> In my “settings.py”
>
>
> import os.path 
>
> PROJECT_DIR = os.path.dirname(__file__) 
>
>
> MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media') 
>
> MEDIA_URL = 'http://www.izbo.com/media/'
>
> *ADMIN_MEDIA_PREFIX = '/media/admin/'*
>
> TEMPLATE_DIRS = ( 
>
>os.path.join(PROJECT_DIR, 'templates'),
>
>...
>
> )
>
>
> 
>
> In my top level “urls.py” file
>
> *from django.contrib import admin * 
>
>
> urlpatterns = patterns('', 
>
># Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
>
># to INSTALLED_APPS to enable admin documentation: 
>
>(r'^admin/doc/', include('django.contrib.admindocs.urls')), 
>
>
>*# Add this to get widgets.AdminDateWidget() working for non is_staff, 
> is_superuser * 
>
>*# This must be placed before (r'^admin/(.*)', admin.site.root), as 
> that gobals up everything * 
>
>*(r'^admin/jsi18n/$', 'django.views.i18n.javascript_catalog'), * 
>
>
># Uncomment the next line to enable the admin: 
>
>(r'^admin/(.*)', admin.site.root), 
>
>
># IZBO related URLs 
>
>(r'^$', splash), 
>
>.
>
> )
>
>
>
> -
>
> In “gzbo/models.py” I

Re: Setting FK field in list view

2016-09-19 Thread Tim Graham
Is your request https://code.djangoproject.com/ticket/10743?

On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:
>
> Yep, the second one is what I wanna do. Althrough they aren't inlines, but 
> like FK filter choices in the list view (not the default ones).
> It's hard to understand, I know it can be done, but don't know how. Will 
> keep searching and throw some light here when done.
>
> El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
> escribió:
>>
>> I looked into it after my first reply and my suggestion was wrong. 
>>
>> If you want to display the value of a foreign key object's property in 
>> the admin page to select an object to change, you can add a callable 
>> to list_display. 
>> For exemple, ` list_display = ('title', lambda o: getattr(o.author, 
>> "name", "-"),) `. The callable will get one argument, an instance of 
>> the model. 
>>
>> If you want to display a field to change a property of a foreign key 
>> object, I haven't found a way. Best option might be a inline model 
>> admin. 
>>
>> 2016-09-19 12:24 GMT+02:00 RompePC : 
>> > Hi again, I didn't have time to try it until now, but I just realized 
>> that 
>> > maybe I asked the wrong way. What I wanna do is to render the widget 
>> > associated to that FK in the panel, not its name. So I need to pass the 
>> > field or its rendered content to the context, but I don't know how to 
>> do get 
>> > it. 
>> > 
>> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic coues 
>> > escribió: 
>> >> 
>> >> Have you tried something like author__name ? Assuming a model with an 
>> >> author foreign key. 
>> >> 
>> >> 2016-09-16 8:56 GMT+02:00 RompePC : 
>> >> > I would like to pass to the list display view a FK field of the 
>> admin 
>> >> > form 
>> >> > (like the ones when adding a new row). But I don't see the way of 
>> doing 
>> >> > it, 
>> >> > although I've searched along many properties of the model admin to 
>> get 
>> >> > it. 
>> >> > 
>> >> > Anyone did something like that before? 
>> >> > 
>> >> > -- 
>> >> > You received this message because you are subscribed to the Google 
>> >> > Groups 
>> >> > "Django users" group. 
>> >> > To unsubscribe from this group and stop receiving emails from it, 
>> send 
>> >> > an 
>> >> > email to django-users...@googlegroups.com. 
>> >> > To post to this group, send email to django...@googlegroups.com. 
>> >> > Visit this group at https://groups.google.com/group/django-users. 
>> >> > To view this discussion on the web visit 
>> >> > 
>> >> > 
>> https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
>>  
>>
>> >> > For more options, visit https://groups.google.com/d/optout. 
>> >> 
>> >> 
>> >> 
>> >> -- 
>> >> 
>> >> Cordialement, Coues Ludovic 
>> >> +336 148 743 42 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups 
>> > "Django users" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an 
>> > email to django-users...@googlegroups.com. 
>> > To post to this group, send email to django...@googlegroups.com. 
>> > Visit this group at https://groups.google.com/group/django-users. 
>> > To view this discussion on the web visit 
>> > 
>> https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com.
>>  
>>
>> > 
>> > For more options, visit https://groups.google.com/d/optout. 
>>
>>
>>
>> -- 
>>
>> Cordialement, Coues Ludovic 
>> +336 148 743 42 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cd705a69-1235-4ef2-9eb1-7af543e453b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie to Novice – Using Admin DateTime Picker in your Form

2016-09-19 Thread Nate Granatir
Just realized this thread was not necessarily about filters for the admin; 
in the case of using custom forms/views Django daterange filter may not be 
a good option.

On Thursday, March 19, 2009 at 8:37:56 AM UTC-5, Paul Nema wrote:
>
> I've noticed many people new to Django (and sometimes also new to Python) 
> often post the same/similar questions in various forums. How to I get 
> something to work and/or do you have an example for X. As I've also 
> experienced this problem I've decided to post my little solution. Its not 
> the only way to do this, just the way I did it. Hopefully this will provide 
> the answer people are searching for or at least get them started. I guess 
> it will also serve as a quick code review by those so inclined to comment.
>
>
> You've probably heard of DRY but I think something is missing. There 
> should also be a Don't Repeat Other's Work (DROW) when they already solved 
> the problem. Thus another motivation to post this.  On a side note there is 
> a bit of debate out there about using the Django AdminDateWidget verse 
> other solutions (Jquery, etc). Your decision to make but why increase 
> dependencies when you don't have to.
>
>
> As I'm still learning Django everything in the code below may not be 
> required but I'm listing it anyway. You may need to modify to your 
> particular environment.  As I don't have a blog to post this I'm sending it 
> to this group. I'm open to any suggestions for a better place to post this.
>
>
> For this example I will focus on adding a date picker for date of birth 
> (dob) and a date time picker for sponsor sign date (sponsor_sign_date). Key 
> items are in *Bold*.
>
>
> Another reference to adding the AdminDateTime widget is here: 
> http://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form
>
>
>
>
> ---
>
> My top level (django-admin.py startproject izbo) directory Structure:
>
> mylogin@LX-D620:~/dev/izbo$ ll
>
> drwxrwxr-x 2 mylogin mylogin 4096 2009-03-17 10:52 account/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:53 add/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 04:34 adjudicator/ 
>
> drwxrwxr-x 2 mylogin mylogin 4096 2009-03-18 09:43 application/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 10:06 contract/ 
>
> drwxrwxrwx 2 mylogin mylogin 4096 2009-03-18 09:49 DB/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:51 employer/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 04:34 entity/ 
>
> -rw-r--r-- 1 mylogin mylogin 207 2009-03-08 04:54 exclude 
>
> drwxrwxrwx 2 mylogin mylogin 4096 2009-03-18 10:06 gzbo/ 
>
> -rw-r--r-- 1 mylogin mylogin 0 2009-01-06 04:55 __init__.py 
>
> -rw-r--r-- 1 mylogin mylogin 546 2009-01-06 04:55 manage.py 
>
> drwxrwxrwx 5 mylogin mylogin 4096 2009-02-08 12:35 media/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:53 member/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:52 note/ 
>
> drwxr-xr-x 2 mylogin mylogin 4096 2009-02-20 12:47 search/ 
>
> -rw-r--r-- 1 mylogin mylogin 4192 2009-03-05 23:39 settings.py 
>
> drwxrwxrwx12 mylogin mylogin 4096 2009-03-16 11:48 templates/ 
>
> -rw-r--r-- 1 mylogin mylogin 2118 2009-03-16 11:16 urls.py 
>
>
> --
>
> Media directory Listing:
>
> mylogin@LX-D620:~/dev/izbo/media$ ll 
>
> total 12 
>
> drwxr-xr-x 5 mylogin mylogin 4096 2009-03-18 10:56 admin/ 
>
> drwxrwxrwx 2 mylogin mylogin 4096 2009-02-07 15:45 css/ 
>
> drwxrwxrwx 2 mylogin mylogin 4096 2009-01-27 10:07 images/ 
>
> lrwxrwxrwx 1 mylogin mylogin 36 2009-03-18 11:07 img -> 
> /home/mylogin/dev/izbo/media/admin/img/ 
>
>
> * Note: admin/ is 'cp -r' of directory 
> /usr/lib/python2.5/site-packages/django/contrib/admin/media.  Then I linked 
> the img directory.
>
>
>
> 
>
> In my “settings.py”
>
>
> import os.path 
>
> PROJECT_DIR = os.path.dirname(__file__) 
>
>
> MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media') 
>
> MEDIA_URL = 'http://www.izbo.com/media/'
>
> *ADMIN_MEDIA_PREFIX = '/media/admin/'*
>
> TEMPLATE_DIRS = ( 
>
>os.path.join(PROJECT_DIR, 'templates'),
>
>...
>
> )
>
>
> 
>
> In my top level “urls.py” file
>
> *from django.contrib import admin * 
>
>
> urlpatterns = patterns('', 
>
># Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
>
># to INSTALLED_APPS to enable admin documentation: 
>
>(r'^admin/doc/', include('django.contrib.admindocs.urls')), 
>
>
>*# Add this to get widgets.AdminDateWidget() working for non is_staff, 
> is_superuser * 
>
>*# This must be placed before (r'^admin/(.*)', admin.site.root), as 
> that gobals up everything * 
>
>*(r'^admin/jsi18n/$', 'django.views.i18n.javascript_catalog'), * 
>
>
># Uncomment the next line to enable the admin: 
>
>(r'^admin/(.*)', admin.site.root), 
>
>
># IZBO related URLs 
>
>(r'^$', splash), 
>
>.
>
> )
>
>
>
> -
>
> In “gzbo/models.py” I have my class
>
>
> # 
>
> # Application 
>
> # 
>
> class App (Record) : 
>
> # P

Re: Newbie to Novice – Using Admin DateTime Picker in your Form

2016-09-19 Thread Mayank Rungta
I am looking at making custom forms look like Django admin forms with the
widgets in place. Also, I like to do a similar thing for displaying tables.
I used a combination of plugins for sorting, filters and displaying tables
with pagination. The result was not as good. What I am hoping is to find an
easy way to reuse the features already available with django admin. But it
appears this approach is not recommended and I saw a post by a django
maintainer saying it is not likely to make this any easier in near future.
Would have been nice to have this in place, as there are a plethora of
plugins in Django & Java Script out there and sifting through them is
difficult for a newbie like me.

Looking for suitable inputs on this forum.

Thanks in advance,
mynk

On Mon, Sep 19, 2016 at 8:04 PM, Nate Granatir 
wrote:

> Just realized this thread was not necessarily about filters for the admin;
> in the case of using custom forms/views Django daterange filter may not be
> a good option.
>
>
> On Thursday, March 19, 2009 at 8:37:56 AM UTC-5, Paul Nema wrote:
>>
>> I've noticed many people new to Django (and sometimes also new to Python)
>> often post the same/similar questions in various forums. How to I get
>> something to work and/or do you have an example for X. As I've also
>> experienced this problem I've decided to post my little solution. Its not
>> the only way to do this, just the way I did it. Hopefully this will provide
>> the answer people are searching for or at least get them started. I guess
>> it will also serve as a quick code review by those so inclined to comment.
>>
>>
>> You've probably heard of DRY but I think something is missing. There
>> should also be a Don't Repeat Other's Work (DROW) when they already solved
>> the problem. Thus another motivation to post this.  On a side note there is
>> a bit of debate out there about using the Django AdminDateWidget verse
>> other solutions (Jquery, etc). Your decision to make but why increase
>> dependencies when you don't have to.
>>
>>
>> As I'm still learning Django everything in the code below may not be
>> required but I'm listing it anyway. You may need to modify to your
>> particular environment.  As I don't have a blog to post this I'm sending it
>> to this group. I'm open to any suggestions for a better place to post this.
>>
>>
>> For this example I will focus on adding a date picker for date of birth
>> (dob) and a date time picker for sponsor sign date (sponsor_sign_date). Key
>> items are in *Bold*.
>>
>>
>> Another reference to adding the AdminDateTime widget is here:
>> http://stackoverflow.com/questions/38601/using-django-time-
>> date-widgets-in-custom-form
>>
>>
>>
>>
>> ---
>>
>> My top level (django-admin.py startproject izbo) directory Structure:
>>
>> mylogin@LX-D620:~/dev/izbo$ ll
>>
>> drwxrwxr-x 2 mylogin mylogin 4096 2009-03-17 10:52 account/
>>
>> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:53 add/
>>
>> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 04:34 adjudicator/
>>
>> drwxrwxr-x 2 mylogin mylogin 4096 2009-03-18 09:43 application/
>>
>> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 10:06 contract/
>>
>> drwxrwxrwx 2 mylogin mylogin 4096 2009-03-18 09:49 DB/
>>
>> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:51 employer/
>>
>> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 04:34 entity/
>>
>> -rw-r--r-- 1 mylogin mylogin 207 2009-03-08 04:54 exclude
>>
>> drwxrwxrwx 2 mylogin mylogin 4096 2009-03-18 10:06 gzbo/
>>
>> -rw-r--r-- 1 mylogin mylogin 0 2009-01-06 04:55 __init__.py
>>
>> -rw-r--r-- 1 mylogin mylogin 546 2009-01-06 04:55 manage.py
>>
>> drwxrwxrwx 5 mylogin mylogin 4096 2009-02-08 12:35 media/
>>
>> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:53 member/
>>
>> drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:52 note/
>>
>> drwxr-xr-x 2 mylogin mylogin 4096 2009-02-20 12:47 search/
>>
>> -rw-r--r-- 1 mylogin mylogin 4192 2009-03-05 23:39 settings.py
>>
>> drwxrwxrwx12 mylogin mylogin 4096 2009-03-16 11:48 templates/
>>
>> -rw-r--r-- 1 mylogin mylogin 2118 2009-03-16 11:16 urls.py
>>
>>
>> --
>>
>> Media directory Listing:
>>
>> mylogin@LX-D620:~/dev/izbo/media$ ll
>>
>> total 12
>>
>> drwxr-xr-x 5 mylogin mylogin 4096 2009-03-18 10:56 admin/
>>
>> drwxrwxrwx 2 mylogin mylogin 4096 2009-02-07 15:45 css/
>>
>> drwxrwxrwx 2 mylogin mylogin 4096 2009-01-27 10:07 images/
>>
>> lrwxrwxrwx 1 mylogin mylogin 36 2009-03-18 11:07 img ->
>> /home/mylogin/dev/izbo/media/admin/img/
>>
>>
>> * Note: admin/ is 'cp -r' of directory /usr/lib/python2.5/site-packag
>> es/django/contrib/admin/media.  Then I linked the img directory.
>>
>>
>>
>> 
>>
>> In my “settings.py”
>>
>>
>> import os.path
>>
>> PROJECT_DIR = os.path.dirname(__file__)
>>
>>
>> MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
>>
>> MEDIA_URL = 'http://www.izbo.com/media/'
>>
>> *ADMIN_MEDIA_PREFIX = '/media/admin/'*
>>
>> TEMPLATE_DIRS = (
>>
>>os.path.join(PROJECT_DIR, 'templates'),
>>
>>...
>>
>> )
>>
>>
>> -

Re: A public cloud with django backend

2016-09-19 Thread 'Tom Evans' via Django users
On Thu, Sep 15, 2016 at 8:21 AM, Rahul Doshi  wrote:
> Hi ,I want to setup  a dropbox like server with django. So far i have
> achieved uploading files onto a location .I want these files to show up on
> browser which they do(while saving file to the location I indexed an entry
> in the Db so i just print the file names from the DB(POSTGRESQL).Now i want
> to provide users options to view or download the files.I put a link on it
> and tried ,it did not work since it shows an javascript error "NOT ALLOWED
> TO LOAD LOCAL RECOURCE" . All uploaded files are loaded in C drive of my
> laptop. Where else do i load so that javascript can load it? Attaching my
> code ..thanks in advance.


For security reasons, browser do not allow internet zone sites to
access local content from javascript (otherwise, any site could read
any accessible file from your computer and submit it, well, anywhere).

Serve the files from the webserver instead.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1LaHEEpfm_9xVx2xeVq-eJQSoevSi2eKuK2wLtj%3DwXvcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting FK field in list view

2016-09-19 Thread RompePC
Nope, it isn't a lookup separator: for simply understanding, I wanna get 
the FK widget (the HTML, the select, all of that) that is show when adding 
an object that has a related key (say, adding a new City and selecting 
its Country in the same model, 'cause a City belongs to a Country) so I can 
use it anywhere in my panel.

El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham escribió:
>
> Is your request https://code.djangoproject.com/ticket/10743?
>
> On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:
>>
>> Yep, the second one is what I wanna do. Althrough they aren't inlines, 
>> but like FK filter choices in the list view (not the default ones).
>> It's hard to understand, I know it can be done, but don't know how. Will 
>> keep searching and throw some light here when done.
>>
>> El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
>> escribió:
>>>
>>> I looked into it after my first reply and my suggestion was wrong. 
>>>
>>> If you want to display the value of a foreign key object's property in 
>>> the admin page to select an object to change, you can add a callable 
>>> to list_display. 
>>> For exemple, ` list_display = ('title', lambda o: getattr(o.author, 
>>> "name", "-"),) `. The callable will get one argument, an instance of 
>>> the model. 
>>>
>>> If you want to display a field to change a property of a foreign key 
>>> object, I haven't found a way. Best option might be a inline model 
>>> admin. 
>>>
>>> 2016-09-19 12:24 GMT+02:00 RompePC : 
>>> > Hi again, I didn't have time to try it until now, but I just realized 
>>> that 
>>> > maybe I asked the wrong way. What I wanna do is to render the widget 
>>> > associated to that FK in the panel, not its name. So I need to pass 
>>> the 
>>> > field or its rendered content to the context, but I don't know how to 
>>> do get 
>>> > it. 
>>> > 
>>> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic coues 
>>> > escribió: 
>>> >> 
>>> >> Have you tried something like author__name ? Assuming a model with an 
>>> >> author foreign key. 
>>> >> 
>>> >> 2016-09-16 8:56 GMT+02:00 RompePC : 
>>> >> > I would like to pass to the list display view a FK field of the 
>>> admin 
>>> >> > form 
>>> >> > (like the ones when adding a new row). But I don't see the way of 
>>> doing 
>>> >> > it, 
>>> >> > although I've searched along many properties of the model admin to 
>>> get 
>>> >> > it. 
>>> >> > 
>>> >> > Anyone did something like that before? 
>>> >> > 
>>> >> > -- 
>>> >> > You received this message because you are subscribed to the Google 
>>> >> > Groups 
>>> >> > "Django users" group. 
>>> >> > To unsubscribe from this group and stop receiving emails from it, 
>>> send 
>>> >> > an 
>>> >> > email to django-users...@googlegroups.com. 
>>> >> > To post to this group, send email to django...@googlegroups.com. 
>>> >> > Visit this group at https://groups.google.com/group/django-users. 
>>> >> > To view this discussion on the web visit 
>>> >> > 
>>> >> > 
>>> https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
>>>  
>>>
>>> >> > For more options, visit https://groups.google.com/d/optout. 
>>> >> 
>>> >> 
>>> >> 
>>> >> -- 
>>> >> 
>>> >> Cordialement, Coues Ludovic 
>>> >> +336 148 743 42 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> Groups 
>>> > "Django users" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> an 
>>> > email to django-users...@googlegroups.com. 
>>> > To post to this group, send email to django...@googlegroups.com. 
>>> > Visit this group at https://groups.google.com/group/django-users. 
>>> > To view this discussion on the web visit 
>>> > 
>>> https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com.
>>>  
>>>
>>> > 
>>> > For more options, visit https://groups.google.com/d/optout. 
>>>
>>>
>>>
>>> -- 
>>>
>>> Cordialement, Coues Ludovic 
>>> +336 148 743 42 
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e290771a-d81c-4bf3-8535-2154a5265f94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting FK field in list view

2016-09-19 Thread Tim Graham
ModelAdmin.list_editable?

https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable

On Monday, September 19, 2016 at 11:05:22 AM UTC-4, RompePC wrote:
>
> Nope, it isn't a lookup separator: for simply understanding, I wanna get 
> the FK widget (the HTML, the select, all of that) that is show when adding 
> an object that has a related key (say, adding a new City and selecting 
> its Country in the same model, 'cause a City belongs to a Country) so I can 
> use it anywhere in my panel.
>
> El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham escribió:
>>
>> Is your request https://code.djangoproject.com/ticket/10743?
>>
>> On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:
>>>
>>> Yep, the second one is what I wanna do. Althrough they aren't inlines, 
>>> but like FK filter choices in the list view (not the default ones).
>>> It's hard to understand, I know it can be done, but don't know how. Will 
>>> keep searching and throw some light here when done.
>>>
>>> El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
>>> escribió:

 I looked into it after my first reply and my suggestion was wrong. 

 If you want to display the value of a foreign key object's property in 
 the admin page to select an object to change, you can add a callable 
 to list_display. 
 For exemple, ` list_display = ('title', lambda o: getattr(o.author, 
 "name", "-"),) `. The callable will get one argument, an instance of 
 the model. 

 If you want to display a field to change a property of a foreign key 
 object, I haven't found a way. Best option might be a inline model 
 admin. 

 2016-09-19 12:24 GMT+02:00 RompePC : 
 > Hi again, I didn't have time to try it until now, but I just realized 
 that 
 > maybe I asked the wrong way. What I wanna do is to render the widget 
 > associated to that FK in the panel, not its name. So I need to pass 
 the 
 > field or its rendered content to the context, but I don't know how to 
 do get 
 > it. 
 > 
 > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic coues 
 > escribió: 
 >> 
 >> Have you tried something like author__name ? Assuming a model with 
 an 
 >> author foreign key. 
 >> 
 >> 2016-09-16 8:56 GMT+02:00 RompePC : 
 >> > I would like to pass to the list display view a FK field of the 
 admin 
 >> > form 
 >> > (like the ones when adding a new row). But I don't see the way of 
 doing 
 >> > it, 
 >> > although I've searched along many properties of the model admin to 
 get 
 >> > it. 
 >> > 
 >> > Anyone did something like that before? 
 >> > 
 >> > -- 
 >> > You received this message because you are subscribed to the Google 
 >> > Groups 
 >> > "Django users" group. 
 >> > To unsubscribe from this group and stop receiving emails from it, 
 send 
 >> > an 
 >> > email to django-users...@googlegroups.com. 
 >> > To post to this group, send email to django...@googlegroups.com. 
 >> > Visit this group at https://groups.google.com/group/django-users. 
 >> > To view this discussion on the web visit 
 >> > 
 >> > 
 https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
  

 >> > For more options, visit https://groups.google.com/d/optout. 
 >> 
 >> 
 >> 
 >> -- 
 >> 
 >> Cordialement, Coues Ludovic 
 >> +336 148 743 42 
 > 
 > -- 
 > You received this message because you are subscribed to the Google 
 Groups 
 > "Django users" group. 
 > To unsubscribe from this group and stop receiving emails from it, 
 send an 
 > email to django-users...@googlegroups.com. 
 > To post to this group, send email to django...@googlegroups.com. 
 > Visit this group at https://groups.google.com/group/django-users. 
 > To view this discussion on the web visit 
 > 
 https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com.
  

 > 
 > For more options, visit https://groups.google.com/d/optout. 



 -- 

 Cordialement, Coues Ludovic 
 +336 148 743 42 

>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9d22ace8-52f8-4acd-a9e8-95cc705dc6a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to do a generic field in an app.

2016-09-19 Thread Jonty Needham
I want to have a model that has a foreignkey to a model from another app.
The app can be one of many.

So far I've come up with a two field solution with:

model_type = ForeignKey(ContentType)
pk_field = PositiveIntegerField()


with an appropriate getter. Is there a better way to do this? It feels like
this has already been solved in a known "good" way.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANOQRbxmrch43CSciPSXNxsQh8EyWUWhKu4u2Rx%3DeJoRb0Zjsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting FK field in list view

2016-09-19 Thread RompePC
Nope, as I wanna the ModelChoiceField rendered in the filter list I did in 
my own (not the sided one).

El lunes, 19 de septiembre de 2016, 18:15:17 (UTC+2), Tim Graham escribió:
>
> ModelAdmin.list_editable?
>
>
> https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable
>
> On Monday, September 19, 2016 at 11:05:22 AM UTC-4, RompePC wrote:
>>
>> Nope, it isn't a lookup separator: for simply understanding, I wanna get 
>> the FK widget (the HTML, the select, all of that) that is show when adding 
>> an object that has a related key (say, adding a new City and selecting 
>> its Country in the same model, 'cause a City belongs to a Country) so I can 
>> use it anywhere in my panel.
>>
>> El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham escribió:
>>>
>>> Is your request https://code.djangoproject.com/ticket/10743?
>>>
>>> On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:

 Yep, the second one is what I wanna do. Althrough they aren't inlines, 
 but like FK filter choices in the list view (not the default ones).
 It's hard to understand, I know it can be done, but don't know how. 
 Will keep searching and throw some light here when done.

 El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
 escribió:
>
> I looked into it after my first reply and my suggestion was wrong. 
>
> If you want to display the value of a foreign key object's property in 
> the admin page to select an object to change, you can add a callable 
> to list_display. 
> For exemple, ` list_display = ('title', lambda o: getattr(o.author, 
> "name", "-"),) `. The callable will get one argument, an instance of 
> the model. 
>
> If you want to display a field to change a property of a foreign key 
> object, I haven't found a way. Best option might be a inline model 
> admin. 
>
> 2016-09-19 12:24 GMT+02:00 RompePC : 
> > Hi again, I didn't have time to try it until now, but I just 
> realized that 
> > maybe I asked the wrong way. What I wanna do is to render the widget 
> > associated to that FK in the panel, not its name. So I need to pass 
> the 
> > field or its rendered content to the context, but I don't know how 
> to do get 
> > it. 
> > 
> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic 
> coues 
> > escribió: 
> >> 
> >> Have you tried something like author__name ? Assuming a model with 
> an 
> >> author foreign key. 
> >> 
> >> 2016-09-16 8:56 GMT+02:00 RompePC : 
> >> > I would like to pass to the list display view a FK field of the 
> admin 
> >> > form 
> >> > (like the ones when adding a new row). But I don't see the way of 
> doing 
> >> > it, 
> >> > although I've searched along many properties of the model admin 
> to get 
> >> > it. 
> >> > 
> >> > Anyone did something like that before? 
> >> > 
> >> > -- 
> >> > You received this message because you are subscribed to the 
> Google 
> >> > Groups 
> >> > "Django users" group. 
> >> > To unsubscribe from this group and stop receiving emails from it, 
> send 
> >> > an 
> >> > email to django-users...@googlegroups.com. 
> >> > To post to this group, send email to django...@googlegroups.com. 
> >> > Visit this group at https://groups.google.com/group/django-users. 
>
> >> > To view this discussion on the web visit 
> >> > 
> >> > 
> https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
>  
>
> >> > For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> 
> >> 
> >> -- 
> >> 
> >> Cordialement, Coues Ludovic 
> >> +336 148 743 42 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, 
> send an 
> > email to django-users...@googlegroups.com. 
> > To post to this group, send email to django...@googlegroups.com. 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@go

Re: Setting FK field in list view

2016-09-19 Thread Tim Graham
I still don't understand the goal. Maybe you can mock up a screenshot 
and/or give a code example.

On Monday, September 19, 2016 at 12:41:32 PM UTC-4, RompePC wrote:
>
> Nope, as I wanna the ModelChoiceField rendered in the filter list I did in 
> my own (not the sided one).
>
> El lunes, 19 de septiembre de 2016, 18:15:17 (UTC+2), Tim Graham escribió:
>>
>> ModelAdmin.list_editable?
>>
>>
>> https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable
>>
>> On Monday, September 19, 2016 at 11:05:22 AM UTC-4, RompePC wrote:
>>>
>>> Nope, it isn't a lookup separator: for simply understanding, I wanna get 
>>> the FK widget (the HTML, the select, all of that) that is show when adding 
>>> an object that has a related key (say, adding a new City and selecting 
>>> its Country in the same model, 'cause a City belongs to a Country) so I can 
>>> use it anywhere in my panel.
>>>
>>> El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham 
>>> escribió:

 Is your request https://code.djangoproject.com/ticket/10743?

 On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:
>
> Yep, the second one is what I wanna do. Althrough they aren't inlines, 
> but like FK filter choices in the list view (not the default ones).
> It's hard to understand, I know it can be done, but don't know how. 
> Will keep searching and throw some light here when done.
>
> El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
> escribió:
>>
>> I looked into it after my first reply and my suggestion was wrong. 
>>
>> If you want to display the value of a foreign key object's property 
>> in 
>> the admin page to select an object to change, you can add a callable 
>> to list_display. 
>> For exemple, ` list_display = ('title', lambda o: getattr(o.author, 
>> "name", "-"),) `. The callable will get one argument, an instance of 
>> the model. 
>>
>> If you want to display a field to change a property of a foreign key 
>> object, I haven't found a way. Best option might be a inline model 
>> admin. 
>>
>> 2016-09-19 12:24 GMT+02:00 RompePC : 
>> > Hi again, I didn't have time to try it until now, but I just 
>> realized that 
>> > maybe I asked the wrong way. What I wanna do is to render the 
>> widget 
>> > associated to that FK in the panel, not its name. So I need to pass 
>> the 
>> > field or its rendered content to the context, but I don't know how 
>> to do get 
>> > it. 
>> > 
>> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic 
>> coues 
>> > escribió: 
>> >> 
>> >> Have you tried something like author__name ? Assuming a model with 
>> an 
>> >> author foreign key. 
>> >> 
>> >> 2016-09-16 8:56 GMT+02:00 RompePC : 
>> >> > I would like to pass to the list display view a FK field of the 
>> admin 
>> >> > form 
>> >> > (like the ones when adding a new row). But I don't see the way 
>> of doing 
>> >> > it, 
>> >> > although I've searched along many properties of the model admin 
>> to get 
>> >> > it. 
>> >> > 
>> >> > Anyone did something like that before? 
>> >> > 
>> >> > -- 
>> >> > You received this message because you are subscribed to the 
>> Google 
>> >> > Groups 
>> >> > "Django users" group. 
>> >> > To unsubscribe from this group and stop receiving emails from 
>> it, send 
>> >> > an 
>> >> > email to django-users...@googlegroups.com. 
>> >> > To post to this group, send email to django...@googlegroups.com. 
>>
>> >> > Visit this group at https://groups.google.com/group/django-users. 
>>
>> >> > To view this discussion on the web visit 
>> >> > 
>> >> > 
>> https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
>>  
>>
>> >> > For more options, visit https://groups.google.com/d/optout. 
>> >> 
>> >> 
>> >> 
>> >> -- 
>> >> 
>> >> Cordialement, Coues Ludovic 
>> >> +336 148 743 42 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups 
>> > "Django users" group. 
>> > To unsubscribe from this group and stop receiving emails from it, 
>> send an 
>> > email to django-users...@googlegroups.com. 
>> > To post to this group, send email to django...@googlegroups.com. 
>> > Visit this group at https://groups.google.com/group/django-users. 
>> > To view this discussion on the web visit 
>> > 
>> https://groups.google.com/d/msgid/django-users/a99dac72-a527-4968-92f5-0a4c405c1778%40googlegroups.com.
>>  
>>
>> > 
>> > For more options, visit https://groups.google.com/d/optout. 
>>
>>
>>
>> -- 
>>
>> Cordialement, Coues

Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied

2016-09-19 Thread premdjango
Im trying to run the tests in Django but get the following error. 


(djangodev) Anands-MacBook-Pro:tests premlaks$ ./runtests.py 
--settings=test_sqlite requests


  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/query.py",
 
line 1072, in _fetch_all

self._result_cache = list(self.iterator())

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/query.py",
 
line 125, in __iter__

for row in compiler.results_iter():

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/sql/compiler.py",
 
line 802, in results_iter

results = self.execute_sql(MULTI)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/sql/compiler.py",
 
line 853, in execute_sql

cursor.execute(sql, params)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/utils.py",
 
line 67, in execute

return self.cursor.execute(sql, params)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/utils.py",
 
line 94, in __exit__

six.reraise(dj_exc_type, dj_exc_value, traceback)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/utils/six.py",
 
line 685, in reraise

raise value.with_traceback(tb)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/utils.py",
 
line 67, in execute

return self.cursor.execute(sql, params)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/sqlite3/base.py",
 
line 334, in execute

return Database.Cursor.execute(self, query, params)

django.db.utils.ProgrammingError: Incorrect number of bindings supplied. 
The current statement uses 0, and there are 1 supplied.



and here is my test_sqllite file.


DATABASES = {

'default': {

'ENGINE': 'django.db.backends.sqlite3',

},

#'other': {

#'ENGINE': 'django.db.backends.sqlite3',

#}

}


SECRET_KEY = "django_tests_secret_key"


# Use a fast hasher to speed up tests.

PASSWORD_HASHERS = [

'django.contrib.auth.hashers.MD5PasswordHasher',

]




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/863b5d59-897b-4b66-ad39-2dce78effd42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting FK field in list view

2016-09-19 Thread RompePC
Yeah, I'm so sorry, it's hard to understand. I'll post an image of the 
Django tutorial of what I mean:


I want that the FK widget (the one for *Question*) could be available in 
other panel admin's views (as listing) (with no CRUD icons along). The 
problem is to get the field correctly, as I just only get str 
representations of the field or the widget.

El lunes, 19 de septiembre de 2016, 18:53:56 (UTC+2), Tim Graham escribió:
>
> I still don't understand the goal. Maybe you can mock up a screenshot 
> and/or give a code example.
>
> On Monday, September 19, 2016 at 12:41:32 PM UTC-4, RompePC wrote:
>>
>> Nope, as I wanna the ModelChoiceField rendered in the filter list I did 
>> in my own (not the sided one).
>>
>> El lunes, 19 de septiembre de 2016, 18:15:17 (UTC+2), Tim Graham escribió:
>>>
>>> ModelAdmin.list_editable?
>>>
>>>
>>> https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable
>>>
>>> On Monday, September 19, 2016 at 11:05:22 AM UTC-4, RompePC wrote:

 Nope, it isn't a lookup separator: for simply understanding, I wanna 
 get the FK widget (the HTML, the select, all of that) that is show when 
 adding an object that has a related key (say, adding a new City and 
 selecting its Country in the same model, 'cause a City belongs to a 
 Country) so I can use it anywhere in my panel.

 El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham 
 escribió:
>
> Is your request https://code.djangoproject.com/ticket/10743?
>
> On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:
>>
>> Yep, the second one is what I wanna do. Althrough they aren't 
>> inlines, but like FK filter choices in the list view (not the default 
>> ones).
>> It's hard to understand, I know it can be done, but don't know how. 
>> Will keep searching and throw some light here when done.
>>
>> El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
>> escribió:
>>>
>>> I looked into it after my first reply and my suggestion was wrong. 
>>>
>>> If you want to display the value of a foreign key object's property 
>>> in 
>>> the admin page to select an object to change, you can add a callable 
>>> to list_display. 
>>> For exemple, ` list_display = ('title', lambda o: getattr(o.author, 
>>> "name", "-"),) `. The callable will get one argument, an instance of 
>>> the model. 
>>>
>>> If you want to display a field to change a property of a foreign key 
>>> object, I haven't found a way. Best option might be a inline model 
>>> admin. 
>>>
>>> 2016-09-19 12:24 GMT+02:00 RompePC : 
>>> > Hi again, I didn't have time to try it until now, but I just 
>>> realized that 
>>> > maybe I asked the wrong way. What I wanna do is to render the 
>>> widget 
>>> > associated to that FK in the panel, not its name. So I need to 
>>> pass the 
>>> > field or its rendered content to the context, but I don't know how 
>>> to do get 
>>> > it. 
>>> > 
>>> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic 
>>> coues 
>>> > escribió: 
>>> >> 
>>> >> Have you tried something like author__name ? Assuming a model 
>>> with an 
>>> >> author foreign key. 
>>> >> 
>>> >> 2016-09-16 8:56 GMT+02:00 RompePC : 
>>> >> > I would like to pass to the list display view a FK field of the 
>>> admin 
>>> >> > form 
>>> >> > (like the ones when adding a new row). But I don't see the way 
>>> of doing 
>>> >> > it, 
>>> >> > although I've searched along many properties of the model admin 
>>> to get 
>>> >> > it. 
>>> >> > 
>>> >> > Anyone did something like that before? 
>>> >> > 
>>> >> > -- 
>>> >> > You received this message because you are subscribed to the 
>>> Google 
>>> >> > Groups 
>>> >> > "Django users" group. 
>>> >> > To unsubscribe from this group and stop receiving emails from 
>>> it, send 
>>> >> > an 
>>> >> > email to django-users...@googlegroups.com. 
>>> >> > To post to this group, send email to django...@googlegroups.com. 
>>>
>>> >> > Visit this group at 
>>> https://groups.google.com/group/django-users. 
>>> >> > To view this discussion on the web visit 
>>> >> > 
>>> >> > 
>>> https://groups.google.com/d/msgid/django-users/d4cfbc3a-8668-4576-8d5c-c04cdd0eb1b2%40googlegroups.com.
>>>  
>>>
>>> >> > For more options, visit https://groups.google.com/d/optout. 
>>> >> 
>>> >> 
>>> >> 
>>> >> -- 
>>> >> 
>>> >> Cordialement, Coues Ludovic 
>>> >> +336 148 743 42 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed 

Re: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied

2016-09-19 Thread Tim Graham
Can you print query and params where the error happens?

On Monday, September 19, 2016 at 12:56:12 PM UTC-4, premdjango wrote:
>
> Im trying to run the tests in Django but get the following error. 
>
>
> (djangodev) Anands-MacBook-Pro:tests premlaks$ ./runtests.py 
> --settings=test_sqlite requests
>
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/query.py",
>  
> line 1072, in _fetch_all
>
> self._result_cache = list(self.iterator())
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/query.py",
>  
> line 125, in __iter__
>
> for row in compiler.results_iter():
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/sql/compiler.py",
>  
> line 802, in results_iter
>
> results = self.execute_sql(MULTI)
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/sql/compiler.py",
>  
> line 853, in execute_sql
>
> cursor.execute(sql, params)
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/utils.py",
>  
> line 67, in execute
>
> return self.cursor.execute(sql, params)
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/utils.py",
>  
> line 94, in __exit__
>
> six.reraise(dj_exc_type, dj_exc_value, traceback)
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/utils/six.py",
>  
> line 685, in reraise
>
> raise value.with_traceback(tb)
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/utils.py",
>  
> line 67, in execute
>
> return self.cursor.execute(sql, params)
>
>   File 
> "/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/sqlite3/base.py",
>  
> line 334, in execute
>
> return Database.Cursor.execute(self, query, params)
>
> django.db.utils.ProgrammingError: Incorrect number of bindings supplied. 
> The current statement uses 0, and there are 1 supplied.
>
>
>
> and here is my test_sqllite file.
>
>
> DATABASES = {
>
> 'default': {
>
> 'ENGINE': 'django.db.backends.sqlite3',
>
> },
>
> #'other': {
>
> #'ENGINE': 'django.db.backends.sqlite3',
>
> #}
>
> }
>
>
> SECRET_KEY = "django_tests_secret_key"
>
>
> # Use a fast hasher to speed up tests.
>
> PASSWORD_HASHERS = [
>
> 'django.contrib.auth.hashers.MD5PasswordHasher',
>
> ]
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/25256f6d-d18c-48bb-b3de-6b1bb9a5bcf9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting FK field in list view

2016-09-19 Thread Tim Graham
So basically ModelAdmin.list_editable but without the icons on the side?

If you never want the inline editing buttons for all models, you could 
override the admin/related_widget_wrapper.html template and remove the 
buttons.
https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/related_widget_wrapper.html

Otherwise, I'm out of (simple) ideas.

On Monday, September 19, 2016 at 12:58:44 PM UTC-4, RompePC wrote:
>
> Yeah, I'm so sorry, it's hard to understand. I'll post an image of the 
> Django tutorial of what I mean:
>
>
> 
> I want that the FK widget (the one for *Question*) could be available in 
> other panel admin's views (as listing) (with no CRUD icons along). The 
> problem is to get the field correctly, as I just only get str 
> representations of the field or the widget.
>
> El lunes, 19 de septiembre de 2016, 18:53:56 (UTC+2), Tim Graham escribió:
>>
>> I still don't understand the goal. Maybe you can mock up a screenshot 
>> and/or give a code example.
>>
>> On Monday, September 19, 2016 at 12:41:32 PM UTC-4, RompePC wrote:
>>>
>>> Nope, as I wanna the ModelChoiceField rendered in the filter list I did 
>>> in my own (not the sided one).
>>>
>>> El lunes, 19 de septiembre de 2016, 18:15:17 (UTC+2), Tim Graham 
>>> escribió:

 ModelAdmin.list_editable?


 https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable

 On Monday, September 19, 2016 at 11:05:22 AM UTC-4, RompePC wrote:
>
> Nope, it isn't a lookup separator: for simply understanding, I wanna 
> get the FK widget (the HTML, the select, all of that) that is show when 
> adding an object that has a related key (say, adding a new City and 
> selecting its Country in the same model, 'cause a City belongs to a 
> Country) so I can use it anywhere in my panel.
>
> El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham 
> escribió:
>>
>> Is your request https://code.djangoproject.com/ticket/10743?
>>
>> On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:
>>>
>>> Yep, the second one is what I wanna do. Althrough they aren't 
>>> inlines, but like FK filter choices in the list view (not the default 
>>> ones).
>>> It's hard to understand, I know it can be done, but don't know how. 
>>> Will keep searching and throw some light here when done.
>>>
>>> El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
>>> escribió:

 I looked into it after my first reply and my suggestion was wrong. 

 If you want to display the value of a foreign key object's property 
 in 
 the admin page to select an object to change, you can add a 
 callable 
 to list_display. 
 For exemple, ` list_display = ('title', lambda o: getattr(o.author, 
 "name", "-"),) `. The callable will get one argument, an instance 
 of 
 the model. 

 If you want to display a field to change a property of a foreign 
 key 
 object, I haven't found a way. Best option might be a inline model 
 admin. 

 2016-09-19 12:24 GMT+02:00 RompePC : 
 > Hi again, I didn't have time to try it until now, but I just 
 realized that 
 > maybe I asked the wrong way. What I wanna do is to render the 
 widget 
 > associated to that FK in the panel, not its name. So I need to 
 pass the 
 > field or its rendered content to the context, but I don't know 
 how to do get 
 > it. 
 > 
 > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic 
 coues 
 > escribió: 
 >> 
 >> Have you tried something like author__name ? Assuming a model 
 with an 
 >> author foreign key. 
 >> 
 >> 2016-09-16 8:56 GMT+02:00 RompePC : 
 >> > I would like to pass to the list display view a FK field of 
 the admin 
 >> > form 
 >> > (like the ones when adding a new row). But I don't see the way 
 of doing 
 >> > it, 
 >> > although I've searched along many properties of the model 
 admin to get 
 >> > it. 
 >> > 
 >> > Anyone did something like that before? 
 >> > 
 >> > -- 
 >> > You received this message because you are subscribed to the 
 Google 
 >> > Groups 
 >> > "Django users" group. 
 >> > To unsubscribe from this group and stop receiving emails from 
 it, send 
 >> > an 
 >> > email to django-users...@googlegroups.com. 
 >> > To post to this group, send email to 
 django...@googlegroups.co

Re: How to do a generic field in an app.

2016-09-19 Thread Tim Graham
Do you know about 
https://docs.djangoproject.com/en/stable/ref/contrib/contenttypes/#generic-relations
 
?

On Monday, September 19, 2016 at 12:30:01 PM UTC-4, Jonty Needham wrote:
>
> I want to have a model that has a foreignkey to a model from another app. 
> The app can be one of many.
>
> So far I've come up with a two field solution with:
>
> model_type = ForeignKey(ContentType)
> pk_field = PositiveIntegerField()
>
>
> with an appropriate getter. Is there a better way to do this? It feels 
> like this has already been solved in a known "good" way.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a81b5dee-3a80-4a05-a3c1-d82b92d0395a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Howto to create custom admin commands with subcommands

2016-09-19 Thread anton
Hi,

is there an possibility to use
https://docs.python.org/3/library/argparse.html#sub-commands

in the custom admin commands so I can have subcommands like

manage.py mycommand subcommand1 choice1-for-subcommand1
manage.py mycommand subcommand1 choice2-for-subcommand1
manage.py mycommand subcommand2 variable-param


Preferably an official way.

I tested an example which I found in the internet
(forgot where), it worked in python 2.7 but didn't in python 3.5
(even when using the same django 1.10 base)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/nrpnt4%24ogs%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


django group authentication

2016-09-19 Thread sum abiut
Hi,
i am building an app using django, on login i want django to check for
users in a group before login users.
 For example, i want to redirect users from a group to page when they login.

please advise the best way to approached this.

cheers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y66dg4Yo0jmuQZjvFz0m20O4RB%3DG_fNmyKdoaTYeyOv%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


covert julian date to calander date

2016-09-19 Thread sum abiut
Hi,
how to you convert from Julian date to a Calender date. I am pulling data
from an MSSQL and i what to convert the Julian date to calender date before
displaying data on my template.

cheer

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5EMLiy4pxwnFbjheY2kR8VMuKEQzagH8nqMBXwnWNFug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied

2016-09-19 Thread premdjango
 

prem compiler sql ==  SELECT "django_migrations"."app", 
"django_migrations"."name" FROM "django_migrations"

prem compiler params ==  ()

prem debugwrapper==  

prem debugwrapper==  ['__class__', '__delattr__', '__dict__', '__dir__', 
'__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', 
'__hash__', '__init__', '__iter__', '__le__', '__lt__', '__module__', 
'__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', 
'__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'arraysize', 
'close', 'connection', 'convert_query', 'description', 'execute', 
'executemany', 'executescript', 'fetchall', 'fetchmany', 'fetchone', 
'lastrowid', 'row_factory', 'rowcount', 'setinputsizes', 'setoutputsize']

prem debugwrapper==  

Traceback (most recent call last):

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/utils.py",
 
line 67, in execute

return self.cursor.execute(sql, params)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/sqlite3/base.py",
 
line 334, in execute

return Database.Cursor.execute(self, query, params)

sqlite3.ProgrammingError: Incorrect number of bindings supplied. The 
current statement uses 0, and there are 1 supplied.


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "./runtests.py", line 483, in 

options.exclude_tags,

  File "./runtests.py", line 277, in django_tests

extra_tests=extra_tests,

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/test/runner.py",
 
line 587, in run_tests

old_config = self.setup_databases()

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/test/runner.py",
 
line 537, in setup_databases

self.parallel, **kwargs

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/test/utils.py",
 
line 181, in setup_databases

serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', 
True),

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/base/creation.py",
 
line 70, in create_test_db

run_syncdb=True,

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/core/management/__init__.py",
 
line 130, in call_command

return command.execute(*args, **defaults)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/core/management/base.py",
 
line 345, in execute

output = self.handle(*args, **options)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/core/management/commands/migrate.py",
 
line 83, in handle

executor = MigrationExecutor(connection, 
self.migration_progress_callback)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/migrations/executor.py",
 
line 20, in __init__

self.loader = MigrationLoader(self.connection)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/migrations/loader.py",
 
line 52, in __init__

self.build_graph()

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/migrations/loader.py",
 
line 209, in build_graph

self.applied_migrations = recorder.applied_migrations()

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/migrations/recorder.py",
 
line 66, in applied_migrations

return set(tuple(x) for x in self.migration_qs.values_list("app", 
"name"))

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/query.py",
 
line 256, in __iter__

self._fetch_all()

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/query.py",
 
line 1072, in _fetch_all

self._result_cache = list(self.iterator())

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/query.py",
 
line 125, in __iter__

for row in compiler.results_iter():

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/sql/compiler.py",
 
line 802, in results_iter

results = self.execute_sql(MULTI)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/models/sql/compiler.py",
 
line 853, in execute_sql

cursor.execute(sql, params)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/utils.py",
 
line 67, in execute

return self.cursor.execute(sql, params)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/utils.py",
 
line 94, in __exit__

six.reraise(dj_exc_type, dj_exc_value, traceback)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/utils/six.py",
 
line 685, in reraise

raise value.with_traceback(tb)

  File 
"/Users/premanandlakshmanan/Documents/django-contribute/django/django/db/backends/utils.py",
 
line 67, in execute

 

Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Shamaila Moazzam
hi
I am a beginner in django/python * :(*

I am making a dashboard of sellers App.
I am stuck in filtering orders of the products according to the logged in 
user(seller)

*sellers/models.py*

from django.conf import settings
from django.core.urlresolvers import reverse
from django.db import models
from django.contrib.auth.models import User



class SellerAccount(models.Model):
user = models.ForeignKey(User)
managers = models.ManyToManyField(settings.AUTH_USER_MODEL, 
related_name="manager_sellers", blank=True)
active = models.BooleanField(default=False)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)


def __unicode__(self):
return str(self.user.username)

def get_absolute_url(self):
return reverse("products:vendor_detail", kwargs={"vendor_name": 
self.user.username})


*orders/models.py*

class Order(models.Model):
status = models.CharField(max_length=120, choices=ORDER_STATUS_CHOICES, 
default='created')
cart = models.ForeignKey(Cart)
user = models.ForeignKey(UserCheckout, null=True)
billing_address = models.ForeignKey(UserAddress, 
related_name='billing_address', null=True)
shipping_address = models.ForeignKey(UserAddress, 
related_name='shipping_address', null=True)
shipping_total_price = models.DecimalField(max_digits=50, 
decimal_places=2, default=5.99)   
order_total = models.DecimalField(max_digits=50, decimal_places=2, )
order_id = models.CharField(max_length=20, null=True, blank=True)
paymethod = models.CharField(max_length=120, choices=CHOICES, 
default='CreditCard')


def __unicode__(self):
return str(self.cart.id)


*sellers/mixins.py*


import datetime

from django.db.models import Count, Min, Sum, Avg, Max

from dress.mixins import LoginRequiredMixin
from orders.models import Transaction, Order
from products.models import Product

from .models import SellerAccount



class SellerAccountMixin(LoginRequiredMixin, object):
account = None
products = []
transactions = []
orders = []

def get_account(self):
user = self.request.user
accounts = SellerAccount.objects.filter(user=user)
if accounts.exists() and accounts.count() == 1:
self.account = accounts.first()
return accounts.first()
return None

def get_products(self):
account = self.get_account()
products = Product.objects.filter(seller=account)
self.products = products
return products

   def get_sold_products(self):
products = self.get_products()
**
  THIS IS THE PROBLEM AREA ? i want to show orders of the 
products i got from (products = self.get_products()).
keeping this thing in mind that order is completed if its status 
set to be 'paid'
OR
In other words i want to show products of the user that is logged 
in if the status of that products are paid.
*
sold = Order.objects.all().filter('products')
return sold


*sellers/views.py*

class SellerDashboard(SellerAccountMixin, FormMixin, View):
form_class = NewSellerForm
success_url = "/seller/"
context["products"] = self.get_products()
   
context["sold_products"] = self.get_sold_products()

*sellers/dashboard.html*

{{ sold_products }}

i hope someone will definitely figure out my problem
regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ffb09df-c7ea-4128-b678-136b07f3bf4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Asad Jibran Ahmed
Hi,
 While you didn't show us the Product model, I assume it has a ForeignKey 
to the Order model. To filter for Products that have an Order with a sold 
status, you should look at the documentation for filtering on relationships 
at 
https://docs.djangoproject.com/en/1.10/topics/db/queries/#lookups-that-span-relationships.
Regards,
Jibran

On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam wrote:
>
> hi
> I am a beginner in django/python * :(*
>
> I am making a dashboard of sellers App.
> I am stuck in filtering orders of the products according to the logged in 
> user(seller)
>
> *sellers/models.py*
>
> from django.conf import settings
> from django.core.urlresolvers import reverse
> from django.db import models
> from django.contrib.auth.models import User
>
>
>
> class SellerAccount(models.Model):
> user = models.ForeignKey(User)
> managers = models.ManyToManyField(settings.AUTH_USER_MODEL, 
> related_name="manager_sellers", blank=True)
> active = models.BooleanField(default=False)
> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
>
>
> def __unicode__(self):
> return str(self.user.username)
>
> def get_absolute_url(self):
> return reverse("products:vendor_detail", kwargs={"vendor_name": 
> self.user.username})
>
>
> *orders/models.py*
>
> class Order(models.Model):
> status = models.CharField(max_length=120, 
> choices=ORDER_STATUS_CHOICES, default='created')
> cart = models.ForeignKey(Cart)
> user = models.ForeignKey(UserCheckout, null=True)
> billing_address = models.ForeignKey(UserAddress, 
> related_name='billing_address', null=True)
> shipping_address = models.ForeignKey(UserAddress, 
> related_name='shipping_address', null=True)
> shipping_total_price = models.DecimalField(max_digits=50, 
> decimal_places=2, default=5.99)   
> order_total = models.DecimalField(max_digits=50, decimal_places=2, )
> order_id = models.CharField(max_length=20, null=True, blank=True)
> paymethod = models.CharField(max_length=120, choices=CHOICES, 
> default='CreditCard')
> 
>
> def __unicode__(self):
> return str(self.cart.id)
>
>
> *sellers/mixins.py*
>
>
> import datetime
>
> from django.db.models import Count, Min, Sum, Avg, Max
>
> from dress.mixins import LoginRequiredMixin
> from orders.models import Transaction, Order
> from products.models import Product
>
> from .models import SellerAccount
>
>
>
> class SellerAccountMixin(LoginRequiredMixin, object):
> account = None
> products = []
> transactions = []
> orders = []
>
> def get_account(self):
> user = self.request.user
> accounts = SellerAccount.objects.filter(user=user)
> if accounts.exists() and accounts.count() == 1:
> self.account = accounts.first()
> return accounts.first()
> return None
>
> def get_products(self):
> account = self.get_account()
> products = Product.objects.filter(seller=account)
> self.products = products
> return products
>
>def get_sold_products(self):
> products = self.get_products()
> **
>   THIS IS THE PROBLEM AREA ? i want to show orders of the 
> products i got from (products = self.get_products()).
> keeping this thing in mind that order is completed if its status 
> set to be 'paid'
> OR
> In other words i want to show products of the user that is logged 
> in if the status of that products are paid.
> *
> sold = Order.objects.all().filter('products')
> return sold
>
>
> *sellers/views.py*
>
> class SellerDashboard(SellerAccountMixin, FormMixin, View):
> form_class = NewSellerForm
> success_url = "/seller/"
> context["products"] = self.get_products()
>
> context["sold_products"] = self.get_sold_products()
>
> *sellers/dashboard.html*
>
> {{ sold_products }}
>
> i hope someone will definitely figure out my problem
> regards
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/457d2aa1-3893-4737-8fdf-a55ed08c06d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Shamaila Moazzam
Thanks for you kind response ...I am stuck in it :(

I have seller as a foreign key in Product model..

*products/models.py*

class Product(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
seller = models.ForeignKey(SellerAccount)
   
title = models.CharField(max_length=120)
description = models.TextField(blank=True, null=True)
price = models.DecimalField(decimal_places=2, max_digits=20)





On Tuesday, September 20, 2016 at 10:09:01 AM UTC+5, Asad Jibran Ahmed 
wrote:
>
> Hi,
>  While you didn't show us the Product model, I assume it has a ForeignKey 
> to the Order model. To filter for Products that have an Order with a sold 
> status, you should look at the documentation for filtering on relationships 
> at 
> https://docs.djangoproject.com/en/1.10/topics/db/queries/#lookups-that-span-relationships
> .
> Regards,
> Jibran
>
> On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam wrote:
>>
>> hi
>> I am a beginner in django/python * :(*
>>
>> I am making a dashboard of sellers App.
>> I am stuck in filtering orders of the products according to the logged in 
>> user(seller)
>>
>> *sellers/models.py*
>>
>> from django.conf import settings
>> from django.core.urlresolvers import reverse
>> from django.db import models
>> from django.contrib.auth.models import User
>>
>>
>>
>> class SellerAccount(models.Model):
>> user = models.ForeignKey(User)
>> managers = models.ManyToManyField(settings.AUTH_USER_MODEL, 
>> related_name="manager_sellers", blank=True)
>> active = models.BooleanField(default=False)
>> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
>>
>>
>> def __unicode__(self):
>> return str(self.user.username)
>>
>> def get_absolute_url(self):
>> return reverse("products:vendor_detail", kwargs={"vendor_name": 
>> self.user.username})
>>
>>
>> *orders/models.py*
>>
>> class Order(models.Model):
>> status = models.CharField(max_length=120, 
>> choices=ORDER_STATUS_CHOICES, default='created')
>> cart = models.ForeignKey(Cart)
>> user = models.ForeignKey(UserCheckout, null=True)
>> billing_address = models.ForeignKey(UserAddress, 
>> related_name='billing_address', null=True)
>> shipping_address = models.ForeignKey(UserAddress, 
>> related_name='shipping_address', null=True)
>> shipping_total_price = models.DecimalField(max_digits=50, 
>> decimal_places=2, default=5.99)   
>> order_total = models.DecimalField(max_digits=50, decimal_places=2, )
>> order_id = models.CharField(max_length=20, null=True, blank=True)
>> paymethod = models.CharField(max_length=120, choices=CHOICES, 
>> default='CreditCard')
>> 
>>
>> def __unicode__(self):
>> return str(self.cart.id)
>>
>>
>> *sellers/mixins.py*
>>
>>
>> import datetime
>>
>> from django.db.models import Count, Min, Sum, Avg, Max
>>
>> from dress.mixins import LoginRequiredMixin
>> from orders.models import Transaction, Order
>> from products.models import Product
>>
>> from .models import SellerAccount
>>
>>
>>
>> class SellerAccountMixin(LoginRequiredMixin, object):
>> account = None
>> products = []
>> transactions = []
>> orders = []
>>
>> def get_account(self):
>> user = self.request.user
>> accounts = SellerAccount.objects.filter(user=user)
>> if accounts.exists() and accounts.count() == 1:
>> self.account = accounts.first()
>> return accounts.first()
>> return None
>>
>> def get_products(self):
>> account = self.get_account()
>> products = Product.objects.filter(seller=account)
>> self.products = products
>> return products
>>
>>def get_sold_products(self):
>> products = self.get_products()
>> **
>>   THIS IS THE PROBLEM AREA ? i want to show orders of the 
>> products i got from (products = self.get_products()).
>> keeping this thing in mind that order is completed if its status 
>> set to be 'paid'
>> OR
>> In other words i want to show products of the user that is logged 
>> in if the status of that products are paid.
>> *
>> sold = Order.objects.all().filter('products')
>> return sold
>>
>>
>> *sellers/views.py*
>>
>> class SellerDashboard(SellerAccountMixin, FormMixin, View):
>> form_class = NewSellerForm
>> success_url = "/seller/"
>> context["products"] = self.get_products()
>>
>> context["sold_products"] = self.get_sold_products()
>>
>> *sellers/dashboard.html*
>>
>> {{ sold_products }}
>>
>> i hope someone will definitely figure out my problem
>> regards
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email

Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Asad Jibran Ahmed
How are you associating a product with an order? Is there a way to get a
list of products sold for each order?

Asad Jibran Ahmed 
http://blog.asadjb.com

On Tue, Sep 20, 2016 at 9:24 AM, Shamaila Moazzam <
shamaila.moaz...@gmail.com> wrote:

> Thanks for you kind response ...I am stuck in it :(
>
> I have seller as a foreign key in Product model..
>
> *products/models.py*
>
> class Product(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
> seller = models.ForeignKey(SellerAccount)
>
> title = models.CharField(max_length=120)
> description = models.TextField(blank=True, null=True)
> price = models.DecimalField(decimal_places=2, max_digits=20)
>
>
>
>
>
> On Tuesday, September 20, 2016 at 10:09:01 AM UTC+5, Asad Jibran Ahmed
> wrote:
>>
>> Hi,
>>  While you didn't show us the Product model, I assume it has a ForeignKey
>> to the Order model. To filter for Products that have an Order with a
>> sold status, you should look at the documentation for filtering on
>> relationships at https://docs.djangoproject.com
>> /en/1.10/topics/db/queries/#lookups-that-span-relationships.
>> Regards,
>> Jibran
>>
>> On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam
>> wrote:
>>>
>>> hi
>>> I am a beginner in django/python * :(*
>>>
>>> I am making a dashboard of sellers App.
>>> I am stuck in filtering orders of the products according to the logged
>>> in user(seller)
>>>
>>> *sellers/models.py*
>>>
>>> from django.conf import settings
>>> from django.core.urlresolvers import reverse
>>> from django.db import models
>>> from django.contrib.auth.models import User
>>>
>>>
>>>
>>> class SellerAccount(models.Model):
>>> user = models.ForeignKey(User)
>>> managers = models.ManyToManyField(settings.AUTH_USER_MODEL,
>>> related_name="manager_sellers", blank=True)
>>> active = models.BooleanField(default=False)
>>> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
>>>
>>>
>>> def __unicode__(self):
>>> return str(self.user.username)
>>>
>>> def get_absolute_url(self):
>>> return reverse("products:vendor_detail", kwargs={"vendor_name":
>>> self.user.username})
>>>
>>>
>>> *orders/models.py*
>>>
>>> class Order(models.Model):
>>> status = models.CharField(max_length=120,
>>> choices=ORDER_STATUS_CHOICES, default='created')
>>> cart = models.ForeignKey(Cart)
>>> user = models.ForeignKey(UserCheckout, null=True)
>>> billing_address = models.ForeignKey(UserAddress,
>>> related_name='billing_address', null=True)
>>> shipping_address = models.ForeignKey(UserAddress,
>>> related_name='shipping_address', null=True)
>>> shipping_total_price = models.DecimalField(max_digits=50,
>>> decimal_places=2, default=5.99)
>>> order_total = models.DecimalField(max_digits=50, decimal_places=2, )
>>> order_id = models.CharField(max_length=20, null=True, blank=True)
>>> paymethod = models.CharField(max_length=120, choices=CHOICES,
>>> default='CreditCard')
>>>
>>>
>>> def __unicode__(self):
>>> return str(self.cart.id)
>>>
>>>
>>> *sellers/mixins.py*
>>>
>>>
>>> import datetime
>>>
>>> from django.db.models import Count, Min, Sum, Avg, Max
>>>
>>> from dress.mixins import LoginRequiredMixin
>>> from orders.models import Transaction, Order
>>> from products.models import Product
>>>
>>> from .models import SellerAccount
>>>
>>>
>>>
>>> class SellerAccountMixin(LoginRequiredMixin, object):
>>> account = None
>>> products = []
>>> transactions = []
>>> orders = []
>>>
>>> def get_account(self):
>>> user = self.request.user
>>> accounts = SellerAccount.objects.filter(user=user)
>>> if accounts.exists() and accounts.count() == 1:
>>> self.account = accounts.first()
>>> return accounts.first()
>>> return None
>>>
>>> def get_products(self):
>>> account = self.get_account()
>>> products = Product.objects.filter(seller=account)
>>> self.products = products
>>> return products
>>>
>>>def get_sold_products(self):
>>> products = self.get_products()
>>> **
>>>   THIS IS THE PROBLEM AREA ? i want to show orders of the
>>> products i got from (products = self.get_products()).
>>> keeping this thing in mind that order is completed if its status
>>> set to be 'paid'
>>> OR
>>> In other words i want to show products of the user that is
>>> logged in if the status of that products are paid.
>>> *
>>> sold = Order.objects.all().filter('products')
>>> return sold
>>>
>>>
>>> *sellers/views.py*
>>>
>>> class SellerDashboard(SellerAccountMixin, FormMixin, View):
>>> form_class = NewSellerForm
>>> success_url = "/seller/"
>>> context["products"] = self.get_products()
>>>
>>> context["sol

Re: Django filters with Foreign Key

2016-09-19 Thread Shamaila Moazzam

Hi ,

i am having the same problem ..with my sellers App .

can you share your solutionthat how you filter 

regards

On Monday, September 19, 2016 at 5:27:31 PM UTC+5, A.Khan wrote:
>
> I just got it done.
>
> Thanks.
>
> On Mon, Sep 19, 2016 at 4:19 AM, Ali khan  > wrote:
>
>> I've tried many ways but it ends with the same error that says:
>>
>> Cannot query "alikhan": Must be "User" instance.
>>
>> Where alikhan is admin user I've created with createsuperuser.
>>
>> Hate to bother you again but please advise.
>>
>> Regards,
>> Ali
>>
>> On Sun, Sep 18, 2016 at 11:08 PM, James Schneider > > wrote:
>>
>>> On Sep 18, 2016 10:22 PM, "Ali khan" > 
>>> wrote:
>>> >
>>> > Thank you for your kind response James.
>>> >
>>> > I must be doing something wrong but I thought that importing different 
>>> models and assigning them with variable may had help me to filter it out. I 
>>> will try your suggestion first to save your valued time and then will post 
>>> with result.
>>> >
>>> > Let me add a field for the seller in my "Orders" model like "seller = 
>>> models.ForeignKey(Seller)" and then filter it out.
>>> > But I tried that before still as per your suggestion I will do that 
>>> again.
>>> > Thanks again.
>>> >
>>>
>>> Once you do that, you can filter the orders with something like this:
>>>
>>> orders = Order.objects.filter(seller__user=user) 
>>>
>>> Inside of the filter function you defined. The way you are currently 
>>> doing it, you'll end up with Seller objects rather than Order objects.
>>>
>>> -James
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciX6N3eQOnb5dP877WM0FEgj%2BAjt-QfT6anwE5jNMafx3Q%40mail.gmail.com
>>>  
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c77f059c-5ab6-43e3-a3bc-099e1aefab57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Asad Jibran Ahmed
Can you share the Cart model? The Order has a foreign key to Cart. I think 
that may be the model holding details of the products.

On Tuesday, September 20, 2016 at 9:32:12 AM UTC+4, Asad Jibran Ahmed wrote:
>
> How are you associating a product with an order? Is there a way to get a 
> list of products sold for each order?
>
> Asad Jibran Ahmed 
> http://blog.asadjb.com
>
> On Tue, Sep 20, 2016 at 9:24 AM, Shamaila Moazzam <
> shamaila.moaz...@gmail.com> wrote:
>
>> Thanks for you kind response ...I am stuck in it :(
>>
>> I have seller as a foreign key in Product model..
>>
>> *products/models.py*
>>
>> class Product(models.Model):
>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>> seller = models.ForeignKey(SellerAccount)
>>
>> title = models.CharField(max_length=120)
>> description = models.TextField(blank=True, null=True)
>> price = models.DecimalField(decimal_places=2, max_digits=20)
>>
>>
>>
>>
>>
>> On Tuesday, September 20, 2016 at 10:09:01 AM UTC+5, Asad Jibran Ahmed 
>> wrote:
>>>
>>> Hi,
>>>  While you didn't show us the Product model, I assume it has a 
>>> ForeignKey to the Order model. To filter for Products that have an Order 
>>> with a sold status, you should look at the documentation for filtering on 
>>> relationships at 
>>> https://docs.djangoproject.com/en/1.10/topics/db/queries/#lookups-that-span-relationships
>>> .
>>> Regards,
>>> Jibran
>>>
>>> On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam 
>>> wrote:

 hi
 I am a beginner in django/python * :(*

 I am making a dashboard of sellers App.
 I am stuck in filtering orders of the products according to the logged 
 in user(seller)

 *sellers/models.py*

 from django.conf import settings
 from django.core.urlresolvers import reverse
 from django.db import models
 from django.contrib.auth.models import User



 class SellerAccount(models.Model):
 user = models.ForeignKey(User)
 managers = models.ManyToManyField(settings.AUTH_USER_MODEL, 
 related_name="manager_sellers", blank=True)
 active = models.BooleanField(default=False)
 timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)


 def __unicode__(self):
 return str(self.user.username)

 def get_absolute_url(self):
 return reverse("products:vendor_detail", kwargs={"vendor_name": 
 self.user.username})


 *orders/models.py*

 class Order(models.Model):
 status = models.CharField(max_length=120, 
 choices=ORDER_STATUS_CHOICES, default='created')
 cart = models.ForeignKey(Cart)
 user = models.ForeignKey(UserCheckout, null=True)
 billing_address = models.ForeignKey(UserAddress, 
 related_name='billing_address', null=True)
 shipping_address = models.ForeignKey(UserAddress, 
 related_name='shipping_address', null=True)
 shipping_total_price = models.DecimalField(max_digits=50, 
 decimal_places=2, default=5.99)   
 order_total = models.DecimalField(max_digits=50, decimal_places=2, )
 order_id = models.CharField(max_length=20, null=True, blank=True)
 paymethod = models.CharField(max_length=120, choices=CHOICES, 
 default='CreditCard')
 

 def __unicode__(self):
 return str(self.cart.id)


 *sellers/mixins.py*


 import datetime

 from django.db.models import Count, Min, Sum, Avg, Max

 from dress.mixins import LoginRequiredMixin
 from orders.models import Transaction, Order
 from products.models import Product

 from .models import SellerAccount



 class SellerAccountMixin(LoginRequiredMixin, object):
 account = None
 products = []
 transactions = []
 orders = []

 def get_account(self):
 user = self.request.user
 accounts = SellerAccount.objects.filter(user=user)
 if accounts.exists() and accounts.count() == 1:
 self.account = accounts.first()
 return accounts.first()
 return None

 def get_products(self):
 account = self.get_account()
 products = Product.objects.filter(seller=account)
 self.products = products
 return products

def get_sold_products(self):
 products = self.get_products()
 **
   THIS IS THE PROBLEM AREA ? i want to show orders of the 
 products i got from (products = self.get_products()).
 keeping this thing in mind that order is completed if its 
 status set to be 'paid'
 OR
 In other words i want to show products of the user that is 
 logged in if the status of that products are paid.

Re: Django filters with Foreign Key

2016-09-19 Thread A.Khan

>
> Happy to see we are in same boat. It did work with like:
>

def prod_sold(self):
prod = self.get_prod().filter(seller__user=self.account.user)
sold = Order.objects.filter(id=products)
return sold
But it only shows number of products sold. 

I couldn't make it happen.

If you can find solution share with me as well and I will do the same.

Regards,
Ali 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/16d19efc-5511-4c0b-a3fa-633780ccbcc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Shamaila Moazzam
user = models.ForeignKey(settings.AUTH_USER_MODEL)

this user is a F.K in products model, orders model , carts model right.
cart is also a F.K in orders like this

class Order(models.Model):
status = models.CharField(max_length=120, choices=ORDER_STATUS_CHOICES, 
default='created')
cart = models.ForeignKey(Cart)
user = models.ForeignKey(UserCheckout, null=True)
billing_address = models.ForeignKey(UserAddress, 
related_name='billing_address', null=True)
shipping_address = models.ForeignKey(UserAddress, 
related_name='shipping_address', null=True
..
seller = models.ForeignKey(SellerAccount, null=True)..i have added 
this field now to relate sellers app with orders...

now advise me 
how to filter orders of products with status of paid .( of a logged in user 
)

:)








On Tuesday, September 20, 2016 at 10:44:19 AM UTC+5, Asad Jibran Ahmed 
wrote:
>
> Can you share the Cart model? The Order has a foreign key to Cart. I think 
> that may be the model holding details of the products.
>
> On Tuesday, September 20, 2016 at 9:32:12 AM UTC+4, Asad Jibran Ahmed 
> wrote:
>>
>> How are you associating a product with an order? Is there a way to get a 
>> list of products sold for each order?
>>
>> Asad Jibran Ahmed >
>> http://blog.asadjb.com
>>
>> On Tue, Sep 20, 2016 at 9:24 AM, Shamaila Moazzam > > wrote:
>>
>>> Thanks for you kind response ...I am stuck in it :(
>>>
>>> I have seller as a foreign key in Product model..
>>>
>>> *products/models.py*
>>>
>>> class Product(models.Model):
>>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>>> seller = models.ForeignKey(SellerAccount)
>>>
>>> title = models.CharField(max_length=120)
>>> description = models.TextField(blank=True, null=True)
>>> price = models.DecimalField(decimal_places=2, max_digits=20)
>>>
>>>
>>>
>>>
>>>
>>> On Tuesday, September 20, 2016 at 10:09:01 AM UTC+5, Asad Jibran Ahmed 
>>> wrote:

 Hi,
  While you didn't show us the Product model, I assume it has a 
 ForeignKey to the Order model. To filter for Products that have an 
 Order with a sold status, you should look at the documentation for 
 filtering on relationships at 
 https://docs.djangoproject.com/en/1.10/topics/db/queries/#lookups-that-span-relationships
 .
 Regards,
 Jibran

 On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam 
 wrote:
>
> hi
> I am a beginner in django/python * :(*
>
> I am making a dashboard of sellers App.
> I am stuck in filtering orders of the products according to the logged 
> in user(seller)
>
> *sellers/models.py*
>
> from django.conf import settings
> from django.core.urlresolvers import reverse
> from django.db import models
> from django.contrib.auth.models import User
>
>
>
> class SellerAccount(models.Model):
> user = models.ForeignKey(User)
> managers = models.ManyToManyField(settings.AUTH_USER_MODEL, 
> related_name="manager_sellers", blank=True)
> active = models.BooleanField(default=False)
> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
>
>
> def __unicode__(self):
> return str(self.user.username)
>
> def get_absolute_url(self):
> return reverse("products:vendor_detail", 
> kwargs={"vendor_name": self.user.username})
>
>
> *orders/models.py*
>
> class Order(models.Model):
> status = models.CharField(max_length=120, 
> choices=ORDER_STATUS_CHOICES, default='created')
> cart = models.ForeignKey(Cart)
> user = models.ForeignKey(UserCheckout, null=True)
> billing_address = models.ForeignKey(UserAddress, 
> related_name='billing_address', null=True)
> shipping_address = models.ForeignKey(UserAddress, 
> related_name='shipping_address', null=True)
> shipping_total_price = models.DecimalField(max_digits=50, 
> decimal_places=2, default=5.99)   
> order_total = models.DecimalField(max_digits=50, decimal_places=2, 
> )
> order_id = models.CharField(max_length=20, null=True, blank=True)
> paymethod = models.CharField(max_length=120, choices=CHOICES, 
> default='CreditCard')
> 
>
> def __unicode__(self):
> return str(self.cart.id)
>
>
> *sellers/mixins.py*
>
>
> import datetime
>
> from django.db.models import Count, Min, Sum, Avg, Max
>
> from dress.mixins import LoginRequiredMixin
> from orders.models import Transaction, Order
> from products.models import Product
>
> from .models import SellerAccount
>
>
>
> class SellerAccountMixin(LoginRequiredMixin, object):
> account = None
> products = []
> transactions = []
> orders = []
>
> def get_account(self):
> user = self.request.u

Re: Setting FK field in list view

2016-09-19 Thread RompePC
Talking in the way of getting the HTML widget yeah, maybe. But what I wanna 
do is, given a model *A* with a FK *a_fk*, I want *a_fk* to be available in 
views other than add. So I wanna get *a_fk* and pass it to another context (
*changelist_view* specifically). But the nearest thing I get is 
*self.model.a_fk*

El lunes, 19 de septiembre de 2016, 19:47:13 (UTC+2), Tim Graham escribió:
>
> So basically ModelAdmin.list_editable but without the icons on the side?
>
> If you never want the inline editing buttons for all models, you could 
> override the admin/related_widget_wrapper.html template and remove the 
> buttons.
>
> https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/related_widget_wrapper.html
>
> Otherwise, I'm out of (simple) ideas.
>
> On Monday, September 19, 2016 at 12:58:44 PM UTC-4, RompePC wrote:
>>
>> Yeah, I'm so sorry, it's hard to understand. I'll post an image of the 
>> Django tutorial of what I mean:
>>
>>
>> 
>> I want that the FK widget (the one for *Question*) could be available in 
>> other panel admin's views (as listing) (with no CRUD icons along). The 
>> problem is to get the field correctly, as I just only get str 
>> representations of the field or the widget.
>>
>> El lunes, 19 de septiembre de 2016, 18:53:56 (UTC+2), Tim Graham escribió:
>>>
>>> I still don't understand the goal. Maybe you can mock up a screenshot 
>>> and/or give a code example.
>>>
>>> On Monday, September 19, 2016 at 12:41:32 PM UTC-4, RompePC wrote:

 Nope, as I wanna the ModelChoiceField rendered in the filter list I did 
 in my own (not the sided one).

 El lunes, 19 de septiembre de 2016, 18:15:17 (UTC+2), Tim Graham 
 escribió:
>
> ModelAdmin.list_editable?
>
>
> https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable
>
> On Monday, September 19, 2016 at 11:05:22 AM UTC-4, RompePC wrote:
>>
>> Nope, it isn't a lookup separator: for simply understanding, I wanna 
>> get the FK widget (the HTML, the select, all of that) that is show when 
>> adding an object that has a related key (say, adding a new City and 
>> selecting its Country in the same model, 'cause a City belongs to a 
>> Country) so I can use it anywhere in my panel.
>>
>> El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham 
>> escribió:
>>>
>>> Is your request https://code.djangoproject.com/ticket/10743?
>>>
>>> On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:

 Yep, the second one is what I wanna do. Althrough they aren't 
 inlines, but like FK filter choices in the list view (not the default 
 ones).
 It's hard to understand, I know it can be done, but don't know how. 
 Will keep searching and throw some light here when done.

 El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic coues 
 escribió:
>
> I looked into it after my first reply and my suggestion was wrong. 
>
> If you want to display the value of a foreign key object's 
> property in 
> the admin page to select an object to change, you can add a 
> callable 
> to list_display. 
> For exemple, ` list_display = ('title', lambda o: 
> getattr(o.author, 
> "name", "-"),) `. The callable will get one argument, an instance 
> of 
> the model. 
>
> If you want to display a field to change a property of a foreign 
> key 
> object, I haven't found a way. Best option might be a inline model 
> admin. 
>
> 2016-09-19 12:24 GMT+02:00 RompePC : 
> > Hi again, I didn't have time to try it until now, but I just 
> realized that 
> > maybe I asked the wrong way. What I wanna do is to render the 
> widget 
> > associated to that FK in the panel, not its name. So I need to 
> pass the 
> > field or its rendered content to the context, but I don't know 
> how to do get 
> > it. 
> > 
> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic 
> coues 
> > escribió: 
> >> 
> >> Have you tried something like author__name ? Assuming a model 
> with an 
> >> author foreign key. 
> >> 
> >> 2016-09-16 8:56 GMT+02:00 RompePC : 
> >> > I would like to pass to the list display view a FK field of 
> the admin 
> >> > form 
> >> > (like the ones when adding a new row). But I don't see the 
> way of doing 
> >> > it, 
> >> > although I've searched along many properties of the model 
> admin to get 
> 

Re: Setting FK field in list view

2016-09-19 Thread RompePC
Ok, looks like just adding a *ModelForm* and getting that field does the 
work. Sorry for the noobish time.

El martes, 20 de septiembre de 2016, 8:23:19 (UTC+2), RompePC escribió:
>
> Talking in the way of getting the HTML widget yeah, maybe. But what I 
> wanna do is, given a model *A* with a FK *a_fk*, I want *a_fk* to be 
> available in views other than add. So I wanna get *a_fk* and pass it to 
> another context (*changelist_view* specifically). But the nearest thing I 
> get is *self.model.a_fk*
>
> El lunes, 19 de septiembre de 2016, 19:47:13 (UTC+2), Tim Graham escribió:
>>
>> So basically ModelAdmin.list_editable but without the icons on the side?
>>
>> If you never want the inline editing buttons for all models, you could 
>> override the admin/related_widget_wrapper.html template and remove the 
>> buttons.
>>
>> https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/related_widget_wrapper.html
>>
>> Otherwise, I'm out of (simple) ideas.
>>
>> On Monday, September 19, 2016 at 12:58:44 PM UTC-4, RompePC wrote:
>>>
>>> Yeah, I'm so sorry, it's hard to understand. I'll post an image of the 
>>> Django tutorial of what I mean:
>>>
>>>
>>> 
>>> I want that the FK widget (the one for *Question*) could be available 
>>> in other panel admin's views (as listing) (with no CRUD icons along). The 
>>> problem is to get the field correctly, as I just only get str 
>>> representations of the field or the widget.
>>>
>>> El lunes, 19 de septiembre de 2016, 18:53:56 (UTC+2), Tim Graham 
>>> escribió:

 I still don't understand the goal. Maybe you can mock up a screenshot 
 and/or give a code example.

 On Monday, September 19, 2016 at 12:41:32 PM UTC-4, RompePC wrote:
>
> Nope, as I wanna the ModelChoiceField rendered in the filter list I 
> did in my own (not the sided one).
>
> El lunes, 19 de septiembre de 2016, 18:15:17 (UTC+2), Tim Graham 
> escribió:
>>
>> ModelAdmin.list_editable?
>>
>>
>> https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable
>>
>> On Monday, September 19, 2016 at 11:05:22 AM UTC-4, RompePC wrote:
>>>
>>> Nope, it isn't a lookup separator: for simply understanding, I wanna 
>>> get the FK widget (the HTML, the select, all of that) that is show when 
>>> adding an object that has a related key (say, adding a new City and 
>>> selecting its Country in the same model, 'cause a City belongs to a 
>>> Country) so I can use it anywhere in my panel.
>>>
>>> El lunes, 19 de septiembre de 2016, 16:31:55 (UTC+2), Tim Graham 
>>> escribió:

 Is your request https://code.djangoproject.com/ticket/10743?

 On Monday, September 19, 2016 at 10:08:59 AM UTC-4, RompePC wrote:
>
> Yep, the second one is what I wanna do. Althrough they aren't 
> inlines, but like FK filter choices in the list view (not the default 
> ones).
> It's hard to understand, I know it can be done, but don't know 
> how. Will keep searching and throw some light here when done.
>
> El lunes, 19 de septiembre de 2016, 14:06:28 (UTC+2), ludovic 
> coues escribió:
>>
>> I looked into it after my first reply and my suggestion was 
>> wrong. 
>>
>> If you want to display the value of a foreign key object's 
>> property in 
>> the admin page to select an object to change, you can add a 
>> callable 
>> to list_display. 
>> For exemple, ` list_display = ('title', lambda o: 
>> getattr(o.author, 
>> "name", "-"),) `. The callable will get one argument, an instance 
>> of 
>> the model. 
>>
>> If you want to display a field to change a property of a foreign 
>> key 
>> object, I haven't found a way. Best option might be a inline 
>> model 
>> admin. 
>>
>> 2016-09-19 12:24 GMT+02:00 RompePC : 
>> > Hi again, I didn't have time to try it until now, but I just 
>> realized that 
>> > maybe I asked the wrong way. What I wanna do is to render the 
>> widget 
>> > associated to that FK in the panel, not its name. So I need to 
>> pass the 
>> > field or its rendered content to the context, but I don't know 
>> how to do get 
>> > it. 
>> > 
>> > El viernes, 16 de septiembre de 2016, 13:59:26 (UTC+2), ludovic 
>> coues 
>> > escribió: 
>> >> 
>> >> Have you tried something like author__name ? Assuming a model 
>> with an 
>> >> author foreign key. 
>> >> 
>> >> 2016-09-16 8:56 GMT+02:00 RompePC : 
>> >> > I

Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Asad Jibran Ahmed
I'd need to see the full Cart model to confirm, but try something like this
to get all products for Orders with the paid status:

def get_products(self):
 orders = Order.objects.filter(user=self.user, status='paid')
 products_list = list()
 for o in orders:
  for p in o.cart.products:
   products_list.append(p)

 return products_list

This depends on their being a ManyToMany relationship to Product in the
Cart model.

Asad Jibran Ahmed 
http://blog.asadjb.com

On Tue, Sep 20, 2016 at 10:12 AM, Shamaila Moazzam <
shamaila.moaz...@gmail.com> wrote:

> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>
> this user is a F.K in products model, orders model , carts model right.
> cart is also a F.K in orders like this
>
> class Order(models.Model):
> status = models.CharField(max_length=120,
> choices=ORDER_STATUS_CHOICES, default='created')
> cart = models.ForeignKey(Cart)
> user = models.ForeignKey(UserCheckout, null=True)
> billing_address = models.ForeignKey(UserAddress,
> related_name='billing_address', null=True)
> shipping_address = models.ForeignKey(UserAddress,
> related_name='shipping_address', null=True
> ..
> seller = models.ForeignKey(SellerAccount, null=True)..i have
> added this field now to relate sellers app with orders...
>
> now advise me
> how to filter orders of products with status of paid .( of a logged in
> user )
>
> :)
>
>
>
>
>
>
>
>
> On Tuesday, September 20, 2016 at 10:44:19 AM UTC+5, Asad Jibran Ahmed
> wrote:
>>
>> Can you share the Cart model? The Order has a foreign key to Cart. I
>> think that may be the model holding details of the products.
>>
>> On Tuesday, September 20, 2016 at 9:32:12 AM UTC+4, Asad Jibran Ahmed
>> wrote:
>>>
>>> How are you associating a product with an order? Is there a way to get a
>>> list of products sold for each order?
>>>
>>> Asad Jibran Ahmed 
>>> http://blog.asadjb.com
>>>
>>> On Tue, Sep 20, 2016 at 9:24 AM, Shamaila Moazzam >> > wrote:
>>>
 Thanks for you kind response ...I am stuck in it :(

 I have seller as a foreign key in Product model..

 *products/models.py*

 class Product(models.Model):
 user = models.ForeignKey(settings.AUTH_USER_MODEL)
 seller = models.ForeignKey(SellerAccount)

 title = models.CharField(max_length=120)
 description = models.TextField(blank=True, null=True)
 price = models.DecimalField(decimal_places=2, max_digits=20)





 On Tuesday, September 20, 2016 at 10:09:01 AM UTC+5, Asad Jibran Ahmed
 wrote:
>
> Hi,
>  While you didn't show us the Product model, I assume it has a
> ForeignKey to the Order model. To filter for Products that have an
> Order with a sold status, you should look at the documentation for
> filtering on relationships at https://docs.djangoproject.com
> /en/1.10/topics/db/queries/#lookups-that-span-relationships.
> Regards,
> Jibran
>
> On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam
> wrote:
>>
>> hi
>> I am a beginner in django/python * :(*
>>
>> I am making a dashboard of sellers App.
>> I am stuck in filtering orders of the products according to the
>> logged in user(seller)
>>
>> *sellers/models.py*
>>
>> from django.conf import settings
>> from django.core.urlresolvers import reverse
>> from django.db import models
>> from django.contrib.auth.models import User
>>
>>
>>
>> class SellerAccount(models.Model):
>> user = models.ForeignKey(User)
>> managers = models.ManyToManyField(settings.AUTH_USER_MODEL,
>> related_name="manager_sellers", blank=True)
>> active = models.BooleanField(default=False)
>> timestamp = models.DateTimeField(auto_now_add=True,
>> auto_now=False)
>>
>>
>> def __unicode__(self):
>> return str(self.user.username)
>>
>> def get_absolute_url(self):
>> return reverse("products:vendor_detail",
>> kwargs={"vendor_name": self.user.username})
>>
>>
>> *orders/models.py*
>>
>> class Order(models.Model):
>> status = models.CharField(max_length=120,
>> choices=ORDER_STATUS_CHOICES, default='created')
>> cart = models.ForeignKey(Cart)
>> user = models.ForeignKey(UserCheckout, null=True)
>> billing_address = models.ForeignKey(UserAddress,
>> related_name='billing_address', null=True)
>> shipping_address = models.ForeignKey(UserAddress,
>> related_name='shipping_address', null=True)
>> shipping_total_price = models.DecimalField(max_digits=50,
>> decimal_places=2, default=5.99)
>> order_total = models.DecimalField(max_digits=50,
>> decimal_places=2, )
>> order_id = models.CharField(max_length=20, null=True, blank=True)
>> paymethod = models.CharField(max_length=120, choices=CHOICES,
>> default='CreditCard'

Help with FlatPages

2016-09-19 Thread Lekan Wahab
Good morning guys,

I'm trying to locally set up an existing  project on my machine.
While I've set up most of the project,  the part giving me a hard time are
the ones using flatpages.

Now,  everytime I access those,  I get a "No Flatpages matches the given
query. " error.

I've tried everything I can but with no luck.

However, there's a flatpages.json file in the project folder.

What could that be for?

Is there something I am supposed to do with that json file?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE6v7oeihYOYgqatE-HqPO0_aQS0P0JvXAwPwvs5_H-xs0d5bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.