Accessing related fields.

2011-09-11 Thread Petey
The more time I spend with django, the more problems pop up :) I dont fully understand how to access related fields between models. (FK or ManyToMany) Code: http://pastebin.com/qbciYqYw In code pasted below - {{p.souce.all}} returns source name but in that form: [], instead of "Google". Also I

Re: Accessing related fields.

2011-09-11 Thread Daniel Roseman
On Sunday, 11 September 2011 08:23:16 UTC+1, Petey wrote: > > The more time I spend with django, the more problems pop up :) > > I dont fully understand how to access related fields between models. (FK or > ManyToMany) > Code: > http://pastebin.com/qbciYqYw > > In code pasted below - {{p.souce.all

Re: Implementing a List of Foreign Keys in a Model

2011-09-11 Thread Daniel Roseman
On Sunday, 11 September 2011 00:18:28 UTC+1, Kurtis wrote: > > Hey Guys, > > I have a very simple stub of a project. I'm trying to do something > that should be very simple but isn't as easy as I hoped. > > I have a UserProfile class. This object is basically just an extension > of the standar

Re: Accessing related fields.

2011-09-11 Thread Petey
That worked but how do I acces other field called "url" which is in Category model? -- 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/-/1VxdFnovRNEJ. To post t

Re: Accessing related fields.

2011-09-11 Thread Daniel Roseman
Why would it be any different? You have the same relationship between Publisher and Category as you do between Publisher and Source, so just do the same thing again. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussio

Re: Accessing related fields.

2011-09-11 Thread Petey
And also how do I display more objets from that list? ;) Sorry for double post -- 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/-/FAgvFRzJpdIJ. To post to thi

Re: Accessing related fields.

2011-09-11 Thread Martin Tiršel
Hi, as Daniel wrote, the {{ p.source.all }} is a queryset you can access the same way as in {% for p in publisher.object_list %}. So you create a nested for loop. Martin On Sun, 11 Sep 2011 10:38:39 +0200, Petey wrote: And also how do I display more objets from that list? ;) Sorry for d

Re: Accessing related fields.

2011-09-11 Thread Petey
Ooops I meant source ;) Firstly: {{ p.source.all.0 }} - < gets source name, only first element (as proper slice should work) but I still dont understand how to get all avaliable elements for each source in publisher Secondly: {{ p.source.url.all.0 }} < does not get URL from Source.url, I reall

Re: Accessing related fields.

2011-09-11 Thread Martin Tiršel
{{ p.source.all }} - is a list of source objects {{ p.source.all.0 }} - is the first item in the list of source objects (the same as p.source.all[0] in python) {{ p.source.all.0.some_attribute }} - you access some_attribute of the object source which is the first item in the list od source

Re: Accessing related fields.

2011-09-11 Thread Petey
Thank you Bruce and Daniel both anwsers really helped me. I really appreciate it :). -- 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/-/LkInATAnM28J. To post

Re: django-registration + csrf token

2011-09-11 Thread DrBloodmoney
On Fri, Sep 9, 2011 at 12:02 PM, Brett Hutley wrote: > You need to add it to the registration_form.html as well. > > Make sure you have  'django.middleware.csrf.CsrfViewMiddleware', in the > MIDDLEWARE_CLASSES tuple in the settings.py file. > > Cheers, Brett > > On 9 Sep 2011, at 16:47, nicolas H

order by + group by

2011-09-11 Thread Jonas H.
Hi! How can I express this SQL query SELECT ... FROM ( SELECT ... FROM ... ) in the ORM? Specifically, I want to express SELECT ... FROM ( SELECT ... FROM app_model ORDER BY field1 ) GROUP BY field2 Is it possible without writing SQL by hand? Thanks, Jonas -- Django +

Re: Multitenant in Django

2011-09-11 Thread yanliang tang
在什么地方举行呢? -- 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

Re: Login based in url for user

2011-09-11 Thread Praveen Krishna R
*You can filter the objects based on user. Which means you can include a ForeignKey to User model in your models, and save the logged in user while saving the model. In the views, while displaying, you can filter based on the logged-in user. So no other user get to see your objects * On Tue, Aug 30

Getting a class using a variable name.

2011-09-11 Thread pbzRPA
Hi, I have been struggling with this for a while now and I can't seem to find a way of returning a class object from a different module without importing it. Say I have two files: test_a.py class A(models.Model): pass test_b.py class B(models.Model): def get_a_class(se

Re: Multitenant in Django

2011-09-11 Thread Alessandro Pasotti
2011/9/9 sjtirtha > But I cannot set the SITE_ID in the settings.py right? > Because if one user set the SITE_ID = 1, then parallel another user > can set the SITE_ID = 2. > Because we only have one instance. > Right, but AFAIK if you don't use threads you shouldn't have any problem. We have b

Re: Getting a class using a variable name.

2011-09-11 Thread pbzRPA
I should add that in the B class function get_a_class I only have a variable name "A" -- 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

Re: Getting a class using a variable name.

2011-09-11 Thread Martin Tiršel
Hi, you can do the import here to prevent circular import: class B(models.Model): def get_a_class(self): from test_a import A return A Martin On Sun, 11 Sep 2011 16:49:22 +0200, pbzRPA wrote: Hi, I have been struggling with this for a while now and I can't seem to find

Re: Getting a class using a variable name.

2011-09-11 Thread pbzRPA
Hi Martin, Thanks for the tip. The thing is that I store my class names in the database. So class B(models.Mode): form_class = models.CharField(...) def get_form_class(self): return ..(self.form_class) <- this is where I need to some how get the class object from a different

Re: Getting a class using a variable name.

2011-09-11 Thread pbzRPA
Ok, I found a way. I don't know if it's the best way but it works :) return getattr(__import__(module_name, fromlist = [class_name]), class_name) Thanks for the help. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

two views in one url

2011-09-11 Thread cha
Hello all I have two views in two app and I want to get them in main url file how I Can do that ? first view in project/app_news/views.py def article_index(request): return render_to_response('news/index.html', { 'news_slide': Article.objects.filter(status=1, statusslide=1)[:

Re: two views in one url

2011-09-11 Thread Babatunde Akinyanmi
Hi cha, Programming in django is just programming in python. Views are just normal python functions that are called from urls.py which contains pattern which is also a function. If you want both views in one file, do exactly that. You could cut and paste the view in the second app and paste it in t

Re: two views in one url

2011-09-11 Thread Petey
You may merge the code in views.py and use 1 url for them. You could use TemplateView() instead of render to response -- 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/djan

When is it useful to run multiple admin sites?

2011-09-11 Thread Joshua Russo
I know you can run multiple admin sites, but the only reason I can see for doing it is to have a full admin and other customized admin sites for different types of users. This is possibly even a stretch, and really just a guess. What are some of the use cases for multiple admin sites? -- Yo

Re: When is it useful to run multiple admin sites?

2011-09-11 Thread Nan
I've done this for a multitenant project where we wanted each tenant to have their own admin site with just their own data filtered, as well as a central admin where senior staff could manage all tenants' data. It's also handy if you want different interfaces (custom forms, read-only or excluded

Re: two views in one url

2011-09-11 Thread cha
thank you very much Babatunde Akinyanmi & petey Im merge the code and its work Mr Babatunde Akinyanmi acutely I need be comfortable with programming with python But I dont Know How to do that can you help me and give me the best way to be comfortable and professional programmer -- You received t

Re: Problem at activating the admin site (Django tutorial part 2)

2011-09-11 Thread pasztilla
Hi Babatunde, 1. sorry for the delayed answer - but I was in the last three weeks far from any possibility to use the Internet (and Django as well)... 2. I have tried to reproduce the phenomenon and with the 'Pászkán Attila' as user it worked ! Why? - still it isn't clear. PA On Aug 26, 12:20 

Re: When is it useful to run multiple admin sites?

2011-09-11 Thread galgal
Where can I find any info about hot to run it? -- 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/-/s5twxCSBgDMJ. To post to this group, send email to django-use

Re: When is it useful to run multiple admin sites?

2011-09-11 Thread Joshua Russo
That makes sense. 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/-/Hz0DW_-dSwAJ. To post to this group, send email to django-users@googlegroups.com. T

Re: newbie question on activating the automatic admin

2011-09-11 Thread nara
ok, i am planning to remove all traces of all django installations from my system, and re-install the dev version (and if that still does not work 3.1) under virtualenv. Will repost here if I still see problems. Nara On Sep 10, 7:16 pm, Babatunde Akinyanmi wrote: > Hi nara, > Please post the de

Re: Admin Site appending letter "s" to end of each model\table name

2011-09-11 Thread Javier Guerra Giraldez
On Sat, Sep 10, 2011 at 11:06 PM, Shawn Milochik wrote: > The way you were doing it makes perfect sense if you have experience > creating database tables by hand, the way most people do for their PHP and > ASP apps. Django's ORM is doing all the same stuff underneath, but it > provides a level of

Re: Problem at activating the admin site (Django tutorial part 2)

2011-09-11 Thread Babatunde Akinyanmi
It isn't clear to me also. Initially I was surprised because the site app doesn't have any dependency on django's user system. Even if it does, django uses unicode which caters for those characters in your name. Well.at least we are sure the problem wsnt from the user name. But something define

Re: two views in one url

2011-09-11 Thread Babatunde Akinyanmi
This is way off topic for this group but.. To be comfortable with python, the online python documentation is a very good resource. It seems like you're a programming noob so also get books like pragmatic programmer and Python The Hard Way. Of course there are many more good books on python pr

Re: newbie question on activating the automatic admin

2011-09-11 Thread Babatunde Akinyanmi
And reply here if you don't see problems :) On 9/12/11, nara wrote: > ok, i am planning to remove all traces of all django installations > from my > system, and re-install the dev version (and if that still does not > work 3.1) > under virtualenv. > > Will repost here if I still see probl

Re: sitemap

2011-09-11 Thread veva...@yandex.ru
Thank You very 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/-/MUltEa4dGogJ. To post to this group, send email to django-users@googlegroups.com. To un

Re: django-registration + csrf token

2011-09-11 Thread nicolas HERSOG
omg, I'm so ashamed... I use {% csrf_token %} and it works, Thx :) Nicolas On Sun, Sep 11, 2011 at 2:52 PM, DrBloodmoney wrote: > On Fri, Sep 9, 2011 at 12:02 PM, Brett Hutley wrote: > > You need to add it to the registration_form.html as well. > > > > Make sure you have 'django.middleware.csr