Re: How to make django's mysql connections to use utf8mb4 ?

2013-01-23 Thread Adrián Espinosa
Hello,

I struggled with this once, although not through Django. I tried a lot of 
things, and I couldn't get MySQL to properly store emojis, or 
japanese/chinese characters for example.

As my project was just starting, I switched to postgresql, and it just 
worked. I did nothing fancy to get it to work and I have succesfully stored 
all kind of characters.

I'm also interested in the right solution for MySQL, but if you don't want 
to spend a lot of time or anything else, you might want to try with 
postgresql.

Best regards

On Wednesday, January 23, 2013 10:07:07 PM UTC+1, Chen Xu wrote:
>
> I saved some Emoji icons to MySQL Database,the icons have been saved 
> correctly. Since I can see them from MySQL Shell when I type 'select 
> message_text from messages'
>
> However, when I do Message.object.get(ph=5).message_text, it shows me a 
> bunch question marks.
>
> Could someone please help?
>
> Thanks
>
> -- 
> ⚡ Chen Xu ⚡ 
>

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



Re: Generic views and url issues

2013-01-23 Thread mgc_django-users

On 24/01/2013 10:39 AM, amy.cerr...@cbsinteractive.com wrote:
I've been trying to understand how to use generic views.  I've 
followed some tutorials, and read through Django docs, but I can't get 
the url function to work in my templates.


I get the error
NoReverseMatch at /testadcall/
Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not found.

in my urls.py

queryset = {'queryset': Adcall.objects.order_by('name')}

urlpatterns = patterns('django.views.generic.list_detail',
url(r'^$','object_list', queryset, name="adcalls"),
url(r'(?P\d+)/detail/$', 'object_detail', queryset, 
name="detail"),

)

in my template for the list view:

{% load url from future %}
{% if object_list %}

{% for adcall in object_list %}
{{ adcall.name 
}}

{% endfor %}

{% endif %}

I've tried no quotes, single quotes, and double quotes around the url 
name "detail", with no apparent effect.


Am I wrong in thinking that this should work?



The problem is a mismatch between your urls.py pattern and the 
parameters you give to the url templatetag - note in the error message 
that it mentions both arguments and keyword arguments (with your example 
having a single non-keyword argument). However, in your url pattern for 
the "detail" url, you use a named capture (object_id). In this case, you 
must use a keyword argument to match:


{% url 'detail' object_id=adcall.id %}

Regards,
Michael.

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



Re: Generic views and url issues

2013-01-23 Thread Sanjay Bhangar
(reply inline)

On Thu, Jan 24, 2013 at 5:09 AM,   wrote:
> I've been trying to understand how to use generic views.  I've followed some
> tutorials, and read through Django docs, but I can't get the url function to
> work in my templates.
>
> I get the error
> NoReverseMatch at /testadcall/
>
> Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not
> found.
>
>
> in my urls.py
>
> queryset = {'queryset': Adcall.objects.order_by('name')}
>
> urlpatterns = patterns('django.views.generic.list_detail',
> url(r'^$','object_list', queryset, name="adcalls"),
> url(r'(?P\d+)/detail/$', 'object_detail', queryset,
> name="detail"),
> )
>
> in my template for the list view:
>
> {% load url from future %}
> {% if object_list %}
> 
> {% for adcall in object_list %}
> {{ adcall.name
> }}
> {% endfor %}
> 
> {% endif %}
>

try:
{% url 'detail' object_id=adcall.id %}

since you have object_id defined as a keyword param in the url, you
will need to specify it as a keyword param in the {% url %} tag, I
*think* :)

let know if that works -
best've luck,
Sanjay

> I've tried no quotes, single quotes, and double quotes around the url name
> "detail", with no apparent effect.
>
> Am I wrong in thinking that this should work?
>
> I'm using Django 1.4.3, Python 2.7.3
>
> Thanks so much.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/M6Qrx89JeBkJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: What's the right pattern to re-use common view code?

2013-01-23 Thread Derek
If you'd read the Django Book (IMO, an essential "before you start with 
Django" read), you would have encountered the include tag in Chpt 4, the 
introduction to the templates:
http://www.djangobook.com/en/2.0/chapter04.html

On Tuesday, 22 January 2013 23:51:53 UTC+2, andrew jackson wrote:
>
> ...I can't believe i missed that as a builtin.  Sorry!
>
> Thank you very much!
> -andrew
>
> On Tuesday, January 22, 2013 12:01:52 PM UTC-8, Nikolas Stevenson-Molnar 
> wrote:
>>
>>  Django does {% include %} too :) 
>> https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#include
>>
>> You could do something like: {% include "book_list.html" with 
>> books=auth.book_set.all %}
>>
>> _Nik
>>
>> On 1/22/2013 8:03 AM, andrew jackson wrote:
>>  
>> I have an object that shows up in lots of different parts of the system, 
>> say a Book.   
>>
>>  I want to display a list view of Book objects in many different places, 
>> e.g.,  
>>
>> When looking at an Author's detail page, I want to see a list of recent 
>> books they've written
>>  when looking at a publisher page, similar.
>> In fact, even when looking at a book i'd like to have a list of books 
>> that reference it.
>>
>>  So, there's going to be html code that shows a table of books on 
>> several different pages.
>>
>>  My question is, what's the right way to follow DRY w/ django templates 
>> and not duplicate the code that makes a list of books?  
>>
>>  If I was using Jinja, it'd be pretty straightforward to {% include %} a 
>> snippet in each page that renders each queryset as a fancy table.  It 
>> doesn't look like template inheritance is set up that way here, though.
>>
>>  So what's the right way to do it with Django?  Am I thinking about it 
>> wrong?  I see a few django-fancy-tables plugins, but they seem pretty 
>> heavyweight, and i'd like to understand the right way to approach the 
>> solution here.  In fact, I don't even know the right words to use to 
>> describe the problem, so my google-fu is weak.  Do I write a custom 
>> template tag that takes a queryset as a parameter?  Aren't custom template 
>> tags to be avoided?
>>  
>>  
>>  Thanks much for your time,
>> Andrew
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/TRxMsFf3sN0J.
>> To post to this group, send email to django...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>>  

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



Re: Generic views and url issues

2013-01-23 Thread Sergiy Khohlov
try to  check testaddcall/1/ please
Many thanks,

Serge


+380 636150445
skype: skhohlov


2013/1/24  :
> I've been trying to understand how to use generic views.  I've followed some
> tutorials, and read through Django docs, but I can't get the url function to
> work in my templates.
>
> I get the error
> NoReverseMatch at /testadcall/
>
> Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not
> found.
>
>
> in my urls.py
>
> queryset = {'queryset': Adcall.objects.order_by('name')}
>
> urlpatterns = patterns('django.views.generic.list_detail',
> url(r'^$','object_list', queryset, name="adcalls"),
> url(r'(?P\d+)/detail/$', 'object_detail', queryset,
> name="detail"),
> )
>
> in my template for the list view:
>
> {% load url from future %}
> {% if object_list %}
> 
> {% for adcall in object_list %}
> {{ adcall.name
> }}
> {% endfor %}
> 
> {% endif %}
>
> I've tried no quotes, single quotes, and double quotes around the url name
> "detail", with no apparent effect.
>
> Am I wrong in thinking that this should work?
>
> I'm using Django 1.4.3, Python 2.7.3
>
> Thanks so much.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/M6Qrx89JeBkJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Relations to unknown models?

2013-01-23 Thread jirka . vejrazka
Hi galgal,

   You might want to take a look at django.contrib.comments (either use it or 
learn from it) and/or GenericForeignKey.

  HTH

Jirka

-Original Message-
From: galgal 
Sender: django-users@googlegroups.com
Date: Wed, 23 Jan 2013 14:48:55 
To: 
Reply-To: django-users@googlegroups.com
Subject: Relations to unknown models?

Hi.
I'm looking for a solution to make site-wide comments that can be connected 
with different models via FK.
I want to make 1 global model Comments. I want to make a relation to 
Articles, Relations and Solutions models. I the future I plan to add 
additional models. Now, Comments model should allow me to make relations to 
any of that models via FK. What is important, I need to have 1 and only 1 
Comments model, and it won't be abstract model.
On site I want to display stats showing how many comments were added to 
each model.

Any suggestions?

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


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



Re: how do I dynamically modify a choice field

2013-01-23 Thread Mike Dewhirst

On 24/01/2013 10:46am, frocco wrote:

Thanks Mike,

I do not know if this will work.
I want to change the field in the template as I read each row.
I do this in PHP rather easy, but am confused on how to do this using
django.


I haven't done much php (only emergency repairs to stuff written by 
others after they have disappeared!) so I don't know how easy that might be.


In Django templates you can use HTML and for-loops to do most things. 
You just write a class in your view to get the data from a query_set and 
construct a list of objects (in your case, each row and a list of all of 
its individual choices as found - foreign key or many-to-many - in the 
database) and render it in your template. There is plenty of template 
power available ...


https://docs.djangoproject.com/en/1.4/ref/templates/builtins/

It might look like this ...

{% if list_of_row_objects %}

{% for row_object in list_of_row_objects %}
{{ row_object.field_name }}
There are {{ row_object.choices|length }} choices

{% for choice in row_object.choices %}
{{ choice.name }}
{% empty %}
There are no choices for this row
{% endfor %}


{% endfor %}

{% else %}
Sorry, no list of row objects today!
{% endif %}

hth

Mike





On Wednesday, January 23, 2013 6:03:28 PM UTC-5, Mike Dewhirst wrote:

On 24/01/2013 2:36am, frocco wrote:
 > Hello,
 >
 > In my view, I am displaying rows of data that have a choice field
in a form.
 > one form for each row
 >
 > I want to change the choice this before printing.
 >
 > one row can have 1 to 5 choices
 > another row can have 1 to 10 choices depending on values in each
row.

I'm likely to want something similar soon so I googled "how do I
dynamically modify a django choice field" and got at least a page of
results. Here is one which I looked at and found interesting. It may
suit your needs ...

http://ilian.i-n-i.org/django-forms-choicefield-with-dynamic-values/


Good luck

Mike

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

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


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



Generic views and url issues

2013-01-23 Thread amy . cerrito
I've been trying to understand how to use generic views.  I've followed 
some tutorials, and read through Django docs, but I can't get the url 
function to work in my templates.

I get the error 
NoReverseMatch at /testadcall/

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not found.


in my urls.py

queryset = {'queryset': Adcall.objects.order_by('name')}

urlpatterns = patterns('django.views.generic.list_detail',
url(r'^$','object_list', queryset, name="adcalls"),
url(r'(?P\d+)/detail/$', 'object_detail', queryset, 
name="detail"),
)

in my template for the list view:

{% load url from future %}
{% if object_list %}

{% for adcall in object_list %}
{{ adcall.name 
}}
{% endfor %}

{% endif %}

I've tried no quotes, single quotes, and double quotes around the url name 
"detail", with no apparent effect.

Am I wrong in thinking that this should work?

I'm using Django 1.4.3, Python 2.7.3

Thanks so much.

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



Re: how do I dynamically modify a choice field

2013-01-23 Thread frocco
Thanks Mike,

I do not know if this will work.
I want to change the field in the template as I read each row.
I do this in PHP rather easy, but am confused on how to do this using 
django.


On Wednesday, January 23, 2013 6:03:28 PM UTC-5, Mike Dewhirst wrote:
>
> On 24/01/2013 2:36am, frocco wrote: 
> > Hello, 
> > 
> > In my view, I am displaying rows of data that have a choice field in a 
> form. 
> > one form for each row 
> > 
> > I want to change the choice this before printing. 
> > 
> > one row can have 1 to 5 choices 
> > another row can have 1 to 10 choices depending on values in each row. 
>
> I'm likely to want something similar soon so I googled "how do I 
> dynamically modify a django choice field" and got at least a page of 
> results. Here is one which I looked at and found interesting. It may 
> suit your needs ... 
>
> http://ilian.i-n-i.org/django-forms-choicefield-with-dynamic-values/ 
>
> Good luck 
>
> Mike 
>
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/BSrfbUYb_v8J. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>
>

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



Re: how do I dynamically modify a choice field

2013-01-23 Thread Mike Dewhirst

On 24/01/2013 2:36am, frocco wrote:

Hello,

In my view, I am displaying rows of data that have a choice field in a form.
one form for each row

I want to change the choice this before printing.

one row can have 1 to 5 choices
another row can have 1 to 10 choices depending on values in each row.


I'm likely to want something similar soon so I googled "how do I 
dynamically modify a django choice field" and got at least a page of 
results. Here is one which I looked at and found interesting. It may 
suit your needs ...


http://ilian.i-n-i.org/django-forms-choicefield-with-dynamic-values/

Good luck

Mike



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


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



Relations to unknown models?

2013-01-23 Thread galgal
Hi.
I'm looking for a solution to make site-wide comments that can be connected 
with different models via FK.
I want to make 1 global model Comments. I want to make a relation to 
Articles, Relations and Solutions models. I the future I plan to add 
additional models. Now, Comments model should allow me to make relations to 
any of that models via FK. What is important, I need to have 1 and only 1 
Comments model, and it won't be abstract model.
On site I want to display stats showing how many comments were added to 
each model.

Any suggestions?

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



How can i redirect a form to amother page when validation is correct

2013-01-23 Thread Okorie Emmanuel
Am trying to build an application that user can login to register  using 
pin and serial number from a scratch card, a valid pin and serial number 
should take a user to the registration page to create an account, here are 
codes i have writen 

*view.py*

def index(request, template_name="index.html"):
errors=[]
if request.method == "POST":
form = PinForm()
if form.is_valid():
#form.save()
#form.cleaned_data
pin1 = request.POST.get('pin', '')
serial_no1 = request.POST.get('serial_no', '')
accept = auth.authenticate(pin=pin1, serial_no=serial_no1)
if accept is not None and accept.is_active:
# Correct password, and the user is marked "active"
auth.login(request, accept)
# Redirect to a success page.
return HttpResponseRedirect('/acceptance/')


else:
form = PinForm()
#accept = authenticate(pin != pin, serial_no !=serial_no, is_valid 
= False )
#errors.append('This card Does Not Exist')
 #   form = PinForm()
return render_to_response(template_name, locals(),context_instance = 
RequestContext(request))


def acceptance(request, template_name = "acceptance.html"):
return render_to_response(template_name, locals(),context_instance = 
RequestContext(request))

*form.py*

from django import forms
from you.models import Pin

class PinForm(forms.ModelForm):
class Meta:
model = Pin
exclude = ('is_active',)

*urls.py*
*
*
from django.conf.urls.defaults import *


urlpatterns = patterns('you.views',
(r'^$','index', {'template_name': 'index.html'}, 'home_page'),
#(r'^acceptance/$',{'template_name': 'acceptance.html'}, 
'acceptance'),
(r'^acceptance/$', 'acceptance', {'template_name': 
'acceptance.html'}, 'acceptance'),

and 

*models.py*
*
*
*from django.db import models*
*from django.forms import ModelForm*
*
*
*class Pin(models.Model):*
*pin = models.CharField(max_length=12)*
*serial_no = models.CharField(max_length=12)*
*is_active = models.BooleanField(default=True)*
**
*class Meta:*
*db_table = 'db_Pin'*
*ordering = ['pin']*
*def __unicode__(self):*
*return self.pin*  

  
In the model i have actually stored the pin and serial no, but each time i 
entered a valid pin and serial number it does not redirect to the next page 
which for now
is the acceptance page, this i intend to change to the registration page. 
pls what have i not done right, pls help me fix this. thanks 

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



How to make django's mysql connections to use utf8mb4 ?

2013-01-23 Thread Chen Xu
I saved some Emoji icons to MySQL Database,the icons have been saved
correctly. Since I can see them from MySQL Shell when I type 'select
message_text from messages'

However, when I do Message.object.get(ph=5).message_text, it shows me a
bunch question marks.

Could someone please help?

Thanks

-- 
⚡ Chen Xu ⚡

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



Re: no attribute JSONEncoder

2013-01-23 Thread ghjim
No, I rebuilt mod_wsgi with the new Python2.7.3.

On Wednesday, January 23, 2013 12:15:50 PM UTC-8, Nikolas Stevenson-Molnar 
wrote:
>
>  Are you sure that mod_wsgi was built against Python 2.7 (you may have 2.7 
> installed on your system, but mod_wsgi may be using an older version). Did 
> you use a pre-built mod_wsgi or did you build it yourself?
>
> _Nik
>
> On 1/23/2013 8:08 AM, ghjim wrote:
>  
> The dev server works fine.  This only happens in my production server via 
> mod_wsgi.
>
>
>
> On Monday, January 21, 2013 8:26:06 PM UTC-8, Nikolas Stevenson-Molnar 
> wrote: 
>>
>> Does this happen only in production running via mod_wsgi, or does it 
>> happen in local development with the Django dev server as well? 
>>
>> _Nik 
>>
>> On 1/21/2013 4:13 PM, ghjim wrote: 
>> > Hello, 
>> > 
>> > I am getting an error when I access my root WSGIScriptAlias /: 
>> > 
>> > AttributeError at / 
>> > module object has no attribute JSONEncoder. 
>> > 
>> > I have seen similar reports on the web, some of them implying that 
>> > this is a python bug 
>> > but I can't implement any of the fixes. 
>> > 
>> > I am using Django 1.4.3 and Python2.7.3, mod_wsgi 3.4. 
>> > 
>> > With my Python2.7.3 installation I have both json amd simplejson 
>> > (I can import "json as simplejson" and print a directory of attributes 
>> > for 
>> > the module simplejson.  It includes JSONEncoder. 
>> > 
>> > I was hoping somebody has seen this. 
>> > 
>> > Thanks 
>> > 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> > Groups "Django users" group. 
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msg/django-users/-/_-xDLgBkMRYJ. 
>> > To post to this group, send email to django...@googlegroups.com. 
>> > To unsubscribe from this group, send email to 
>> > django-users...@googlegroups.com. 
>> > For more options, visit this group at 
>> > http://groups.google.com/group/django-users?hl=en. 
>>
>>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/qxlRVfEiy4YJ.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>  

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



Re: no attribute JSONEncoder

2013-01-23 Thread Nikolas Stevenson-Molnar
Are you sure that mod_wsgi was built against Python 2.7 (you may have
2.7 installed on your system, but mod_wsgi may be using an older
version). Did you use a pre-built mod_wsgi or did you build it yourself?

_Nik

On 1/23/2013 8:08 AM, ghjim wrote:
> The dev server works fine.  This only happens in my production server
> via mod_wsgi.
>
>
>
> On Monday, January 21, 2013 8:26:06 PM UTC-8, Nikolas Stevenson-Molnar
> wrote:
>
> Does this happen only in production running via mod_wsgi, or does it
> happen in local development with the Django dev server as well?
>
> _Nik
>
> On 1/21/2013 4:13 PM, ghjim wrote:
> > Hello,
> >
> > I am getting an error when I access my root WSGIScriptAlias /:
> >
> > AttributeError at /
> > module object has no attribute JSONEncoder.
> >
> > I have seen similar reports on the web, some of them implying that
> > this is a python bug
> > but I can't implement any of the fixes.
> >
> > I am using Django 1.4.3 and Python2.7.3, mod_wsgi 3.4.
> >
> > With my Python2.7.3 installation I have both json amd simplejson
> > (I can import "json as simplejson" and print a directory of
> attributes
> > for
> > the module simplejson.  It includes JSONEncoder.
> >
> > I was hoping somebody has seen this.
> >
> > Thanks
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/django-users/-/_-xDLgBkMRYJ
> .
> > To post to this group, send email to django...@googlegroups.com
> .
> > To unsubscribe from this group, send email to
> > django-users...@googlegroups.com .
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en
> .
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/qxlRVfEiy4YJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Upload multiple files using Ajax

2013-01-23 Thread Barry Morrison
I created this https://github.com/esacteksab/django-jquery-file-upload 
which is just jQuery-File-Upload ported to Django. It was a fork of someone 
elses' project that addressed my needs (support for models)

On Wednesday, January 23, 2013 2:18:01 AM UTC-8, psjinx wrote:
>
> You can use https://github.com/blueimp/jQuery-File-Upload. 
>
> You can use a view function similar to following. Here I have 3 models 
> - Project, Album and Flat 
>
> A Project can have multiple albums. 
> An Album can have multiple Flats 
> A Flat has an ImageField, caption as TextField and a ForeignKey to Album. 
>
> def upload_flat(request, project_slug, album_pk): 
> project = get_object_or_404(Project, slug=project_slug) 
> album = get_object_or_404(Album, pk=album_pk) 
> if request.method == 'GET': 
> flats = album.flat_set.all() 
> return render(request, "upload.html", {"project": project, 
> "album": album, "flats": flats}) 
>
> if request.method == "POST": 
> form = FlatForm(request.POST, request.FILES) 
> if form.is_valid(): 
> flat = form.save(commit=False) 
> flat.user = request.user 
> flat.album = album 
> flat.save() 
>
> data = { 
> "files": 
> [{ 
> "url": flat.image.url, 
> "thumbnail_url": flat.thumbnail.url, 
> "name": flat.image.name, 
> "type": "image/jpeg", 
> "size": flat.image.size, 
> "delete_url": reverse("delete_flat", args=[flat.pk]), 
> "delete_type": "DELETE", 
> "description": flat.description 
> }] 
> } 
> return HttpResponse(simplejson.dumps(data)) 
> return render(request, "upload.html", {}) 
>
> -- 
> Pankaj Singh 
> http://about.me/psjinx 
>
>
> On Wed, Jan 23, 2013 at 1:22 AM, Mengu  
> wrote: 
> > i used jquery.form plugin back in the day. it worked great but it had 
> > issues with large files. 
> > 
> > check out http://malsup.com/jquery/form/progress3.html and 
> > http://malsup.com/jquery/form/ 
> > 
> > On Jan 22, 6:05 pm, Andre Lopes  wrote: 
> >> Hi, 
> >> 
> >> I need to develop a form to upload multiple files. 
> >> 
> >> I was thinking in using an Ajax uploader. I have google some options 
> >> but there are to many and I don't know which one to choose. 
> >> 
> >> Any recommendations about this subject? 
> >> 
> >> Best Regards, 
> >> André. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Django users" group. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> django-users...@googlegroups.com . 
> > For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en. 
> > 
>

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



Re: Django-SEO issue

2013-01-23 Thread Jeff Ammons
Looks like a bug or partial implementation issue. I just submitted a pull 
request, so hopefully it'll get accepted quickly.

https://github.com/willhardy/django-seo/pull/35

-Jeff

On Tuesday, January 22, 2013 1:36:54 PM UTC-7, jondbaker wrote:
>
>  I wasn't. If anyone has a solution I'd still be interested in cleaning 
> up the clutter and removing the backends I'm not using.
>
> On 01/22/2013 12:05 PM, Jeff Ammons wrote:
>  
> Were you able to figure out what was happening here? I'm experiencing the 
> same issue. 
>
> On Friday, August 17, 2012 2:16:53 PM UTC-6, jondbaker wrote: 
>>
>> I've successfully installed Django-SEO, but when I try to limit the 
>> number of backends (I only need/want my admin to have 'path' and not the 
>> other three) I am met with the following error: 
>> AttributeError at /admin/ 'NoneType' object has no attribute '_meta' 
>>
>>  I am using the documentation here: 
>> http://django-seo.readthedocs.org/en/latest/reference/definition.html#Meta.backends
>>  
>>  *seo.py*
>> from rollyourown import seo
>>
>>  class AppMetadata(seo.Metadata):
>> title = seo.Tag(head=True, max_length=68)
>> description = seo.MetaTag(max_length=155)
>>
>>  class Meta:
>> backends = ('path',)
>> #backends = ('path', 'modelinstance', 'model', 'view',) This 
>> works but includes all default backends
>>
>>  *admin.py*
>> from django.contrib import admin
>> from rollyourown.seo.admin import register_seo_admin
>>
>>  from localsite.seo import AppMetadata
>>
>>  register_seo_admin(admin.site, AppMetadata)
>>
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/gB5-ZyRCpHIJ.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>
> -- 
> Software Developerhttps://github.com/jondbaker
> GPG: 1F6F3FFD
>
>  

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



Re: Can I set a "global" variable after user login, to use in my view?

2013-01-23 Thread Tomas Neme
> I don`t understand that.. in my form, I don't have the request, or I have?
>
> I know I have request in my view, but I need to pass UserProfile to my form, 
> but inlineformset_factory doesn't accept to pass vUserProfile as parameter, 
> even I modified __init__ to get this parameter.

OK, so you were asking the wrong question, or incompletely. So you
want to know how to pass a parameter to your form via the formset.

Why don't you show us your code? The view and the form, mainly. The
models too, if your final objective is to modify a model object

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



Re: no attribute JSONEncoder

2013-01-23 Thread ghjim
The dev server works fine.  This only happens in my production server via 
mod_wsgi.



On Monday, January 21, 2013 8:26:06 PM UTC-8, Nikolas Stevenson-Molnar 
wrote:
>
> Does this happen only in production running via mod_wsgi, or does it 
> happen in local development with the Django dev server as well? 
>
> _Nik 
>
> On 1/21/2013 4:13 PM, ghjim wrote: 
> > Hello, 
> > 
> > I am getting an error when I access my root WSGIScriptAlias /: 
> > 
> > AttributeError at / 
> > module object has no attribute JSONEncoder. 
> > 
> > I have seen similar reports on the web, some of them implying that 
> > this is a python bug 
> > but I can't implement any of the fixes. 
> > 
> > I am using Django 1.4.3 and Python2.7.3, mod_wsgi 3.4. 
> > 
> > With my Python2.7.3 installation I have both json amd simplejson 
> > (I can import "json as simplejson" and print a directory of attributes 
> > for 
> > the module simplejson.  It includes JSONEncoder. 
> > 
> > I was hoping somebody has seen this. 
> > 
> > Thanks 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/_-xDLgBkMRYJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>
>

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



how do I dynamically modify a choice field

2013-01-23 Thread frocco
Hello,

In my view, I am displaying rows of data that have a choice field in a form.
one form for each row

I want to change the choice this before printing.

one row can have 1 to 5 choices
another row can have 1 to 10 choices depending on values in each row.

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



Re: BigAutoField

2013-01-23 Thread SteveB
Yes, I'll post it there.

Thanks,
Steve

On Wednesday, 23 January 2013 13:40:44 UTC, psjinx wrote:
>
> Hey Steve, 
>
> You should ask this questions in django-developers mailing list as 
> it's related to development of django itself. It will be best to hear 
> comments from Core Developers. 
>
> -- 
> Pankaj Singh 
> http://about.me/psjinx 
>
>
> On Wed, Jan 23, 2013 at 6:58 PM, SteveB  
> wrote: 
> > Can anybody provide an update on the request to define a BigAutoField in 
> > Django? 
> > We could really use this model field type without having to do 
> workarounds 
> > and customizations. 
> > Can any of the Django developers comment on when this will be released? 
> > 
> > Thanks, 
> > Steve 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/etnu2n_Fc6wJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>

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



Re: how do I code sql using the raw method?

2013-01-23 Thread frocco
Nevermind, I got this working.

On Wednesday, January 23, 2013 9:13:46 AM UTC-5, frocco wrote:
>
> Hello,
>
> I need to code a select statement based on a dynamic field.
>
> select price_a as price from table
>
> def return priceLevel(x):
> if x == 'A': return 'price_a'
> if x == 'B': return 'price_b'
> if x == 'C': return 'price_c'
>
> so my sql would be:
>
> fld = priceLevel('B')
> select fld as price from table
>
> I cannot get the select statement to work.
> Thanks
>

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



how do I code sql using the raw method?

2013-01-23 Thread frocco
Hello,

I need to code a select statement based on a dynamic field.

select price_a as price from table

def return priceLevel(x):
if x == 'A': return 'price_a'
if x == 'B': return 'price_b'
if x == 'C': return 'price_c'

so my sql would be:

fld = priceLevel('B')
select fld as price from table

I cannot get the select statement to work.
Thanks

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



Re: interplay between django and twitter-bootstrap...

2013-01-23 Thread Sameer Oak
Hello Pankaj,

This is much of a help from you. Thank you very much for you help.

Regards,
- sameer oak.


On Wed, Jan 23, 2013 at 7:07 PM, Pankaj Singh  wrote:

> Hey Sameer,
>
> Django gives you complete freedom for choosing client side libraries.
> You can easily use twitter-bootstrap in django templates. There are
> many libraries written using django and bootstrap to create beautiful
> forms. Here are some example -
>
> 1. http://django-crispy-forms.readthedocs.org/en/d-0/
> 2. https://github.com/pinax/django-forms-bootstrap
> 3. https://github.com/brutasse/django-floppyforms
> 4. https://github.com/earle/django-bootstrap
> 5. https://github.com/dyve/django-bootstrap-toolkit
>
> For getting started with bootstrap and django,
> 1. Download twitter-bootstrap from official website
> 2. Create a new django project
> 3. Copy your html files in templates folder
> 4. Copy javascript files, css files and images in static folder
> 5. Try to get a static template up using TemplateView.
> 6. Now you can customize your templates further and use features of
> django templates and views to make things more dynamic
>
> This will give you basic understanding of `how to integrate
> django+bootstrap".
>
> --
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 9:53 AM, SameerOak  wrote:
> > Hello,
> >
> > I am new to web development and python and django was my immediate
> choice to
> > start with. I am in a process of developing a moderated traffic portal.
> > Coming straight to the query, can I design my web pages using
> > twitter-bootstrap and django framework in the back-end?
> >
> > Kindly help.
> >
> > Regards,
> > - sameer oak.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/django-users/-/WypNp46wXB0J.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



RE: Newbee: Unable to change the date because Calender won't

2013-01-23 Thread Babatunde Akinyanmi
 POP-UP as said in Tutorial
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="=_Part_397_27447967.1358923165638"

--=_Part_397_27447967.1358923165638
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Is JavaScript activated?

Sent from my Windows Phone
From: Shiva MSK
Sent: 1/23/2013 2:08 PM
To: django-users@googlegroups.com
Subject: Newbee: Unable to change the date because Calender won't
POP-UP as said in Tutorial


  Hello Friends,
I am new to the Django and right now i am doing=20
"Writing Your First Django app" .In the tutorial , it was said "Each=20
DateTimeField gets free JavaScript shortcuts. Dates get a =E2=80=9CToday=E2=
=80=9D shortcut=20
and calendar popup, and
times get a =E2=80=9CNow=E2=80=9D shortcut and a convenient popup that list=
s commonly=20
entered times." But i am not getting these Pop-up ,so i am unable to change=
=20
the date .
Please Suggest Something .
   Thank you,

-Shiva

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


--=_Part_397_27447967.1358923165638
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Is JavaScript activated?Sent from my Windows Phon=
eFrom: Shiva MSKSent: =
1/23/2013 =
2:08 PMTo: django-users@googlegroups.comNewbee: Unable to change the date because Calender won't POP-UP as =
said in Tutorial Hello Friends,<=
br>=
 I am new=
 to the Django and right now i am doing "Writing Your First Django app" .In=
 the tutorial , it was said "Each DateTimeField gets free JavaScript shortc=
uts. Dates get a =E2=80=9CToday=E2=80=9D shortcut and calendar popup, 

Re: BigAutoField

2013-01-23 Thread Pankaj Singh
Hey Steve,

You should ask this questions in django-developers mailing list as
it's related to development of django itself. It will be best to hear
comments from Core Developers.

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 6:58 PM, SteveB  wrote:
> Can anybody provide an update on the request to define a BigAutoField in
> Django?
> We could really use this model field type without having to do workarounds
> and customizations.
> Can any of the Django developers comment on when this will be released?
>
> Thanks,
> Steve
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/etnu2n_Fc6wJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: interplay between django and twitter-bootstrap...

2013-01-23 Thread Pankaj Singh
Hey Sameer,

Django gives you complete freedom for choosing client side libraries.
You can easily use twitter-bootstrap in django templates. There are
many libraries written using django and bootstrap to create beautiful
forms. Here are some example -

1. http://django-crispy-forms.readthedocs.org/en/d-0/
2. https://github.com/pinax/django-forms-bootstrap
3. https://github.com/brutasse/django-floppyforms
4. https://github.com/earle/django-bootstrap
5. https://github.com/dyve/django-bootstrap-toolkit

For getting started with bootstrap and django,
1. Download twitter-bootstrap from official website
2. Create a new django project
3. Copy your html files in templates folder
4. Copy javascript files, css files and images in static folder
5. Try to get a static template up using TemplateView.
6. Now you can customize your templates further and use features of
django templates and views to make things more dynamic

This will give you basic understanding of `how to integrate django+bootstrap".

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 9:53 AM, SameerOak  wrote:
> Hello,
>
> I am new to web development and python and django was my immediate choice to
> start with. I am in a process of developing a moderated traffic portal.
> Coming straight to the query, can I design my web pages using
> twitter-bootstrap and django framework in the back-end?
>
> Kindly help.
>
> Regards,
> - sameer oak.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/WypNp46wXB0J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



BigAutoField

2013-01-23 Thread SteveB
Can anybody provide an update on the request to define a BigAutoField in 
Django?
We could really use this model field type without having to do workarounds 
and customizations.
Can any of the Django developers comment on when this will be released?

Thanks,
Steve

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



Re: django admin - changelist view: keep selected items on multiple pages

2013-01-23 Thread Pankaj Singh
Hey Luke,

This is not related to link you mentioned. That link only talks about
`How to customize the admin change list`.

You can achieve what you want using cookies.

Please have a look at similar question
http://css-tricks.com/forums/discussion/12141/javascript-remember-what-was-selected-after-refresh/p1.

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 2:12 PM, luke lukes  wrote:
> a question about admin: in the changelist page, is it possible to keep the
> selected items of a page while going to another page and returning to it.
>
> I mean:
>
> I'm on the page 1;
> I select some items;
> then i go to page 2;
> I select other items;
> I return to page 1;
> my previous selection is lost.
>
> Is it possible to keep that selection somewhere (cookie, session,...)?
>
> thanks, Luke
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/h4gvzMFOXMcJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: django-registration-template

2013-01-23 Thread Pankaj Singh
Hey Sameer,

His project uses twitter bootstrap forms in templates. That's the only
unique thing about this project.

If you are looking for an email based registration app in django which
uses bootstrap forms then you can use this one.

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 2:21 PM, SameerOak  wrote:
> Hello,
>
> Sorry if you find my question too foolish or naive. Actually, I don't have
> any web development experience and this is the first time I'm trying to
> learn django and twitter-bootstrap. While searching on the forum for a
> solution about how to use twitter-bootstrap on the client side while django
> as MVC engine, I found link to your project. It isn't very clear to me as to
> what exactly your project is about? But my gut feel is this is something
> what I'm looking for.
>
> Please provide some more details.
>
> Regards,
> - sameer oak.
>
>
> On Friday, November 4, 2011 9:41:54 AM UTC+5:30, Ezequiel Bertti wrote:
>>
>> Hi,
>>
>> I just release a project on github with bootstrap from twitter v1.4 form
>> django-registration.
>>
>> Is a simple use of bootstrap just using template for render with css. No
>> python code need.
>>
>> Its is perfect sample for designers to know how to use bootstrap without
>> asking to programmer to do some fix in their code.
>>
>> https://github.com/ebertti/django-registration-bootstrap
>>
>> It is my first of many github public projects.
>>
>> --
>> Ezequiel Bertti
>> E-Mail: ebe...@gmail.com
>> From Brazil
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/hXQfJECymeUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Custom storage question

2013-01-23 Thread Bart Grantham
Hello, I'm working on a project that has specific, but not terribly 
complex, file management needs and I think I may need to write a custom 
Storage backend.  But I'm not totally sure, so let me explain my problem 
before I ask any specific questions.

I am migrating a large set of files into this new Django project and I need 
to have these files private (ie. not in MEDIA_ROOT, and with url() not 
implemented).  The file metadata such as name, md5, the uploading user, 
file size, etc. need to be maintained in the database, presumably computed 
on the fly on saving the file.  The scheme used in the current system, 
which is so-so but I'm ok with perpetuating, is to have the files stored as 
(file_id % 100)/file_id, so that file_id==12345 would be stored in 
45/12345.  Disregarding the lack of merit in such a scheme, let's just take 
that as part of the exercise I'm trying to achieve here.

I have already implemented a mediocre solution with just building a file 
metadata model, having one of the attributes be a FileField, and overriding 
save() to manage the files properly, but that feels really clunky.

The documentation is pretty unhelpful in understanding when my custom 
Storage class really comes into play, if I should be subclassing File, how 
this all interacts with FileField, or if the solution lies elsewhere.  For 
example, the docs give the impression that by overriding Storage.path() you 
can mangle file names however you'd like, but that doesn't seem to have any 
effect on the FileField of my model.  It would help if there was a diagram 
or even several sentences that talked about how these classes fit together 
to produce Django's file management (ex. which class is authoritative for 
what information and what time in the file upload/save/retrieval process).

There's two other problems besides the mechanics of file system management. 
 One is that the model that contains the file is itself a member of another 
model, making form management more laborious than it could be (I think). 
 Second, I need to import a few thousand files via an import script and it 
doesn't seem quite right that I would just manually set the FileField's 
value (not a serious problem, it's just import, but it seems to indicate a 
deeper misstep).  Surely there's a simpler way of having database-backed 
file metadata than what I've hacked here.

I think what would be ideal is if I could subclass models.Model and 
files.File together, but that seems inadvisable.  Are there any simple 
examples of people doing the kind of thing I'm doing?  Or is there 
somewhere in the docs or mailing list that I missed that has the one or two 
sentences that I need to read that will clear it all up?  It doesn't seem 
complex, but it's turning out that way.

Bart

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



Re: django-registration-template

2013-01-23 Thread SameerOak
Hello,

Sorry if you find my question too foolish or naive. Actually, I don't have 
any web development experience and this is the first time I'm trying to 
learn django and twitter-bootstrap. While searching on the forum for a 
solution about how to use twitter-bootstrap on the client side while django 
as MVC engine, I found link to your project. It isn't very clear to me as 
to what exactly your project is about? But my gut feel is this is something 
what I'm looking for.

Please provide some more details.

Regards,
- sameer oak.


On Friday, November 4, 2011 9:41:54 AM UTC+5:30, Ezequiel Bertti wrote:
>
> Hi, 
>
> I just release a project on github with bootstrap from twitter v1.4 form 
> django-registration.
>
> Is a simple use of bootstrap just using template for render with css. No 
> python code need.
>
> Its is perfect sample for designers to know how to use bootstrap without 
> asking to programmer to do some fix in their code.
>
> https://github.com/ebertti/django-registration-bootstrap 
>
> It is my first of many github public projects.
>
> -- 
> Ezequiel Bertti
> E-Mail: ebe...@gmail.com 
> From Brazil
>

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



django admin - changelist view: keep selected items on multiple pages

2013-01-23 Thread luke lukes


a question about admin: in the changelist 
page,
 
is it possible to keep the selected items of a page while going to another 
page and returning to it.

I mean:

   1. I'm on the page 1;
   2. I select some items;
   3. then i go to page 2;
   4. I select other items;
   5. I return to page 1;
   6. my previous selection is lost.

Is it possible to keep that selection somewhere (cookie, session,...)?

thanks, Luke

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



django admin: keeping selected items on different page in changelist view

2013-01-23 Thread luke lukes


Hi everyone.

a question about admin: in the changelist page, is it possible to keep the 
selected items of a page while going to another page and returning to it.

I mean:


   1. I'm on the page 1;
   2. I select some items;
   3. then i go to page 2;
   4. I select other items;
   5. I return to page 1;
   6. my selection is lost.
   
Is it possible to keep it somewhere (cookie, session,...)?

thanks, Luke

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



Re: django<-->twitter bootstrap philosophy

2013-01-23 Thread SameerOak
Hello Vincent,

I'm also a new comer to the web-2.0 world. After almost 12+ years of 
experience in developing enterprise level products in pure C on Linux and a 
lot of bash shell scripting, I thought I'd start something new. So I left 
job, 25-Jan-2013 being the last day.
It's better late than never. For good things, it's never late. I'd like to 
contribute to your effort, of course, if you agree.

Regards,
- sameer oak.




On Tuesday, September 25, 2012 8:58:08 PM UTC+5:30, Vincent Fulco wrote:
>
> Been thru the Django manual, bootstrap website instructions and other 
> resources a few times so have working understanding of MVC structure.  
> However, the incorporation of bootstrap throwing me off a little.  Working 
> on a ecommerce idea, for now plan is to create homepage  (using bootstrap) 
> as a launchpad to other pages (using bootstrap) providing services for two 
> different target audiences (producers and consumers of service).  Once at 
> the second site(?), this is where the MVC comes in for 
> login/registration/EULA agreements/data io, etc.
>
> Is bootstrap considered to be substitute template for parts of the website 
> then the django templating system takes up the rest?
>
> Any trailheads for these concepts would be much appreciated.
>
> TIA, V.
>

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



Newbee: Unable to change the date because Calender won't POP-UP as said in Tutorial

2013-01-23 Thread Shiva MSK


  Hello Friends,
I am new to the Django and right now i am doing 
"Writing Your First Django app" .In the tutorial , it was said "Each 
DateTimeField gets free JavaScript shortcuts. Dates get a “Today” shortcut 
and calendar popup, and
times get a “Now” shortcut and a convenient popup that lists commonly 
entered times." But i am not getting these Pop-up ,so i am unable to change 
the date .
Please Suggest Something .
   Thank you,

-Shiva

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



interplay between django and twitter-bootstrap...

2013-01-23 Thread SameerOak
Hello,

I am new to web development and python and django was my immediate choice 
to start with. I am in a process of developing a moderated traffic portal.
Coming straight to the query, can I design my web pages using 
twitter-bootstrap and django framework in the back-end?

Kindly help.

Regards,
- sameer oak.

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



Re: ignore field during form validation

2013-01-23 Thread Sarfraz ahmad
def clean_A6M1F6_F(self):
data=self.cleaned_data['A6M1F6_F']
if A6M1_mobile.objects.filter(A6M1F6=data).exists():
 raise forms.ValidationError(" already exixts")
return data
i have this clean_field method in the form and given field is not
updatable... whenever i tried to update the record with the form having
initial data as the record already inserted in the database this method
raise an exception while calling the is_valid() method



On Tue, Jan 22, 2013 at 7:39 PM, Sarfraz ahmad wrote:

> gusy i have form which has 5 fields i have defined a clean_field
> method which doesn't allow a duplicate entry in the database.
> bt when i tried to update the model instance while calling form.is_valid()
> method it calls the clean_field() method and returns error that entry
> already exists.
>
>
>
> On Tue, Jan 22, 2013 at 2:57 AM, Mario Gudelj wrote:
>
>> Add required=False to the form field and it won't be validated.
>> On 22 Jan, 2013 2:30 AM, "Jonathan D. Baker" <
>> jonathandavidba...@gmail.com> wrote:
>>
>>>  Hi Sarfraz,
>>>
>>> If your form class inherits from ModelForm, you can use a subset of
>>> fields within your form per the following documentation:
>>> https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form
>>>
>>> If you're not inheriting from ModelForm, then it's a matter of
>>> configuring your model and form fields to allow null/blank. In this case,
>>> seeing your code would help provide more direction.
>>>
>>> Hope this helps,
>>> Jonathan
>>>
>>> On 01/21/2013 04:34 AM, Sarfraz ahmad wrote:
>>>
>>> Hello everyone,
>>>
>>>  i m facing a problem while validating django
>>> form. i have 5 form fields in a form and in the view i want to
>>> validate only three form fields which i need to update .. tell me a
>>> solution if anyone have any
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/django-users/-/oZfMAZ8FWt4J.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>>
>>> --
>>> Software Developerhttps://github.com/jondbaker
>>> GPG: 1F6F3FFD
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

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



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Sarfraz ahmad
items = request.user. a11m1_user_itmes_set.all() works correctly
thank you buddies


On Wed, Jan 23, 2013 at 4:40 PM, Rafael E. Ferrero  wrote:

> Sorry, but select_related() dont work for you??
>
>
> 2013/1/23 Pankaj Singh 
>
>> items = request.user. a11m1_user_itmes_set.all()
>>
>> is equivalent to
>>
>> items = A11M1_user_itmes.objects.filter(user=request.user)
>>
>> `items` will contain all items A11M1_user_itmes related to currently
>> logged in user.
>>
>> Now, if you want to get `content_object` for a particular item, do
>> something like following
>>
>> i = items[0]
>>
>> `i.content_object` will refer to original object used.
>>
>> Please go through official documentation for GenericForeignKey once more.
>>
>> Links:
>> 1.
>> https://docs.djangoproject.com/en/1.4/ref/contrib/contenttypes/#django.contrib.contenttypes.generic.GenericForeignKey
>>
>> --
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Wed, Jan 23, 2013 at 4:11 PM, Sarfraz ahmad 
>> wrote:
>> > i dont found any query related to this model bro
>> >
>> >
>> > On Wed, Jan 23, 2013 at 4:01 PM, Pankaj Singh 
>> wrote:
>> >>
>> >> If you want to get all `A11M1_user_items` objects then following query
>> >> should work
>> >>
>> >>
>> >> --
>> >> Pankaj Singh
>> >> http://about.me/psjinx
>> >>
>> >>
>> >> On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad <
>> sarfrazdja...@gmail.com>
>> >> wrote:
>> >> > i have the same model having one foreignkey to User and second to the
>> >> > ContentType
>> >> >
>> >> > class A11M1_user_itmes(models.Model):
>> >> > A11M1F1_user=models.ForeignKey(User)
>> >> > content_type = models.ForeignKey(ContentType)
>> >> > object_id = models.PositiveIntegerField()
>> >> > content_object = generic.GenericForeignKey('content_type',
>> >> > 'object_id')
>> >> > this is the code of ma model.. using this code i wanna get all
>> >> > objects
>> >> > related to current logged in user
>> >> >
>> >> >
>> >> > On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh 
>> wrote:
>> >> >>
>> >> >> So, you have a custom model like following
>> >> >>
>> >> >> class MyModel(models.Model):
>> >> >> ...
>> >> >> content_type = models.ForeignKey(ContentType)
>> >> >> ...
>> >> >>
>> >> >> And you want to run a query on MyModel which should return objects
>> >> >> from various apps related to currently logged in User.
>> >> >>
>> >> >> Is this what you want to achieve?
>> >> >>
>> >> >> Pankaj Singh
>> >> >> http://about.me/psjinx
>> >> >>
>> >> >>
>> >> >> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad
>> >> >> 
>> >> >> wrote:
>> >> >> > thanx buddy bt i wish to do it in a manner that a model which has
>> a
>> >> >> > foreign
>> >> >> > key to ContentType, when i make a query on this model it returns
>> all
>> >> >> > the
>> >> >> > objects from various apps related to current logged in user
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh 
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> Hey Sarfraz,
>> >> >> >>
>> >> >> >> If you have an user object, then you can get all related objects
>> >> >> >> using
>> >> >> >> following code
>> >> >> >>
>> >> >> >> user = User.objects.get(username="psjinx")
>> >> >> >>
>> >> >> >> related_links = [rel.get_accessor_name() for rel in
>> >> >> >> user._meta.get_all_related_objects()]
>> >> >> >>
>> >> >> >> ## above code will give a list of attribute names for each
>> related
>> >> >> >> object to an user
>> >> >> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>> >> >> >> 'recipient_set', 'customer']
>> >> >> >>
>> >> >> >> Now you can iterate over this list
>> >> >> >>
>> >> >> >> for link in related_links:
>> >> >> >> objects = getattr(user, link).all()
>> >> >> >> for object in objects:
>> >> >> >> ## do something with object
>> >> >> >>
>> >> >> >> FYI, getattr(user, link) is manager for that relate object.
>> >> >> >>
>> >> >> >>
>> >> >> >> Pankaj Singh
>> >> >> >> http://about.me/psjinx
>> >> >> >>
>> >> >> >>
>> >> >> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh > >
>> >> >> >> wrote:
>> >> >> >> > Hey Sarfraz,
>> >> >> >> >
>> >> >> >> > You can use any of following methods:
>> >> >> >> >
>> >> >> >> > User._meta.get_all_related_m2m_objects_with_model()
>> >> >> >> > User._meta.get_all_related_objects()
>> >> >> >> > User._meta.get_all_related_many_to_many_objects()
>> >> >> >> > User._meta.get_all_related_objects_with_model()
>> >> >> >> >
>> >> >> >> > get_all_related_objects() is the one I guess you may want to
>> use
>> >> >> >> > in
>> >> >> >> > your
>> >> >> >> > case.
>> >> >> >> >
>> >> >> >> > Pankaj Singh
>> >> >> >> > http://about.me/psjinx
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad
>> >> >> >> > 
>> >> >> >> > wrote:
>> >> >> >> 

Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Rafael E. Ferrero
Sorry, but select_related() dont work for you??

2013/1/23 Pankaj Singh 

> items = request.user. a11m1_user_itmes_set.all()
>
> is equivalent to
>
> items = A11M1_user_itmes.objects.filter(user=request.user)
>
> `items` will contain all items A11M1_user_itmes related to currently
> logged in user.
>
> Now, if you want to get `content_object` for a particular item, do
> something like following
>
> i = items[0]
>
> `i.content_object` will refer to original object used.
>
> Please go through official documentation for GenericForeignKey once more.
>
> Links:
> 1.
> https://docs.djangoproject.com/en/1.4/ref/contrib/contenttypes/#django.contrib.contenttypes.generic.GenericForeignKey
>
> --
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 4:11 PM, Sarfraz ahmad 
> wrote:
> > i dont found any query related to this model bro
> >
> >
> > On Wed, Jan 23, 2013 at 4:01 PM, Pankaj Singh  wrote:
> >>
> >> If you want to get all `A11M1_user_items` objects then following query
> >> should work
> >>
> >>
> >> --
> >> Pankaj Singh
> >> http://about.me/psjinx
> >>
> >>
> >> On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad  >
> >> wrote:
> >> > i have the same model having one foreignkey to User and second to the
> >> > ContentType
> >> >
> >> > class A11M1_user_itmes(models.Model):
> >> > A11M1F1_user=models.ForeignKey(User)
> >> > content_type = models.ForeignKey(ContentType)
> >> > object_id = models.PositiveIntegerField()
> >> > content_object = generic.GenericForeignKey('content_type',
> >> > 'object_id')
> >> > this is the code of ma model.. using this code i wanna get all
> >> > objects
> >> > related to current logged in user
> >> >
> >> >
> >> > On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh 
> wrote:
> >> >>
> >> >> So, you have a custom model like following
> >> >>
> >> >> class MyModel(models.Model):
> >> >> ...
> >> >> content_type = models.ForeignKey(ContentType)
> >> >> ...
> >> >>
> >> >> And you want to run a query on MyModel which should return objects
> >> >> from various apps related to currently logged in User.
> >> >>
> >> >> Is this what you want to achieve?
> >> >>
> >> >> Pankaj Singh
> >> >> http://about.me/psjinx
> >> >>
> >> >>
> >> >> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad
> >> >> 
> >> >> wrote:
> >> >> > thanx buddy bt i wish to do it in a manner that a model which has a
> >> >> > foreign
> >> >> > key to ContentType, when i make a query on this model it returns
> all
> >> >> > the
> >> >> > objects from various apps related to current logged in user
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh 
> >> >> > wrote:
> >> >> >>
> >> >> >> Hey Sarfraz,
> >> >> >>
> >> >> >> If you have an user object, then you can get all related objects
> >> >> >> using
> >> >> >> following code
> >> >> >>
> >> >> >> user = User.objects.get(username="psjinx")
> >> >> >>
> >> >> >> related_links = [rel.get_accessor_name() for rel in
> >> >> >> user._meta.get_all_related_objects()]
> >> >> >>
> >> >> >> ## above code will give a list of attribute names for each related
> >> >> >> object to an user
> >> >> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
> >> >> >> 'recipient_set', 'customer']
> >> >> >>
> >> >> >> Now you can iterate over this list
> >> >> >>
> >> >> >> for link in related_links:
> >> >> >> objects = getattr(user, link).all()
> >> >> >> for object in objects:
> >> >> >> ## do something with object
> >> >> >>
> >> >> >> FYI, getattr(user, link) is manager for that relate object.
> >> >> >>
> >> >> >>
> >> >> >> Pankaj Singh
> >> >> >> http://about.me/psjinx
> >> >> >>
> >> >> >>
> >> >> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh 
> >> >> >> wrote:
> >> >> >> > Hey Sarfraz,
> >> >> >> >
> >> >> >> > You can use any of following methods:
> >> >> >> >
> >> >> >> > User._meta.get_all_related_m2m_objects_with_model()
> >> >> >> > User._meta.get_all_related_objects()
> >> >> >> > User._meta.get_all_related_many_to_many_objects()
> >> >> >> > User._meta.get_all_related_objects_with_model()
> >> >> >> >
> >> >> >> > get_all_related_objects() is the one I guess you may want to use
> >> >> >> > in
> >> >> >> > your
> >> >> >> > case.
> >> >> >> >
> >> >> >> > Pankaj Singh
> >> >> >> > http://about.me/psjinx
> >> >> >> >
> >> >> >> >
> >> >> >> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad
> >> >> >> > 
> >> >> >> > wrote:
> >> >> >> >> hello friends
> >> >> >> >>   i have a project with 7 applications
> installed
> >> >> >> >> in
> >> >> >> >> it
> >> >> >> >> and i
> >> >> >> >> want to get all the objects related to a particular user from
> all
> >> >> >> >> the
> >> >> >> >> applications of ma project. please tell me how can i
> get
> >> >> >> 

Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
items = request.user. a11m1_user_itmes_set.all()

is equivalent to

items = A11M1_user_itmes.objects.filter(user=request.user)

`items` will contain all items A11M1_user_itmes related to currently
logged in user.

Now, if you want to get `content_object` for a particular item, do
something like following

i = items[0]

`i.content_object` will refer to original object used.

Please go through official documentation for GenericForeignKey once more.

Links:
1. 
https://docs.djangoproject.com/en/1.4/ref/contrib/contenttypes/#django.contrib.contenttypes.generic.GenericForeignKey

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 4:11 PM, Sarfraz ahmad  wrote:
> i dont found any query related to this model bro
>
>
> On Wed, Jan 23, 2013 at 4:01 PM, Pankaj Singh  wrote:
>>
>> If you want to get all `A11M1_user_items` objects then following query
>> should work
>>
>>
>> --
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad 
>> wrote:
>> > i have the same model having one foreignkey to User and second to the
>> > ContentType
>> >
>> > class A11M1_user_itmes(models.Model):
>> > A11M1F1_user=models.ForeignKey(User)
>> > content_type = models.ForeignKey(ContentType)
>> > object_id = models.PositiveIntegerField()
>> > content_object = generic.GenericForeignKey('content_type',
>> > 'object_id')
>> > this is the code of ma model.. using this code i wanna get all
>> > objects
>> > related to current logged in user
>> >
>> >
>> > On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh  wrote:
>> >>
>> >> So, you have a custom model like following
>> >>
>> >> class MyModel(models.Model):
>> >> ...
>> >> content_type = models.ForeignKey(ContentType)
>> >> ...
>> >>
>> >> And you want to run a query on MyModel which should return objects
>> >> from various apps related to currently logged in User.
>> >>
>> >> Is this what you want to achieve?
>> >>
>> >> Pankaj Singh
>> >> http://about.me/psjinx
>> >>
>> >>
>> >> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad
>> >> 
>> >> wrote:
>> >> > thanx buddy bt i wish to do it in a manner that a model which has a
>> >> > foreign
>> >> > key to ContentType, when i make a query on this model it returns all
>> >> > the
>> >> > objects from various apps related to current logged in user
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh 
>> >> > wrote:
>> >> >>
>> >> >> Hey Sarfraz,
>> >> >>
>> >> >> If you have an user object, then you can get all related objects
>> >> >> using
>> >> >> following code
>> >> >>
>> >> >> user = User.objects.get(username="psjinx")
>> >> >>
>> >> >> related_links = [rel.get_accessor_name() for rel in
>> >> >> user._meta.get_all_related_objects()]
>> >> >>
>> >> >> ## above code will give a list of attribute names for each related
>> >> >> object to an user
>> >> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>> >> >> 'recipient_set', 'customer']
>> >> >>
>> >> >> Now you can iterate over this list
>> >> >>
>> >> >> for link in related_links:
>> >> >> objects = getattr(user, link).all()
>> >> >> for object in objects:
>> >> >> ## do something with object
>> >> >>
>> >> >> FYI, getattr(user, link) is manager for that relate object.
>> >> >>
>> >> >>
>> >> >> Pankaj Singh
>> >> >> http://about.me/psjinx
>> >> >>
>> >> >>
>> >> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh 
>> >> >> wrote:
>> >> >> > Hey Sarfraz,
>> >> >> >
>> >> >> > You can use any of following methods:
>> >> >> >
>> >> >> > User._meta.get_all_related_m2m_objects_with_model()
>> >> >> > User._meta.get_all_related_objects()
>> >> >> > User._meta.get_all_related_many_to_many_objects()
>> >> >> > User._meta.get_all_related_objects_with_model()
>> >> >> >
>> >> >> > get_all_related_objects() is the one I guess you may want to use
>> >> >> > in
>> >> >> > your
>> >> >> > case.
>> >> >> >
>> >> >> > Pankaj Singh
>> >> >> > http://about.me/psjinx
>> >> >> >
>> >> >> >
>> >> >> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad
>> >> >> > 
>> >> >> > wrote:
>> >> >> >> hello friends
>> >> >> >>   i have a project with 7 applications installed
>> >> >> >> in
>> >> >> >> it
>> >> >> >> and i
>> >> >> >> want to get all the objects related to a particular user from all
>> >> >> >> the
>> >> >> >> applications of ma project. please tell me how can i get
>> >> >> >> all
>> >> >> >> these
>> >> >> >> objects using ContentType framework
>> >> >> >>
>> >> >> >>
>> >> >> >> thank you all
>> >> >> >>
>> >> >> >> --
>> >> >> >> You received this message because you are subscribed to the
>> >> >> >> Google
>> >> >> >> Groups
>> >> >> >> "Django users" group.
>> >> >> >> To view this discussion on the web visit
>> >> >> >> 

Re: download pdf in admin

2013-01-23 Thread Pankaj Singh
Hey Milan,

Uploaded files are available at `MEDIA_URL` which is generally set to
`/media`. So if you enable serving for media files, then your file should
be available at

http://127.0.0.1:8000/media/scany/2013/01/21/hrebci.pdf

Please have a look at official documentation for this,
https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-other-directories
.

--
Pankaj Singh
http://about.me/psjinx


On Tue, Jan 22, 2013 at 6:08 AM, grat  wrote:

> hi,
>
> i cannot download file upladed by admin.
>
> i have this model:
> class Smlouvy(models.Model):
> note= models.TextField(blank=True)
> pdf= models.FileField( upload_to =
> 'scany/%Y/%m/%d',blank=True,verbose_name="Pdf Filw")
>
> in Admin i upladed file, and file is in correct directory. But cannot
> download this file. I get this error:
>
> ...
> Page not found (404) Request Method: GETRequest URL:
> http://127.0.0.1:8000/scany/2013/01/21/hrebci.pdf
>
> Using the URLconf defined in maxmart.urls, Django tried these URL
> patterns, in this order:
>
>1. ^admin/
>
> The current URL, scany/2013/01/21/hrebci.pdf, didn't match any of these.
>
>
> Do you know, where is problem?
>
>
> Thanks Milan
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/pKPcvF3xW10J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Can I set a "global" variable after user login, to use in my view?

2013-01-23 Thread Fellipe Henrique
I don`t understand that.. in my form, I don't have the request, or I have?

I know I have request in my view, but I need to pass UserProfile to my
form, but inlineformset_factory doesn't accept to pass vUserProfile as
parameter, even I modified __init__ to get this parameter.

Here is my form code:  http://pastebin.com/AeYUvX8S
my view code: http://pastebin.com/rBzg0jM8

and the traceback: http://pastebin.com/0Z9NTF4G

I need to pass UserProfile to my form, to modified the queryset "idproduto"
field.

How can  I do these?



PS: sorry my poor english...

T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

*"Quemadmodum gladius neminem occidit, occidentis telum est."* (Epistulae
morales ad Lucilium,
Lucius Annaeus Seneca)

*"Any intelligent fool can make things bigger, more complex, and more
violent. It takes a touch of genius -- and a lot of courage -- to move in
the opposite direction."*
Albert Einstein (March 14th 1879 – April 18th 1955)


2013/1/22 Tomas Neme 

>
> vUserProfile=request.user.profile
> or
> vUserProfile=request.user.get_profile()
> to be more flexible
>
>
>
> On Tue, Jan 22, 2013 at 5:01 PM, Fellipe Henrique wrote:
>
>> The problem is, I need to pass this request.user to one form, using a
>> inlineformset_factory..in these code:
>>
>> class PedidoItensForm(ModelForm):
>> class Meta:
>> model = ItensPedido
>>
>> def __init__(self, *args, **kwargs):
>> profile = kwargs.pop('vUserProfile', None)
>> super(PedidoItensForm, self).__init__(*args, **kwargs)
>> self.fields["idproduto"].queryset =
>> Produto.objects.filter(idempresa=profile.idempresa)
>>
>> I need to pass UserProfile to my form, to get works my filter.
>>
>> If I use inlineformset_factory, how can I pass the vUserProfile ?
>>
>>
>> Thanks
>>
>> T.·.F.·.A.·. S+F
>> *Fellipe Henrique P. Soares*
>>
>> *"Quemadmodum gladius neminem occidit, occidentis telum est."* (Epistulae
>> morales ad 
>> Lucilium,
>> Lucius Annaeus Seneca)
>>
>> *"Any intelligent fool can make things bigger, more complex, and more
>> violent. It takes a touch of genius -- and a lot of courage -- to move in
>> the opposite direction."*
>> Albert Einstein (March 14th 1879 – April 18th 1955)
>>
>>
>> 2013/1/22 Tomas Neme 
>>
>>>
>>>
>>> what mengu says is good for templates, but not so for views.
>>>
>>> But lo! your request should have a .user property that points to the
>>> currently logged user, so try
>>>
>>> request.user
>>>
>>> in your view
>>>
>>>
>>> On Tue, Jan 22, 2013 at 4:49 PM, Mengu  wrote:
>>>
 hi fellipe,

 if you enable auth context processors and pass in RequestContext to
 render_to_response you can always access the user in your templates
 which also means you can access the associated profile as user.profile
 (assuming your model is named profile)

 please read more at
 https://docs.djangoproject.com/en/dev/topics/auth/default/#authentication-data-in-templates



 On Jan 22, 8:34 pm, Fellipe Henrique  wrote:
 > Hello,
 >
 > It's possible, when the user make a login, I set one "global"
 variable, and
 > get this value in my view?
 >
 > My question is because I have a inlineformset_factory, and I need to
 pass a
 > user profile do my view.. but it`s doesn't work.
 >
 > Regards,
 >
 > T.·.F.·.A.·. S+F
 > *Fellipe Henrique P. Soares*
 >
 > *"Quemadmodum gladius neminem occidit, occidentis telum est."*
 (Epistulae
 > morales ad Lucilium<
 http://en.wikipedia.org/wiki/Epistulae_morales_ad_Lucilium>,
 > Lucius Annaeus Seneca)
 >
 > *"Any intelligent fool can make things bigger, more complex, and more
 > violent. It takes a touch of genius -- and a lot of courage -- to
 move in
 > the opposite direction."*
 > Albert Einstein (March 14th 1879 – April 18th 1955)

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


>>>
>>>
>>> --
>>> "The whole of Japan is pure invention. There is no such country, there
>>> are no such people" --Oscar Wilde
>>>
>>> |_|0|_|
>>> |_|_|0|
>>> |0|0|0|
>>>
>>> (\__/)
>>> (='.'=)This is Bunny. Copy and paste bunny
>>> (")_(") to help him gain world domination.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from 

Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Sarfraz ahmad
i dont found any query related to this model bro

On Wed, Jan 23, 2013 at 4:01 PM, Pankaj Singh  wrote:

> If you want to get all `A11M1_user_items` objects then following query
> should work
>
>
> --
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad 
> wrote:
> > i have the same model having one foreignkey to User and second to the
> > ContentType
> >
> > class A11M1_user_itmes(models.Model):
> > A11M1F1_user=models.ForeignKey(User)
> > content_type = models.ForeignKey(ContentType)
> > object_id = models.PositiveIntegerField()
> > content_object = generic.GenericForeignKey('content_type',
> 'object_id')
> > this is the code of ma model.. using this code i wanna get all
> objects
> > related to current logged in user
> >
> >
> > On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh  wrote:
> >>
> >> So, you have a custom model like following
> >>
> >> class MyModel(models.Model):
> >> ...
> >> content_type = models.ForeignKey(ContentType)
> >> ...
> >>
> >> And you want to run a query on MyModel which should return objects
> >> from various apps related to currently logged in User.
> >>
> >> Is this what you want to achieve?
> >>
> >> Pankaj Singh
> >> http://about.me/psjinx
> >>
> >>
> >> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad  >
> >> wrote:
> >> > thanx buddy bt i wish to do it in a manner that a model which has a
> >> > foreign
> >> > key to ContentType, when i make a query on this model it returns all
> the
> >> > objects from various apps related to current logged in user
> >> >
> >> >
> >> >
> >> >
> >> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh 
> wrote:
> >> >>
> >> >> Hey Sarfraz,
> >> >>
> >> >> If you have an user object, then you can get all related objects
> using
> >> >> following code
> >> >>
> >> >> user = User.objects.get(username="psjinx")
> >> >>
> >> >> related_links = [rel.get_accessor_name() for rel in
> >> >> user._meta.get_all_related_objects()]
> >> >>
> >> >> ## above code will give a list of attribute names for each related
> >> >> object to an user
> >> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
> >> >> 'recipient_set', 'customer']
> >> >>
> >> >> Now you can iterate over this list
> >> >>
> >> >> for link in related_links:
> >> >> objects = getattr(user, link).all()
> >> >> for object in objects:
> >> >> ## do something with object
> >> >>
> >> >> FYI, getattr(user, link) is manager for that relate object.
> >> >>
> >> >>
> >> >> Pankaj Singh
> >> >> http://about.me/psjinx
> >> >>
> >> >>
> >> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh 
> >> >> wrote:
> >> >> > Hey Sarfraz,
> >> >> >
> >> >> > You can use any of following methods:
> >> >> >
> >> >> > User._meta.get_all_related_m2m_objects_with_model()
> >> >> > User._meta.get_all_related_objects()
> >> >> > User._meta.get_all_related_many_to_many_objects()
> >> >> > User._meta.get_all_related_objects_with_model()
> >> >> >
> >> >> > get_all_related_objects() is the one I guess you may want to use in
> >> >> > your
> >> >> > case.
> >> >> >
> >> >> > Pankaj Singh
> >> >> > http://about.me/psjinx
> >> >> >
> >> >> >
> >> >> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad
> >> >> > 
> >> >> > wrote:
> >> >> >> hello friends
> >> >> >>   i have a project with 7 applications installed
> in
> >> >> >> it
> >> >> >> and i
> >> >> >> want to get all the objects related to a particular user from all
> >> >> >> the
> >> >> >> applications of ma project. please tell me how can i get
> all
> >> >> >> these
> >> >> >> objects using ContentType framework
> >> >> >>
> >> >> >>
> >> >> >> thank you all
> >> >> >>
> >> >> >> --
> >> >> >> You received this message because you are subscribed to the Google
> >> >> >> Groups
> >> >> >> "Django users" group.
> >> >> >> To view this discussion on the web visit
> >> >> >> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
> >> >> >> To post to this group, send email to
> django-users@googlegroups.com.
> >> >> >> To unsubscribe from this group, send email to
> >> >> >> django-users+unsubscr...@googlegroups.com.
> >> >> >> For more options, visit this group at
> >> >> >> http://groups.google.com/group/django-users?hl=en.
> >> >>
> >> >> --
> >> >> You received this message because you are subscribed to the Google
> >> >> Groups
> >> >> "Django users" group.
> >> >> To post to this group, send email to django-users@googlegroups.com.
> >> >> To unsubscribe from this group, send email to
> >> >> django-users+unsubscr...@googlegroups.com.
> >> >> For more options, visit this group at
> >> >> http://groups.google.com/group/django-users?hl=en.
> >> >>
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Django users" group.
> >> > To post to 

Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
Sorry for last reply. I sent uncompleted email by mistake, while
looking at other laptop.

If you want to get all `A11M1_user_itmes ` objects then following
query should work

objects = request.user. a11m1_user_itmes_set.all()

You can use `content_object` attribute on each object in objects list
to get original object.

I used similar approach for creating a new feed similar to facebook.
Please have a look at related stackoverflow question,
http://stackoverflow.com/questions/2128886/django-way-for-building-a-news-feed-status-update-activity-stream.

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 4:01 PM, Pankaj Singh  wrote:
> If you want to get all `A11M1_user_items` objects then following query
> should work
>
>
> --
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad  
> wrote:
>> i have the same model having one foreignkey to User and second to the
>> ContentType
>>
>> class A11M1_user_itmes(models.Model):
>> A11M1F1_user=models.ForeignKey(User)
>> content_type = models.ForeignKey(ContentType)
>> object_id = models.PositiveIntegerField()
>> content_object = generic.GenericForeignKey('content_type', 'object_id')
>> this is the code of ma model.. using this code i wanna get all objects
>> related to current logged in user
>>
>>
>> On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh  wrote:
>>>
>>> So, you have a custom model like following
>>>
>>> class MyModel(models.Model):
>>> ...
>>> content_type = models.ForeignKey(ContentType)
>>> ...
>>>
>>> And you want to run a query on MyModel which should return objects
>>> from various apps related to currently logged in User.
>>>
>>> Is this what you want to achieve?
>>>
>>> Pankaj Singh
>>> http://about.me/psjinx
>>>
>>>
>>> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad 
>>> wrote:
>>> > thanx buddy bt i wish to do it in a manner that a model which has a
>>> > foreign
>>> > key to ContentType, when i make a query on this model it returns all the
>>> > objects from various apps related to current logged in user
>>> >
>>> >
>>> >
>>> >
>>> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh  wrote:
>>> >>
>>> >> Hey Sarfraz,
>>> >>
>>> >> If you have an user object, then you can get all related objects using
>>> >> following code
>>> >>
>>> >> user = User.objects.get(username="psjinx")
>>> >>
>>> >> related_links = [rel.get_accessor_name() for rel in
>>> >> user._meta.get_all_related_objects()]
>>> >>
>>> >> ## above code will give a list of attribute names for each related
>>> >> object to an user
>>> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>>> >> 'recipient_set', 'customer']
>>> >>
>>> >> Now you can iterate over this list
>>> >>
>>> >> for link in related_links:
>>> >> objects = getattr(user, link).all()
>>> >> for object in objects:
>>> >> ## do something with object
>>> >>
>>> >> FYI, getattr(user, link) is manager for that relate object.
>>> >>
>>> >>
>>> >> Pankaj Singh
>>> >> http://about.me/psjinx
>>> >>
>>> >>
>>> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh 
>>> >> wrote:
>>> >> > Hey Sarfraz,
>>> >> >
>>> >> > You can use any of following methods:
>>> >> >
>>> >> > User._meta.get_all_related_m2m_objects_with_model()
>>> >> > User._meta.get_all_related_objects()
>>> >> > User._meta.get_all_related_many_to_many_objects()
>>> >> > User._meta.get_all_related_objects_with_model()
>>> >> >
>>> >> > get_all_related_objects() is the one I guess you may want to use in
>>> >> > your
>>> >> > case.
>>> >> >
>>> >> > Pankaj Singh
>>> >> > http://about.me/psjinx
>>> >> >
>>> >> >
>>> >> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad
>>> >> > 
>>> >> > wrote:
>>> >> >> hello friends
>>> >> >>   i have a project with 7 applications installed in
>>> >> >> it
>>> >> >> and i
>>> >> >> want to get all the objects related to a particular user from all
>>> >> >> the
>>> >> >> applications of ma project. please tell me how can i get all
>>> >> >> these
>>> >> >> objects using ContentType framework
>>> >> >>
>>> >> >>
>>> >> >> thank you all
>>> >> >>
>>> >> >> --
>>> >> >> You received this message because you are subscribed to the Google
>>> >> >> Groups
>>> >> >> "Django users" group.
>>> >> >> To view this discussion on the web visit
>>> >> >> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
>>> >> >> To post to this group, send email to django-users@googlegroups.com.
>>> >> >> To unsubscribe from this group, send email to
>>> >> >> django-users+unsubscr...@googlegroups.com.
>>> >> >> For more options, visit this group at
>>> >> >> http://groups.google.com/group/django-users?hl=en.
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> >> Groups
>>> >> "Django users" group.
>>> >> To post to this group, send email to 

Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
If you want to get all `A11M1_user_items` objects then following query
should work


--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad  wrote:
> i have the same model having one foreignkey to User and second to the
> ContentType
>
> class A11M1_user_itmes(models.Model):
> A11M1F1_user=models.ForeignKey(User)
> content_type = models.ForeignKey(ContentType)
> object_id = models.PositiveIntegerField()
> content_object = generic.GenericForeignKey('content_type', 'object_id')
> this is the code of ma model.. using this code i wanna get all objects
> related to current logged in user
>
>
> On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh  wrote:
>>
>> So, you have a custom model like following
>>
>> class MyModel(models.Model):
>> ...
>> content_type = models.ForeignKey(ContentType)
>> ...
>>
>> And you want to run a query on MyModel which should return objects
>> from various apps related to currently logged in User.
>>
>> Is this what you want to achieve?
>>
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad 
>> wrote:
>> > thanx buddy bt i wish to do it in a manner that a model which has a
>> > foreign
>> > key to ContentType, when i make a query on this model it returns all the
>> > objects from various apps related to current logged in user
>> >
>> >
>> >
>> >
>> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh  wrote:
>> >>
>> >> Hey Sarfraz,
>> >>
>> >> If you have an user object, then you can get all related objects using
>> >> following code
>> >>
>> >> user = User.objects.get(username="psjinx")
>> >>
>> >> related_links = [rel.get_accessor_name() for rel in
>> >> user._meta.get_all_related_objects()]
>> >>
>> >> ## above code will give a list of attribute names for each related
>> >> object to an user
>> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>> >> 'recipient_set', 'customer']
>> >>
>> >> Now you can iterate over this list
>> >>
>> >> for link in related_links:
>> >> objects = getattr(user, link).all()
>> >> for object in objects:
>> >> ## do something with object
>> >>
>> >> FYI, getattr(user, link) is manager for that relate object.
>> >>
>> >>
>> >> Pankaj Singh
>> >> http://about.me/psjinx
>> >>
>> >>
>> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh 
>> >> wrote:
>> >> > Hey Sarfraz,
>> >> >
>> >> > You can use any of following methods:
>> >> >
>> >> > User._meta.get_all_related_m2m_objects_with_model()
>> >> > User._meta.get_all_related_objects()
>> >> > User._meta.get_all_related_many_to_many_objects()
>> >> > User._meta.get_all_related_objects_with_model()
>> >> >
>> >> > get_all_related_objects() is the one I guess you may want to use in
>> >> > your
>> >> > case.
>> >> >
>> >> > Pankaj Singh
>> >> > http://about.me/psjinx
>> >> >
>> >> >
>> >> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad
>> >> > 
>> >> > wrote:
>> >> >> hello friends
>> >> >>   i have a project with 7 applications installed in
>> >> >> it
>> >> >> and i
>> >> >> want to get all the objects related to a particular user from all
>> >> >> the
>> >> >> applications of ma project. please tell me how can i get all
>> >> >> these
>> >> >> objects using ContentType framework
>> >> >>
>> >> >>
>> >> >> thank you all
>> >> >>
>> >> >> --
>> >> >> You received this message because you are subscribed to the Google
>> >> >> Groups
>> >> >> "Django users" group.
>> >> >> To view this discussion on the web visit
>> >> >> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
>> >> >> To post to this group, send email to django-users@googlegroups.com.
>> >> >> To unsubscribe from this group, send email to
>> >> >> django-users+unsubscr...@googlegroups.com.
>> >> >> For more options, visit this group at
>> >> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.

Re: Where can I put code that will get executed when page refreshes

2013-01-23 Thread Pankaj Singh
Hey,

You must be using a context variable to fill your `side_menu` block.

One reason for failure can be that, context variable is available in
template when `ntw.views.index` is called but not available when
'staff.views.index' is called.

--
Pankaj Singh
http://about.me/psjinx


On Tue, Jan 22, 2013 at 10:04 PM, frocco  wrote:
> I have a  index.html template that extends base.html
> In Index I has:
> {% block side_menu %}
> Content
> {% endblock %}
>
> I fill this block from a database table.
> This only works if I click on the home link.
> if I click any other link to view, the side-menu is not populated.
>
> url(r'^$', 'ntw.views.index', name='home'), works
> url(r'^staff/', 'staff.views.index'), does not work
>
> ntw.views.py has the code to query the database
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/tRmjXkGaeoEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Sarfraz ahmad
i have the same model having one foreignkey to User and second to the
ContentType

class A11M1_user_itmes(models.Model):
A11M1F1_user=models.ForeignKey(User)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
this is the code of ma model.. using this code i wanna get all objects
related to current logged in user

On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh  wrote:

> So, you have a custom model like following
>
> class MyModel(models.Model):
> ...
> content_type = models.ForeignKey(ContentType)
> ...
>
> And you want to run a query on MyModel which should return objects
> from various apps related to currently logged in User.
>
> Is this what you want to achieve?
>
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad 
> wrote:
> > thanx buddy bt i wish to do it in a manner that a model which has a
> foreign
> > key to ContentType, when i make a query on this model it returns all the
> > objects from various apps related to current logged in user
> >
> >
> >
> >
> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh  wrote:
> >>
> >> Hey Sarfraz,
> >>
> >> If you have an user object, then you can get all related objects using
> >> following code
> >>
> >> user = User.objects.get(username="psjinx")
> >>
> >> related_links = [rel.get_accessor_name() for rel in
> >> user._meta.get_all_related_objects()]
> >>
> >> ## above code will give a list of attribute names for each related
> >> object to an user
> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
> >> 'recipient_set', 'customer']
> >>
> >> Now you can iterate over this list
> >>
> >> for link in related_links:
> >> objects = getattr(user, link).all()
> >> for object in objects:
> >> ## do something with object
> >>
> >> FYI, getattr(user, link) is manager for that relate object.
> >>
> >>
> >> Pankaj Singh
> >> http://about.me/psjinx
> >>
> >>
> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh 
> wrote:
> >> > Hey Sarfraz,
> >> >
> >> > You can use any of following methods:
> >> >
> >> > User._meta.get_all_related_m2m_objects_with_model()
> >> > User._meta.get_all_related_objects()
> >> > User._meta.get_all_related_many_to_many_objects()
> >> > User._meta.get_all_related_objects_with_model()
> >> >
> >> > get_all_related_objects() is the one I guess you may want to use in
> your
> >> > case.
> >> >
> >> > Pankaj Singh
> >> > http://about.me/psjinx
> >> >
> >> >
> >> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad <
> sarfrazdja...@gmail.com>
> >> > wrote:
> >> >> hello friends
> >> >>   i have a project with 7 applications installed in
> it
> >> >> and i
> >> >> want to get all the objects related to a particular user from all the
> >> >> applications of ma project. please tell me how can i get all
> >> >> these
> >> >> objects using ContentType framework
> >> >>
> >> >>
> >> >> thank you all
> >> >>
> >> >> --
> >> >> You received this message because you are subscribed to the Google
> >> >> Groups
> >> >> "Django users" group.
> >> >> To view this discussion on the web visit
> >> >> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
> >> >> To post to this group, send email to django-users@googlegroups.com.
> >> >> To unsubscribe from this group, send email to
> >> >> django-users+unsubscr...@googlegroups.com.
> >> >> For more options, visit this group at
> >> >> http://groups.google.com/group/django-users?hl=en.
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/django-users?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send 

Re: Upload multiple files using Ajax

2013-01-23 Thread Pankaj Singh
You can use https://github.com/blueimp/jQuery-File-Upload.

You can use a view function similar to following. Here I have 3 models
- Project, Album and Flat

A Project can have multiple albums.
An Album can have multiple Flats
A Flat has an ImageField, caption as TextField and a ForeignKey to Album.

def upload_flat(request, project_slug, album_pk):
project = get_object_or_404(Project, slug=project_slug)
album = get_object_or_404(Album, pk=album_pk)
if request.method == 'GET':
flats = album.flat_set.all()
return render(request, "upload.html", {"project": project,
"album": album, "flats": flats})

if request.method == "POST":
form = FlatForm(request.POST, request.FILES)
if form.is_valid():
flat = form.save(commit=False)
flat.user = request.user
flat.album = album
flat.save()

data = {
"files":
[{
"url": flat.image.url,
"thumbnail_url": flat.thumbnail.url,
"name": flat.image.name,
"type": "image/jpeg",
"size": flat.image.size,
"delete_url": reverse("delete_flat", args=[flat.pk]),
"delete_type": "DELETE",
"description": flat.description
}]
}
return HttpResponse(simplejson.dumps(data))
return render(request, "upload.html", {})

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 1:22 AM, Mengu  wrote:
> i used jquery.form plugin back in the day. it worked great but it had
> issues with large files.
>
> check out http://malsup.com/jquery/form/progress3.html and
> http://malsup.com/jquery/form/
>
> On Jan 22, 6:05 pm, Andre Lopes  wrote:
>> Hi,
>>
>> I need to develop a form to upload multiple files.
>>
>> I was thinking in using an Ajax uploader. I have google some options
>> but there are to many and I don't know which one to choose.
>>
>> Any recommendations about this subject?
>>
>> Best Regards,
>> André.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
So, you have a custom model like following

class MyModel(models.Model):
...
content_type = models.ForeignKey(ContentType)
...

And you want to run a query on MyModel which should return objects
from various apps related to currently logged in User.

Is this what you want to achieve?

Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad  wrote:
> thanx buddy bt i wish to do it in a manner that a model which has a foreign
> key to ContentType, when i make a query on this model it returns all the
> objects from various apps related to current logged in user
>
>
>
>
> On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh  wrote:
>>
>> Hey Sarfraz,
>>
>> If you have an user object, then you can get all related objects using
>> following code
>>
>> user = User.objects.get(username="psjinx")
>>
>> related_links = [rel.get_accessor_name() for rel in
>> user._meta.get_all_related_objects()]
>>
>> ## above code will give a list of attribute names for each related
>> object to an user
>> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>> 'recipient_set', 'customer']
>>
>> Now you can iterate over this list
>>
>> for link in related_links:
>> objects = getattr(user, link).all()
>> for object in objects:
>> ## do something with object
>>
>> FYI, getattr(user, link) is manager for that relate object.
>>
>>
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh  wrote:
>> > Hey Sarfraz,
>> >
>> > You can use any of following methods:
>> >
>> > User._meta.get_all_related_m2m_objects_with_model()
>> > User._meta.get_all_related_objects()
>> > User._meta.get_all_related_many_to_many_objects()
>> > User._meta.get_all_related_objects_with_model()
>> >
>> > get_all_related_objects() is the one I guess you may want to use in your
>> > case.
>> >
>> > Pankaj Singh
>> > http://about.me/psjinx
>> >
>> >
>> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad 
>> > wrote:
>> >> hello friends
>> >>   i have a project with 7 applications installed in it
>> >> and i
>> >> want to get all the objects related to a particular user from all the
>> >> applications of ma project. please tell me how can i get all
>> >> these
>> >> objects using ContentType framework
>> >>
>> >>
>> >> thank you all
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To view this discussion on the web visit
>> >> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Sarfraz ahmad
thanx buddy bt i wish to do it in a manner that a model which has a foreign
key to ContentType, when i make a query on this model it returns all the
objects from various apps related to current logged in user



On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh  wrote:

> Hey Sarfraz,
>
> If you have an user object, then you can get all related objects using
> following code
>
> user = User.objects.get(username="psjinx")
>
> related_links = [rel.get_accessor_name() for rel in
> user._meta.get_all_related_objects()]
>
> ## above code will give a list of attribute names for each related
> object to an user
> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
> 'recipient_set', 'customer']
>
> Now you can iterate over this list
>
> for link in related_links:
> objects = getattr(user, link).all()
> for object in objects:
> ## do something with object
>
> FYI, getattr(user, link) is manager for that relate object.
>
>
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh  wrote:
> > Hey Sarfraz,
> >
> > You can use any of following methods:
> >
> > User._meta.get_all_related_m2m_objects_with_model()
> > User._meta.get_all_related_objects()
> > User._meta.get_all_related_many_to_many_objects()
> > User._meta.get_all_related_objects_with_model()
> >
> > get_all_related_objects() is the one I guess you may want to use in your
> case.
> >
> > Pankaj Singh
> > http://about.me/psjinx
> >
> >
> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad 
> wrote:
> >> hello friends
> >>   i have a project with 7 applications installed in it
> and i
> >> want to get all the objects related to a particular user from all the
> >> applications of ma project. please tell me how can i get all
> these
> >> objects using ContentType framework
> >>
> >>
> >> thank you all
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To view this discussion on the web visit
> >> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
Hey Sarfraz,

If you have an user object, then you can get all related objects using
following code

user = User.objects.get(username="psjinx")

related_links = [rel.get_accessor_name() for rel in
user._meta.get_all_related_objects()]

## above code will give a list of attribute names for each related
object to an user
## e.g. ['logentry_set', 'api_key', 'userprofile_set',
'recipient_set', 'customer']

Now you can iterate over this list

for link in related_links:
objects = getattr(user, link).all()
for object in objects:
## do something with object

FYI, getattr(user, link) is manager for that relate object.


Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh  wrote:
> Hey Sarfraz,
>
> You can use any of following methods:
>
> User._meta.get_all_related_m2m_objects_with_model()
> User._meta.get_all_related_objects()
> User._meta.get_all_related_many_to_many_objects()
> User._meta.get_all_related_objects_with_model()
>
> get_all_related_objects() is the one I guess you may want to use in your case.
>
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad  
> wrote:
>> hello friends
>>   i have a project with 7 applications installed in it and i
>> want to get all the objects related to a particular user from all the
>> applications of ma project. please tell me how can i get all these
>> objects using ContentType framework
>>
>>
>> thank you all
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.

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



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
Hey Sarfraz,

You can use any of following methods:

User._meta.get_all_related_m2m_objects_with_model()
User._meta.get_all_related_objects()
User._meta.get_all_related_many_to_many_objects()
User._meta.get_all_related_objects_with_model()

get_all_related_objects() is the one I guess you may want to use in your case.

Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad  wrote:
> hello friends
>   i have a project with 7 applications installed in it and i
> want to get all the objects related to a particular user from all the
> applications of ma project. please tell me how can i get all these
> objects using ContentType framework
>
>
> thank you all
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Sarfraz ahmad
hello friends
  i have a project with 7 applications installed in it and 
i want to get all the objects related to a particular user from all the 
applications of ma project. please tell me how can i get all these 
objects using ContentType framework


thank you all

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