Re: View decorator for common navigation elements?

2011-09-29 Thread Alex Chan
Hi Victor, I think this is a very good question. I've been considering what the best approach would be and decided on either using a decorator as you've mentioned or implementing class based views. You can create base view classes that load common data for the different types of pages. You

View decorator for common navigation elements?

2011-09-29 Thread Victor Hooi
Hi, We have a common navigation bar on nearly every page (view) that contains a dropdown - this dropdown is populated with items from a database table. This dropdown also has AJAX behaviour attached to it. I'm thinking I can create a decorator that will retrieve the list from the database,

How to do something just like in user right assignment ?

2011-09-29 Thread bino oetomo
Dear All .. Let's say I have 2 model in manyTOmany relation, i.e : Persons and colours I want a 2 CRUD interface for this , that is : 1. Persons : where I can add colours to each person, and 2. Colours : where I can add Persons to each colour I also want the "ADD" methode (Add colours to

set_test_cookie() on every page?

2011-09-29 Thread Victor Hooi
Hi, I've read the Django docs on setting test cookies (https://docs.djangoproject.com/en/dev/topics/http/sessions/#setting-test-cookies), and I'm still a bit confused. One of our views sets a session variable to remember the object a user is currently viewing (we figured it wasn't worth

Re: CSRF with AJAX problem

2011-09-29 Thread galgal
Yes I have. It returns null if no cookie. -- 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/-/Y4TMZ5p-XYgJ. To post to this group, send email to

Re: CSRF with AJAX problem

2011-09-29 Thread Javier Guerra Giraldez
On Thu, Sep 29, 2011 at 7:15 PM, galgal wrote: > Yes, but that JavaScript code is useless until {% csrf_token %} or get_token > is used. I don't use POST forms - only AJAX forms so I don't have that > cookie made after page load. have you read it? -- Javier -- You

Re: CSRF with AJAX problem

2011-09-29 Thread galgal
Yes, but that JavaScript code is useless until {% csrf_token %} or get_token is used. I don't use POST forms - only AJAX forms so I don't have that cookie made after page load. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

Re: CSRF with AJAX problem

2011-09-29 Thread Javier Guerra Giraldez
On Thu, Sep 29, 2011 at 6:23 PM, galgal wrote: > How can I make that cookie without using csrf tag? right there in the code sample you quoted: xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); where getCookie() is defined as: function getCookie(name)

Re: accessing domain of a cookie

2011-09-29 Thread Edison
you can set cookie domain in the django settings.py file SESSION_COOKIE_DOMAIN https://docs.djangoproject.com/en/1.3/ref/settings/ On Fri, Sep 30, 2011 at 6:31 AM, aiexbecumont wrote: > Is there a way to tell what domain a cookie was set for? > request.COOKIES only

Get latest item by many items in a queryset

2011-09-29 Thread Colin
Hi Users, So I have a DB that has a list of backends and there properties and I have a table that gets updated with if it is able to access and the status. It is only updated when it is reported down or, if it was reported down and is currenly back up. What i want to do is make a queryset that

Re: Catching the autogenerated admin post

2011-09-29 Thread Jay Martin
Awesome, I think that's it. Much thanks. jay On Sep 29, 2011, at 6:31 PM, Andres Reyes wrote: > You could try doing your processing in the save_model method of ModelAdmin > > https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model > > 2011/9/29

Re: Catching the autogenerated admin post

2011-09-29 Thread Andres Reyes
You could try doing your processing in the save_model method of ModelAdmin https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model 2011/9/29 bazaarsoft > Hello - I'm new to Django and love what I see so far. I have the need > to

CSRF with AJAX problem

2011-09-29 Thread galgal
I have a problem/bug found? in AJAX with CSRF. I don't use {% csrf_token %} at all. I use only AJAX forms so - there is no cookie set for csrf. In taht case - https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#ajax is useless :( I can use get_token to generate it, but I have to put it in

Catching the autogenerated admin post

2011-09-29 Thread bazaarsoft
Hello - I'm new to Django and love what I see so far. I have the need to "catch" the admin post for one of my models: essentially, the model contains a file and from the file I want to extract data for some of the other model fields that are required for that particular model. So, can I "break"

will work for food ))

2011-09-29 Thread Andriyko
hello, I would like to get real experience in development of django based sites, but don't know how to bring together UI and backend. -- how to divide tasks/functionality between html, css, jquery, django etc; -- how to design architecture; -- how to choose when to use already existent

accessing domain of a cookie

2011-09-29 Thread aiexbecumont
Is there a way to tell what domain a cookie was set for? request.COOKIES only gives name/value pairs, but i would like to inspect the domain that the cookie was set for. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Two django apps (models) using same table

2011-09-29 Thread IgorS
Thank you Andre for your quick answer :-) I think the second option is a good choice. >From your expertise, does it make sense to follow this approach? 1. Add models.py to the first app added to the project 2. Use [db_table = 'users'] -- without model prefix 3. When new apps are added, refer to

Re: Sampling of the two models by matching fields.

2011-09-29 Thread Михаил
:dance: On 29 сен, 13:56, Satan Study Django wrote: > Anybody? > > On 27 сен, 18:53, Satan Study Django > > > > > > > > wrote: > > Good day. > > To the case. > > There are some models (simplified

sitemap.xml and 'unknown timezone'

2011-09-29 Thread shacker
Django sitemaps worked fine on a previous server, and work fine in my development environment, but break in production on a new server, with: ValidationError: [u'Unknown timezone'] (traceback below) The docs don't mention anything about timezone configuration or dependencies:

Re: Using IGNORABLE_404_URLS

2011-09-29 Thread shacker
Thanks guys. Yes, after thinking about this more, there are really two things going on here: 1) Figuring out why entries in Django's IGNORABLE_404_URLS seem to be completely ignored. 2) Blocking bad behavior. Since most of these requests are bogus, #2 is really what I want. Set up a bunch of

Anyone sync'd a django project with flickr recently? django-syncr

2011-09-29 Thread i...@webbricks.co.uk
I've searched. pretty much everyone recoomends http://code.google.com/p/django-syncr/ thing is, it doesn't actually do anything. am i right in thinking that this code when run, should sync to the django database information (sets and photos) from the flickr user you give it? I've given it two

Re: form.is_valid() NOT triggering model validation?

2011-09-29 Thread momo2k
Well, with the new knowledge about the debugger I found the place where BaseModelForm calls all three form-validation methods in forms/ models.py:306:_post_form Sorry. On Sep 29, 9:26 pm, momo2k wrote: > That explains my thoughts that the debugger is "disturbing" the >

Re: form.is_valid() NOT triggering model validation?

2011-09-29 Thread momo2k
That explains my thoughts that the debugger is "disturbing" the correct execution of the code, but this discussion does *not* (!) answer my question where the *model* of a *ModelForm* gets full_clean- ed - and why it doesn't do so in my case. On Sep 29, 8:48 pm, Shawn Milochik

ImportError: No module named staticfiles

2011-09-29 Thread EricSI
I'm running Django 1.3.1. On my staging server I am getting this error message through the email error log only. The error does not appear to manifest itself in how the site is rendered, all of my static files are actually showing up correctly. I find this error odd for a couple of reasons.

Re: form.is_valid() NOT triggering model validation?

2011-09-29 Thread Shawn Milochik
This exact thing was just discussed on this list. https://groups.google.com/d/topic/django-users/R2HUGqZ1BAQ/discussion -- 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

form.is_valid() NOT triggering model validation?

2011-09-29 Thread momo2k
Hello, after hours of examinating and debugging the Django source code I decided to post my problem here. I'm using Django 1.3.1 and its docs say: The is_valid() method and errors Changed in Django 1.2: Please, see the release notes The first time you call is_valid() or access the errors

Re: Two django apps (models) using same table

2011-09-29 Thread Andre Terra
Perhaps https://docs.djangoproject.com/en/dev/ref/models/options/#db-table ? But you really shouldn't describe the same table twice, if it's exactly the same thing. Move the models.py to a standalone "app" and have your two apps refer to that instead. Cheers, AT On Thu, Sep 29, 2011 at 2:28

Two django apps (models) using same table

2011-09-29 Thread IgorS
I am new to Django. It might be a very easy question but i could not google it... If i have two django apps in the same project and both apps need to use the same table in the same database, how should i describe this table in two different models.py files. Thank you, -igor -- You received

RE: ManyToMany problem

2011-09-29 Thread James DeMichele
I got it! It turns out I was right in my suspicion. It doesn’t look like you can use the string notation to reference a model in a different module. Is that expected? Is there any way to do that? Basically, I simply moved the RestaurantHoodMap into the hood.py file, changed the string name to

Re: ManyToMany problem

2011-09-29 Thread James DeMichele
Thanks, Tom. So, I've changed my code slightly.but I'm still getting an error. I'm pretty much following exactly what is in the Django docs as well. I'm wondering if it's because I have my models in different modules. That shouldn't matter though should it? Maybe I'm doing something wrong with

Wanted: JQuery Developer w/ some Django knowledge to build a large site module

2011-09-29 Thread Kurtis
Hey JQuery/Django Developers, We are looking to hire someone to complete a project for us. Read on for details. Background --- I am the lead developer for fireflie.com. We're currently in the beginning of a total site-rebuild using Python/Django. The current site was built by

Re: (off-topic) Quick method of sending files from ssh to clients

2011-09-29 Thread Cal Leeming [Simplicity Media Ltd]
This thread is already off topic - so thought I should +1 on pexpect. Anyone who hasn't tried it already - should defo take a look. Used it in quite a few data scrapping Django projects (mostly for talking with devices on RS232 over TCP) - it's very nice. Cal 2011/9/29 Charles Cossé

Re: (off-topic) Quick method of sending files from ssh to clients

2011-09-29 Thread Charles Cossé
Hello, (this is my first post here), just thought it might be helpful to mention python's pexpect module. It's used like this: rcmd="ssh root@%s /etc/init.d/firewall restart"%(IP_SOMEWHERE) foo = pexpect.spawn(rcmd) -Charles Cosse 2011/9/29 Bjarni Rúnar Einarsson >

Re: ManyToMany problem

2011-09-29 Thread Tom Evans
On Thu, Sep 29, 2011 at 5:20 PM, James DeMichele wrote: > Thanks for the response, that's a completely inaccurate statement. > > Here's an example from the Django docs: > > https://docs.djangoproject.com/en/1.3/topics/db/models/#intermediary-manyt > omany > > The Group

RE: ManyToMany problem

2011-09-29 Thread James DeMichele
Thanks for the response, that's a completely inaccurate statement. Here's an example from the Django docs: https://docs.djangoproject.com/en/1.3/topics/db/models/#intermediary-manyt omany The Group object has through="Membership". Although, one thing I notice is that it looks like in the

Re: ManyToMany problem

2011-09-29 Thread Shawn Milochik
I don't think you can make the 'through' argument a string, and I don't think there's circular dependency issue with the 'through' kwarg. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: modelformset partial save and AttributeErrors

2011-09-29 Thread Michael Wayne Goodman
Ahem... turned out to be quite a small problem. number.qsession = request.qsession should be number.qsession = request.session['qsession'] Sorry for the list noise. But if anybody has a better idea for how to tie data from multiple forms together with a common "session" (not necessarily a

ManyToMany problem

2011-09-29 Thread James DeMichele
Hello, I have created my own ManyToMany table, but am getting an error when I attempt to get a related item from one of my Models. Any insight would be greatly appreciated. I am on Django 1.3.1. *models/restuarant_hood_map.py* class RestaurantHoodMap(models.Model): restaurant =

Re: (off-topic) Quick method of sending files from ssh to clients

2011-09-29 Thread Tom Evans
I'm sure there are many many ways to use the shell to send email messages, but none of them are on topic for this list. Please lets not enumerate them. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

Re: (off-topic) Quick method of sending files from ssh to clients

2011-09-29 Thread Bjarni Rúnar Einarsson
2011/9/29 Bjarni Rúnar Einarsson : > If you have mutt installed (a popular text-mode mail reader/writer), > you can get the same thing done without any scripting: > > $ echo 'Here you go' |mutt recipi...@domain.com -s 'My subject' -a > /path/to/file ... following up to myself,

Re: (off-topic) Quick method of sending files from ssh to clients

2011-09-29 Thread Bjarni Rúnar Einarsson
If you have mutt installed (a popular text-mode mail reader/writer), you can get the same thing done without any scripting: $ echo 'Here you go' |mutt recipi...@domain.com -s 'My subject' -a /path/to/file :-) On Thu, Sep 29, 2011 at 2:57 PM, Cal Leeming [Simplicity Media Ltd]

(off-topic) Quick method of sending files from ssh to clients

2011-09-29 Thread Cal Leeming [Simplicity Media Ltd]
Hey, Little bit off topic, but quite relevant for the busy coder. Often I needed to quickly grab a file off a server, or send to a client, but it took me 2-3 minutes to fire up an SCP client, find the file, send it etc etc. So I created a small script (depends on sendmail and

Re: You -- yes, you -- should contribute to Django.

2011-09-29 Thread Shawn Milochik
On Wed, Sep 28, 2011 at 10:36 PM, Kurtis wrote: > Out of curiosity, is this a good place to start? > https://code.djangoproject.com/query?status=!closed=1 > That could be a good place to start. But we do have a lack of triage volunteers, so many tickets won't have been

Re: Question about QuerySet and Pagination

2011-09-29 Thread Felix Wagner
Thank you very much for your help On Sep 29, 4:25 pm, Tom Evans wrote: > On Thu, Sep 29, 2011 at 3:16 PM, Felix Wagner > wrote: > > Ok, so now i have: > > .. > >             > ... > > Now if i click next page I get an empty page because: >

Re: Create singular instance with ManyToManyField input as ids

2011-09-29 Thread Shawn Milochik
I think you need the commit=False argument. https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#the-save-method -- 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

Re: Help with forms (really struggling)

2011-09-29 Thread David
Thank you both so much for your help! I had been fighting this for some time; doesn't help starting Django whilst still learning Python and OOP. The following works perfectly: @login_required @transaction.commit_on_success def update_log(request, pk): if request.method == 'POST' and

Re: Question about QuerySet and Pagination

2011-09-29 Thread Tom Evans
On Thu, Sep 29, 2011 at 3:16 PM, Felix Wagner wrote: > Ok, so now i have: > .. >             ... > Now if i click next page I get an empty page because: > http://127.0.0.1:8000/search/?page=2, > > I probably need a url entry and do i have to give the poaginator the >

Re: Help with forms (really struggling)

2011-09-29 Thread Tom Evans
On Thu, Sep 29, 2011 at 3:16 PM, David wrote: > Thank you both for your assistance. > > When I try to use the following (which is my interpretation Tom of > your modifications) I get this error: > > Cannot assign "u'1'": "Log.person" must be a "Person" instance. > So you can

Re: Help with forms (really struggling)

2011-09-29 Thread David
I should add that person is a FK in the log model. -- 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

Re: Question about QuerySet and Pagination

2011-09-29 Thread Felix Wagner
Ok, so now i have: template: {% block coltype %}colMS{% endblock %} {% block content %} Suche Search: {% if query %} Resultate für "{{ query|escape }}": {% if results %}

Re: Help with forms (really struggling)

2011-09-29 Thread David
Thank you both for your assistance. When I try to use the following (which is my interpretation Tom of your modifications) I get this error: Cannot assign "u'1'": "Log.person" must be a "Person" instance. @login_required @transaction.commit_on_success def update_log(request, pk): if

Re: Help with forms (really struggling)

2011-09-29 Thread Tom Evans
On Thu, Sep 29, 2011 at 2:58 PM, David wrote: > Hi Kurtis > > Thanks for your reply. > > That wasn't a silly question. A person is not a user. > > I modified my view like this: > > @login_required > def update_log(request, pk): >        try: >                person =

Re: Dynamic parameters in django URLs

2011-09-29 Thread Piotr Zalewa
On 09/29/11 11:36, Dejan Noveski wrote: Hi, I want to add dynamic urls to my site for faceting purposes. E.g: /(type)/(subtype)/(category)/ But I also want something like this to work: /(type)/(subtype)/ or /(type)/(category)/ or /(subtype)/(category)/ or just /(category)/ | /(type)/ |

Re: Help with forms (really struggling)

2011-09-29 Thread David
Hi Kurtis Thanks for your reply. That wasn't a silly question. A person is not a user. I modified my view like this: @login_required def update_log(request, pk): try: person = Person.objects.get(pk=pk) except KeyError: raise Http404 if

Re: Question about QuerySet and Pagination

2011-09-29 Thread Tom Evans
On Thu, Sep 29, 2011 at 8:36 AM, Felix Wagner wrote: > Hello, > > I'm currently trying to paginate my results from a search query. > > views.py: > > def search(request): >    query = request.GET.get('q', '') > >    if query: >        qset = ( >            

Re: problem with middleware - correctly formatted

2011-09-29 Thread Tom Evans
On Thu, Sep 29, 2011 at 2:18 AM, jenia ivlev wrote: > Hello: > > This is the second version of my question. I reformatted it. > > I have defined a middleware class. and i have added it to the > middleware_classes attribute in setting. When a request comes in, the >

Re: Dynamic parameters in django URLs

2011-09-29 Thread Ilian Iliev
I had the same case a while ago but I decided always to keep all the params, and fill them with 'all' if empty i.e. /type/ redirects to /type/all/all/ /type/subtype/ redirects to type/subtupe/all Otherwise if you are absolute sure that it is inpossible for type,subtype and category to mach you

Re: Help with forms (really struggling)

2011-09-29 Thread Kurtis Mullins
Hey, I'm still half asleep so I apologize if this is a dumb question. Is the "Person" the User using this? If so, you should have access to the User object from the session. If not, you could probably do a query with the Primary Key to grab the Person object. e.g. person = Person.objects.get(pk

Re: Wired image file upload problem

2011-09-29 Thread @@
Thanks Dejan, Now my problem is that I can't got the file from request.FILES , the request.FILES is None. On Thu, Sep 29, 2011 at 6:31 PM, Dejan Noveski wrote: > Older versions of PIL have issues with incomplete exif data. If you make > thumbnails or in any way manipulate

Dynamic parameters in django URLs

2011-09-29 Thread Dejan Noveski
Hi, I want to add dynamic urls to my site for faceting purposes. E.g: /(type)/(subtype)/(category)/ But I also want something like this to work: /(type)/(subtype)/ or /(type)/(category)/ or /(subtype)/(category)/ or just /(category)/ | /(type)/ | /(subtype)/ Is there any clean way of doing this

Re: Wired image file upload problem

2011-09-29 Thread Dejan Noveski
Older versions of PIL have issues with incomplete exif data. If you make thumbnails or in any way manipulate the image, it wont work. Had this issue 2 days ago. Try working with PIL 1.1.7 On Thu, Sep 29, 2011 at 12:10 PM, @@ wrote: > No it's size limitation. don't know if it

Help with forms (really struggling)

2011-09-29 Thread David
Hi I have a page called Person which lists basic contact details. I intend to have a series of forms on this page in hidden div's that enable a user to submit data pertaining to this contact such as contact logs. Each form will be submitted by ajax which is why I am making their form actions

Re: Wired image file upload problem

2011-09-29 Thread @@
No it's size limitation. don't know if it was something wrong with exif, cause this is the only thing I found special with this image. I use ms paint open this image and saved it as another image, and the new image can be uploaded with no problem. On Thu, Sep 29, 2011 at 5:57 PM, Jian Chang

Re: Wired image file upload problem

2011-09-29 Thread Jian Chang
size limitation? it is wired. [?] 2011/9/28 @@ > Hi > I got a image can't upload while other image works fine, and i use paint > open this image and save it as another file, then the other file can be > uploaded. > The debug page shows the request.FILES is None. > The

Re: Sampling of the two models by matching fields.

2011-09-29 Thread Satan Study Django
Anybody? On 27 сен, 18:53, Satan Study Django wrote: > Good day. > To the case. > There are some models (simplified form): > > class Group (models.Model): >      name = models.CharField () > > class Person (models.Model): >      name =

Re: Helping someone move from Joomla to Django

2011-09-29 Thread Baurzhan Ismagulov
On Wed, Sep 28, 2011 at 11:19:30PM -0700, Derek wrote: > >   How would you recommend I go about this task of moving my friend > > over to a Django/Python based system over a Joomla/PHP based system? ... > >   He is requesting some other interesting features, which apparently > > someone else is

Question about QuerySet and Pagination

2011-09-29 Thread Felix Wagner
Hello, I'm currently trying to paginate my results from a search query. views.py: def search(request): query = request.GET.get('q', '') if query: qset = ( Q(NAME__icontains=query) ) results = Thin_Client.objects.filter(qset).distinct() else:

Re: Community Wiki/CMS app

2011-09-29 Thread Kevin
Pinax is live and well as they did a recent presentation at PyCon 2011, and the PyCon website is even made in Pinax. http://us.pycon.org/ List of complete sites currently built on Pinax: http://pinaxproject.com/sites/ The most impressive site in the list is actually GirlGamer.com, their website

Re: Disable HTTP Referer checking

2011-09-29 Thread sspross
On Sep 28, 5:19 pm, Tom Evans wrote: > On Wed, Sep 28, 2011 at 4:03 PM, sspross wrote: > > hi tom > > > thanks for your reply, but > > > i'm don't want to disable a whole view, just disabling the http > > referer checking in https. > > > silvan >

Re: Helping someone move from Joomla to Django

2011-09-29 Thread Derek
On Sep 28, 9:58 am, Kevin wrote: > Hello, > >   I have a friend who is doing website design, not any backend > programming tasks.  He actually would like me to do the backend > coding.  The unfortunate case is that he is currently using Joomla, > which I know almost nothing