Re: Can I POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Hemebond
Oh, and also AJAX requests could then do everything on the object URI
(since they won't need the forms). Maybe it could be done with
temporary objects in the database. Use a randomised value in the
redirect URL to re-fetch what the user typed in and the errors
associated, then discard the entry.

On Mar 30, 3:33 pm, Hemebond  wrote:
> I can definitely write my code the normal way. I just wanted to see if
> it was possible; perhaps some way I hadn't thought of. I just liked
> the idea of all CRUD operations being done on the object URI.
>
> On Mar 30, 3:29 am, Mjumbe Poe  wrote:
>
>
>
>
>
>
>
> > You're correct: HTTP does not allow you to, say, send POST data along
> > in a 30X (redirect) response [1].  You can redisplay the form at your
> > object's URL, but in order to actually do an HTTP redirect back to the
> > form URL, you'd have to pass the form data along in the URL query
> > string or store it on the session or something.  The easiest thing to
> > do in most cases is to POST to the /edit/ URL and redirect to the
> > detail page (or somewhere else) if valid.  This is what the [Create|
> > Update]View classes do.  Could you provide a little more context on
> > why this is infeasible in your code?  Maybe an snippet?
>
> > - Mjumbe
>
> > [1]http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3
>
> > On Mar 29, 7:49 am, Hemebond  wrote:
>
> > > I don't see anything on there that deals with transferring an
> > > redirecting with POST data. Is there a particular section that covers
> > > this?
>
> > > To be honest, I'm not sure if HTTP really supports what I'm trying to
> > > do, let alone Django.
>
> > > On Mar 30, 12:32 am, Joel Goldstick  wrote:
>
> > > > On Thu, Mar 29, 2012 at 7:13 AM, Hemebond  wrote:
> > > > > What can I pass back to the edit form view that already contains the
> > > > > values and errors and how? Posting to the edit form view would work
> > > > > but that would re-process the form.
>
> > > > > On Mar 30, 12:06 am, Joel Goldstick  wrote:
> > > > >> On Thu, Mar 29, 2012 at 6:33 AM, Hemebond  wrote:
> > > > >> > I want to use the URL of an object (a detail view) as the 
> > > > >> > destination
> > > > >> > for CRUD operations. I want it to be able to accept GET, POST and
> > > > >> > DELETE requests.
>
> > > > >> > As part of this, I want the edit form (retrieved by appending 
> > > > >> > /edit/
> > > > >> > to the object URL) to submit to the object URL. If the form is
> > > > >> > invalid, I then need to redirect back to the edit form, and display
> > > > >> > the errors.
>
> > > > >> > Is this possible? Is there a way to redirect back to the edit form
> > > > >> > with the new values and the errors that occurred during processing?
>
> > > > >> yes
>
> > > > You need to look at form handling in django.  Here is a good starting
> > > > point:http://www.djangobook.com/en/2.0/chapter07/
>
> > > > Then look at model forms.
>
> > > > --
> > > > Joel Goldstick

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



Template file not recognized for some strange reason

2012-03-29 Thread Mika
I'm working through one of the template examples in the django book
and the template file I created isn't being recognized for some reason
even though it's in the folder. The error report is at the bottom of
the page. The TEMP_DIRS variable is set to the correct file path in my
settings file:  TEMPLATE_DIRS = ("/Users/Documents/Music\ App/redlab/
templates",)
The view function is in order too:

from django.template.loader import get_template
from django.template import Context
from django.http import HttpResponse
import datetime
def current_datetime(request):
now = datetime.datetime.now()
t = get_template('current_datetime.html')
html = t.render(Context({'current_date':now}))
return HttpResponse(html)

The url file is also in order:

from django.conf.urls.defaults import*
from redlab.views import current_datetime
urlpatterns = patterns('', (r'^time/$', current_datetime))


And there is a current_datetime.html file in the templates directory
with the following code in it:
It is now {{ current_date }}.


But the file isn't being recognized for some reason. Please advise.
thnx.



Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/time/
Django Version: 1.3.1
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/Users/Documents/Music\ App/redlab/templates/current_datetime.html
(File does not exist)
Using loader django.template.loaders.app_directories.Loader:

Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
site-packages/django/core/handlers/base.py" in get_response
  111. response = callback(request,
*callback_args, **callback_kwargs)
File "/Users/mikaschiller/Documents/Music App/redlab/../redlab/
views.py" in current_datetime
  11.   t = get_template('current_datetime.html')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
site-packages/django/template/loader.py" in get_template
  157. template, origin = find_template(template_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
site-packages/django/template/loader.py" in find_template
  138. raise TemplateDoesNotExist(name)

Exception Type: TemplateDoesNotExist at /time/
Exception Value: current_datetime.html


-- 
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 POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Hemebond
I can definitely write my code the normal way. I just wanted to see if
it was possible; perhaps some way I hadn't thought of. I just liked
the idea of all CRUD operations being done on the object URI.

On Mar 30, 3:29 am, Mjumbe Poe  wrote:
> You're correct: HTTP does not allow you to, say, send POST data along
> in a 30X (redirect) response [1].  You can redisplay the form at your
> object's URL, but in order to actually do an HTTP redirect back to the
> form URL, you'd have to pass the form data along in the URL query
> string or store it on the session or something.  The easiest thing to
> do in most cases is to POST to the /edit/ URL and redirect to the
> detail page (or somewhere else) if valid.  This is what the [Create|
> Update]View classes do.  Could you provide a little more context on
> why this is infeasible in your code?  Maybe an snippet?
>
> - Mjumbe
>
> [1]http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3
>
> On Mar 29, 7:49 am, Hemebond  wrote:
>
>
>
>
>
>
>
> > I don't see anything on there that deals with transferring an
> > redirecting with POST data. Is there a particular section that covers
> > this?
>
> > To be honest, I'm not sure if HTTP really supports what I'm trying to
> > do, let alone Django.
>
> > On Mar 30, 12:32 am, Joel Goldstick  wrote:
>
> > > On Thu, Mar 29, 2012 at 7:13 AM, Hemebond  wrote:
> > > > What can I pass back to the edit form view that already contains the
> > > > values and errors and how? Posting to the edit form view would work
> > > > but that would re-process the form.
>
> > > > On Mar 30, 12:06 am, Joel Goldstick  wrote:
> > > >> On Thu, Mar 29, 2012 at 6:33 AM, Hemebond  wrote:
> > > >> > I want to use the URL of an object (a detail view) as the destination
> > > >> > for CRUD operations. I want it to be able to accept GET, POST and
> > > >> > DELETE requests.
>
> > > >> > As part of this, I want the edit form (retrieved by appending /edit/
> > > >> > to the object URL) to submit to the object URL. If the form is
> > > >> > invalid, I then need to redirect back to the edit form, and display
> > > >> > the errors.
>
> > > >> > Is this possible? Is there a way to redirect back to the edit form
> > > >> > with the new values and the errors that occurred during processing?
>
> > > >> yes
>
> > > You need to look at form handling in django.  Here is a good starting
> > > point:http://www.djangobook.com/en/2.0/chapter07/
>
> > > Then look at model forms.
>
> > > --
> > > Joel Goldstick

-- 
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: Web App Systems Management Tool for Ubuntu Platform

2012-03-29 Thread Alex Mandel
On 03/29/2012 06:37 PM, Eduardo Bergavera wrote:
> Hi Everyone!
> 
> I would like to ask some guidance regarding anyone who may be
> interested in developing web-based python app for systems management
> in Ubuntu. The web-app acts as centralized interface to manage cloud
> based or physical Ubuntu servers in one location. I'd like it to be
> developed using web2py framework. The system has features found in
> Ubuntu's proprietary systems management tool like Landscape
> --(http://www.canonical.com/enterprise-services/ubuntu-advantage/
> landscape/systems-management)
> a remote management tool for Ubuntu servers and desktops. The project
> combines some essential features of Webmin (webmin.com) and Landscape.
> 
> System Requirements:
> 
> * Django based web app
> * manages Ubuntu desktop or servers thru a single interface
> * require registration of clients (desktop or servers) to be managed
> by the system
> * install, remove, upgrade packages, update history
> * Manage users (create, remove, change password)
> * View system info (cpu, ram, io)
> * email notification such as status of services, package updates
> * support common basic configurations
> * ability to explore filesystem
> * reboot, shutdown remote servers
> * log viewer (/var/log)
> 
> 
> Thank you for your help and guidance.
> 

Take a look at ganeti web manager, it's a Django site for managing
ganeti virtualization clusters. It doesn't do any of the python specific
stuff you're talking about but does do the
creation/deletion/boot/restart/remote console for virtual machines.

Could be a good starting point for you.
https://code.osuosl.org/projects/ganeti-webmgr

Thanks,
Alex

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



Web App Systems Management Tool for Ubuntu Platform

2012-03-29 Thread Eduardo Bergavera
Hi Everyone!

I would like to ask some guidance regarding anyone who may be
interested in developing web-based python app for systems management
in Ubuntu. The web-app acts as centralized interface to manage cloud
based or physical Ubuntu servers in one location. I'd like it to be
developed using web2py framework. The system has features found in
Ubuntu's proprietary systems management tool like Landscape
--(http://www.canonical.com/enterprise-services/ubuntu-advantage/
landscape/systems-management)
a remote management tool for Ubuntu servers and desktops. The project
combines some essential features of Webmin (webmin.com) and Landscape.

System Requirements:

* Django based web app
* manages Ubuntu desktop or servers thru a single interface
* require registration of clients (desktop or servers) to be managed
by the system
* install, remove, upgrade packages, update history
* Manage users (create, remove, change password)
* View system info (cpu, ram, io)
* email notification such as status of services, package updates
* support common basic configurations
* ability to explore filesystem
* reboot, shutdown remote servers
* log viewer (/var/log)


Thank you for your help and guidance.

-- 
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: Where are the site variables set?

2012-03-29 Thread Mike Dewhirst

On 30/03/2012 10:02am, Robert Steckroth wrote:
Hello Gang, I have two other servers on Debian which have the correct 
site variables set. E.g. site.name , site.domain.
But on this particulaly crazy Centos setup the site variable is set to 
the default (www.example.com ).

It shows when I use it in this manner -->
{% load i18n %}
{% trans "Simply follow the link below to complete your Activation at" 
%} {{ site.name  }}:

http://{{ site.domain }}{% url registration_activate activation_key %}
{% blocktrans %}Link is valid for {{ expiration_days }} days.{% 
endblocktrans %}


How do I get the proper information in the site dictionary? Also, if 
applicable, might this

have anything to do with my crazy Centos/VirtualEnv setup?


www.example.com is in the database in the django_site table. If you have 
the Admin running, you can adjust it there under "Sites"


hth








--
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"
"Finding the exit without looking"

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



Where are the site variables set?

2012-03-29 Thread Robert Steckroth
Hello Gang, I have two other servers on Debian which have the correct site
variables set. E.g. site.name, site.domain.
But on this particulaly crazy Centos setup the site variable is set to the
default (www.example.com).
It shows when I use it in this manner -->
{% load i18n %}
{% trans "Simply follow the link below to complete your Activation at" %}
{{ site.name }}:
http://{{ site.domain }}{% url registration_activate activation_key %}
{% blocktrans %}Link is valid for {{ expiration_days }} days.{%
endblocktrans %}

How do I get the proper information in the site dictionary? Also, if
applicable, might this
have anything to do with my crazy Centos/VirtualEnv setup?






-- 
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"
"Finding the exit without looking"

-- 
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: strange problem deleting objects

2012-03-29 Thread Marc Aymerich
On Thu, Mar 29, 2012 at 11:47 AM, Marc Aymerich  wrote:
> On Thu, Mar 29, 2012 at 11:15 AM, Daniel Roseman  
> wrote:
>> On Thursday, 29 March 2012 00:06:29 UTC+1, Marc Aymerich wrote:
>>>
>>> Hi!,
>>> I've overrided the save() method of one of my ModelForms and I'm
>>> performing a delete of some related objects depending on some form
>>> fields values. The thing is I'm getting differents behaviours
>>> dependening on how the deletion is performed, consider:
>>>
>>> 1) self.instance.delete()
>>> 2) MyModel.objects.get(pk=self.instance.pk).delete()
>>>
>>> I'm listening the post_delete of self.instance class, in there I
>>> create a "dependency graph" of their related objects. The problem is
>>> that at some point I'm retriveing self.instance like:
>>> MyRelatedModel.self_instance_related_name and with the first (1)
>>> delete method I can still access to self.instance but with the second
>>> (2) delete method i'm getting a DoesNotExist.
>>>
>>> Why it's different?
>>>
>>> Thanks!
>>> --
>>> Marc
>>
>>
>> self.instance.delete() will delete the item from the database, but the
>> instance itself will still exist in memory. As long as you don't save it, it
>> will disappear when it goes out of scope, or you can explicitly call del()
>> on it.
>> --
>
> Hi Daniel,
> thanks for your answer!
> mmm, but deleting like
> MyModel.objects.get(pk=self.instance.pk).delete() self.instance will
> continue exist too, isn't it?

I give it a second thought and I think that you were absolutely right
Danniel. In (1) the post_save is called with a new object that no
longer exists when post_save is called and with (2) is called with
self.instance that still exists after post_save. Thanks and sorry for
not catching it at the first time.

thanks again :)
-- 
Marc

-- 
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: Problems with {% url %} in templates

2012-03-29 Thread Jamie Lawrence

On Mar 29, 2012, at 12:59 PM, Alasdair Nicol wrote:

> Hi Jamie,

> Don't include the (.*)$ in the regex for the include. The documented pattern 
> [1] for the include is
> 
>(r'^d/events/', include('myproject.events.urls')),

Ah, thank you, that was it. (I do need sleep - don't know how long I was 
staring at that and not seeing it.)

Thanks again, Alasdair.

-j

-- 
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: Problems with {% url %} in templates

2012-03-29 Thread Alasdair Nicol

Hi Jamie,

On 29/03/12 20:49, Jamie Lawrence wrote:

I'm very confused… this has worked fine in the past. Django 1.3.1

In myproject/urls.py:

urlpatterns = patterns('',
 (r'^d/events/(.*)$', include('myproject.events.urls')),
[…]
Don't include the (.*)$ in the regex for the include. The documented 
pattern [1] for the include is


(r'^d/events/', include('myproject.events.urls')),

Regards,
Alasdair

[1]: 
https://docs.djangoproject.com/en/dev/topics/http/urls/#including-other-urlconfs


--
Alasdair Nicol
Developer, MEMSET

mail: alasd...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, Guildford, 
Surrey, GU2 7YD, UK.

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



Problems with {% url %} in templates

2012-03-29 Thread Jamie Lawrence
I'm very confused… this has worked fine in the past. Django 1.3.1

In myproject/urls.py:

urlpatterns = patterns('',
(r'^d/events/(.*)$', include('myproject.events.urls')),
[…]

in myproject/events/urls.py :

urlpatterns = patterns('myproject.events.views',
   url(r'^add/$', 'add_view', name="event-add"),
[…]


Both:

{% url events.views.add_view %}

and

{% url event-add %}

Throw:

Caught NoReverseMatch while rendering: Reverse for 'event-add' with arguments 
'()' and keyword arguments '{}' not found.

(Or "Reverse for 'myproject.events.views', as appropriate.)

This must be something absurd… anyone see what I'm missing? Think I've been up 
too long.

TIA,

-j

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



Re: Best approach to execute tasks inside django admin views

2012-03-29 Thread Marc Aymerich
On Thu, Mar 29, 2012 at 7:40 PM, Marc Aymerich  wrote:
> On Thu, Mar 29, 2012 at 6:28 PM, Marc Aymerich  wrote:
>> Hi guys,
>> I have an application that execute some tasks after an object is
>> modifyed through django admin interface. In order to do that I'm
>> subscribed to django.contrib.admin.models.EntryLog post_save signal
>> and for each signal I execute a celery task.
>>
>> As you migh know django admin views are running under
>> commit_on_success transaction so executing tasks within can lead to
>> some issues, good explained on the celery documentation:
>> http://ask.github.com/celery/userguide/tasks.html#database-transactions
>>
>> So my question is, how do I should deal with this transactions?
>> it is possible to manually commit a commit_on_success transaction
>> before calling the task?
>> if not, what would you do? monkeypatch django admin views to use
>> commit_manually?
>> subclass all your project modelAdmin classes? (I'm using a lot of
>> reusable applications)
>>
>
> Just saw this ticket https://code.djangoproject.com/ticket/14051
>

problem solved by this app:
https://github.com/davehughes/django-transaction-signals

amazing :)

-- 
Marc

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



Re: Best approach to execute tasks inside django admin views

2012-03-29 Thread Marc Aymerich
On Thu, Mar 29, 2012 at 6:28 PM, Marc Aymerich  wrote:
> Hi guys,
> I have an application that execute some tasks after an object is
> modifyed through django admin interface. In order to do that I'm
> subscribed to django.contrib.admin.models.EntryLog post_save signal
> and for each signal I execute a celery task.
>
> As you migh know django admin views are running under
> commit_on_success transaction so executing tasks within can lead to
> some issues, good explained on the celery documentation:
> http://ask.github.com/celery/userguide/tasks.html#database-transactions
>
> So my question is, how do I should deal with this transactions?
> it is possible to manually commit a commit_on_success transaction
> before calling the task?
> if not, what would you do? monkeypatch django admin views to use
> commit_manually?
> subclass all your project modelAdmin classes? (I'm using a lot of
> reusable applications)
>

Just saw this ticket https://code.djangoproject.com/ticket/14051

-- 
Marc

-- 
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: Auth app in separate database

2012-03-29 Thread Chris
I setup my router following the docs.

Here's what my router.py looks like:

AUTH_APPS = ('auth',)

class MyRouter(object):
def db_for_read(self, model, **hints):
if model._meta.app_label in AUTH_APPS:
return 'auth'
return None

def db_for_read(self, model, **hints):
if model._meta.app_label in AUTH_APPS:
return 'auth'
return None

def allow_syncdb(self, db, model):
"Make sure the Auth apps only appears on the 'auth' db"
if db == 'auth':
return model._meta.app_label in AUTH_APPS
elif model._meta.app_label in AUTH_APPS:
return False
return None

Removing auth from the default database seems to cause issues with 
contenttypes and create errors on syncdb. auth and contenttypes seem to be 
dependent on each other.

On Thursday, 29 March 2012 12:15:49 UTC-4, Josh Cartmell wrote:
>
> Couldn't he also just add the router before syncdb and then they would 
> be created in the correct database? 
>
> Chris take a look at this documentation if you haven't already, it 
> explains routers which tell Django which database to use for a 
> particular query: 
> https://docs.djangoproject.com/en/dev/topics/db/multi-db/#using-routers 
>
> On Mar 28, 9:00 pm, Amit  wrote: 
> > While running syncdb command django uses default database to create 
> > tables. 
> > You can do one thing, first create default database using syncdb then 
> > copy auth related tables to another database. 
> > Then define router for auth. You can get more ref form django 
> > documentatiion. 
> > 
> > Regards, 
> > Amit 
> > 
> > On Mar 29, 4:08 am, Chris  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Has anyone been successful in putting the auth application in a 
> > > separate database so that users can be shared with different django 
> > > projects? 
> > 
> > > When I try to put the auth application in a different database I get 
> > > an error with syncdb: 
> > 
> > > django.db.utils.DatabaseError: relation "auth_permission" does not 
> > > exist 
> > > LINE 1: ...ntent_type_id", "auth_permission"."codename" FROM 
> > > "auth_perm...

-- 
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/-/ZaoLWNLzD3sJ.
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: comparing custom template tag within if tag

2012-03-29 Thread Nikhil Verma
Hi All

I am still not able to solve this problem .Any more suggestions ?

Thanks


On Thu, Mar 29, 2012 at 10:03 PM, Tom Evans wrote:

> On Thu, Mar 29, 2012 at 5:22 PM, Josh Cartmell 
> wrote:
> > I think something like this would work:
> > {% with price_for_pax service pax '' as pfp %}
>
> It won't. The {% with %} tag cannot arbitrarily call custom tags.
>
> Cheers
>
> Tom
>
> --
> 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.
>
>


-- 
Regards
Nikhil Verma
+91-958-273-3156

-- 
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: comparing custom template tag within if tag

2012-03-29 Thread Tom Evans
On Thu, Mar 29, 2012 at 5:22 PM, Josh Cartmell  wrote:
> I think something like this would work:
> {% with price_for_pax service pax '' as pfp %}

It won't. The {% with %} tag cannot arbitrarily call custom tags.

Cheers

Tom

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



Best approach to execute tasks inside django admin views

2012-03-29 Thread Marc Aymerich
Hi guys,
I have an application that execute some tasks after an object is
modifyed through django admin interface. In order to do that I'm
subscribed to django.contrib.admin.models.EntryLog post_save signal
and for each signal I execute a celery task.

As you migh know django admin views are running under
commit_on_success transaction so executing tasks within can lead to
some issues, good explained on the celery documentation:
http://ask.github.com/celery/userguide/tasks.html#database-transactions

So my question is, how do I should deal with this transactions?
it is possible to manually commit a commit_on_success transaction
before calling the task?
if not, what would you do? monkeypatch django admin views to use
commit_manually?
subclass all your project modelAdmin classes? (I'm using a lot of
reusable applications)

thank you guys!
-- 
Marc

-- 
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: comparing custom template tag within if tag

2012-03-29 Thread Josh Cartmell
I think something like this would work:
{% with price_for_pax service pax '' as pfp %}
{% if service.price == pfp %}
  do something
{% endif %}
{% endwith %}

Alternatively if price_for_pax is only used for comparing to
service.price you could have it return true or false based on whether
whatever equaled service.price, and then use it more directly.

Regards,
Josh

On Mar 29, 1:54 am, Tom Evans  wrote:
> On Wed, Mar 28, 2012 at 4:59 PM, Nikhil Verma  
> wrote:
> > Hi all
>
> > i have a custom template tag that takes some argument and calculates the
> > result.
> > I want to compare that value obtained from that custom tag with another
> > variable.
>
> > Custom template tag
> > {% price_for_pax service pax '' %}
>
> > variable :
>
> > {{service.price}}
>
> > What i want is {% if service.price == price_for_pax service pax ' ' %}
> >    do something
> >  {% endif %}
>
> > When i look for the result it does not show anything
> > Can i compare like this ? If not what can be the solution ?
>
> > Thanks in advance
>
> The manual has a section on this:
>
> https://docs.djangoproject.com/en/1.4//howto/custom-template-tags/#se...
>
> Cheers
>
> Tom

-- 
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: Auth app in separate database

2012-03-29 Thread Josh Cartmell
Couldn't he also just add the router before syncdb and then they would
be created in the correct database?

Chris take a look at this documentation if you haven't already, it
explains routers which tell Django which database to use for a
particular query:
https://docs.djangoproject.com/en/dev/topics/db/multi-db/#using-routers

On Mar 28, 9:00 pm, Amit  wrote:
> While running syncdb command django uses default database to create
> tables.
> You can do one thing, first create default database using syncdb then
> copy auth related tables to another database.
> Then define router for auth. You can get more ref form django
> documentatiion.
>
> Regards,
> Amit
>
> On Mar 29, 4:08 am, Chris  wrote:
>
>
>
>
>
>
>
> > Has anyone been successful in putting the auth application in a
> > separate database so that users can be shared with different django
> > projects?
>
> > When I try to put the auth application in a different database I get
> > an error with syncdb:
>
> > django.db.utils.DatabaseError: relation "auth_permission" does not
> > exist
> > LINE 1: ...ntent_type_id", "auth_permission"."codename" FROM
> > "auth_perm...

-- 
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: strange problem deleting objects

2012-03-29 Thread Marc Aymerich
On Thu, Mar 29, 2012 at 11:47 AM, Marc Aymerich  wrote:
> On Thu, Mar 29, 2012 at 11:15 AM, Daniel Roseman  
> wrote:
>> On Thursday, 29 March 2012 00:06:29 UTC+1, Marc Aymerich wrote:
>>>
>>> Hi!,
>>> I've overrided the save() method of one of my ModelForms and I'm
>>> performing a delete of some related objects depending on some form
>>> fields values. The thing is I'm getting differents behaviours
>>> dependening on how the deletion is performed, consider:
>>>
>>> 1) self.instance.delete()
>>> 2) MyModel.objects.get(pk=self.instance.pk).delete()
>>>
>>> I'm listening the post_delete of self.instance class, in there I
>>> create a "dependency graph" of their related objects. The problem is
>>> that at some point I'm retriveing self.instance like:
>>> MyRelatedModel.self_instance_related_name and with the first (1)
>>> delete method I can still access to self.instance but with the second
>>> (2) delete method i'm getting a DoesNotExist.
>>>
>>> Why it's different?
>>>
>>> Thanks!
>>> --
>>> Marc
>>
>>
>> self.instance.delete() will delete the item from the database, but the
>> instance itself will still exist in memory. As long as you don't save it, it
>> will disappear when it goes out of scope, or you can explicitly call del()
>> on it.
>> --
>
> Hi Daniel,
> thanks for your answer!
> mmm, but deleting like
> MyModel.objects.get(pk=self.instance.pk).delete() self.instance will
> continue exist too, isn't it?

Maybe it could be something related with db transactions?
-- 
Marc

-- 
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 POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Mjumbe Poe
You're correct: HTTP does not allow you to, say, send POST data along
in a 30X (redirect) response [1].  You can redisplay the form at your
object's URL, but in order to actually do an HTTP redirect back to the
form URL, you'd have to pass the form data along in the URL query
string or store it on the session or something.  The easiest thing to
do in most cases is to POST to the /edit/ URL and redirect to the
detail page (or somewhere else) if valid.  This is what the [Create|
Update]View classes do.  Could you provide a little more context on
why this is infeasible in your code?  Maybe an snippet?

- Mjumbe

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3

On Mar 29, 7:49 am, Hemebond  wrote:
> I don't see anything on there that deals with transferring an
> redirecting with POST data. Is there a particular section that covers
> this?
>
> To be honest, I'm not sure if HTTP really supports what I'm trying to
> do, let alone Django.
>
> On Mar 30, 12:32 am, Joel Goldstick  wrote:
>
>
>
>
>
>
>
> > On Thu, Mar 29, 2012 at 7:13 AM, Hemebond  wrote:
> > > What can I pass back to the edit form view that already contains the
> > > values and errors and how? Posting to the edit form view would work
> > > but that would re-process the form.
>
> > > On Mar 30, 12:06 am, Joel Goldstick  wrote:
> > >> On Thu, Mar 29, 2012 at 6:33 AM, Hemebond  wrote:
> > >> > I want to use the URL of an object (a detail view) as the destination
> > >> > for CRUD operations. I want it to be able to accept GET, POST and
> > >> > DELETE requests.
>
> > >> > As part of this, I want the edit form (retrieved by appending /edit/
> > >> > to the object URL) to submit to the object URL. If the form is
> > >> > invalid, I then need to redirect back to the edit form, and display
> > >> > the errors.
>
> > >> > Is this possible? Is there a way to redirect back to the edit form
> > >> > with the new values and the errors that occurred during processing?
>
> > >> yes
>
> > You need to look at form handling in django.  Here is a good starting
> > point:http://www.djangobook.com/en/2.0/chapter07/
>
> > Then look at model forms.
>
> > --
> > Joel Goldstick

-- 
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 POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Tom Evans
On Thu, Mar 29, 2012 at 12:49 PM, Hemebond  wrote:
> I don't see anything on there that deals with transferring an
> redirecting with POST data. Is there a particular section that covers
> this?
>
> To be honest, I'm not sure if HTTP really supports what I'm trying to
> do, let alone Django.
>

I think this is more accurate. You should try to sit within the
conventions used with HTTP in order to have a good experience.

You should present your form at a particular URI. If the form data is
valid, save the data, and redirect to a palce to view the data.

Eg,

» GET /widgets/create
« Django renders object creation form
* User fills in form
» POST /widgets/create
* Form is not valid
« Django renders bound object creation form, with errors highlighted
* User fills in form correctly
» POST /widgets/create
* Django creates object
« Django redirects user to /widgets/by-id/1
» GET /widgets/by-id/1
« Django renders object edit form

etc.

If you don't want to do it the standard way, there must be some
compelling reason. Care to share?

Cheers

Tom

-- 
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 POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Joel Goldstick
On Thu, Mar 29, 2012 at 7:49 AM, Hemebond  wrote:
> I don't see anything on there that deals with transferring an
> redirecting with POST data. Is there a particular section that covers
> this?
>
> To be honest, I'm not sure if HTTP really supports what I'm trying to
> do, let alone Django.
>
> On Mar 30, 12:32 am, Joel Goldstick  wrote:
>> On Thu, Mar 29, 2012 at 7:13 AM, Hemebond  wrote:
>> > What can I pass back to the edit form view that already contains the
>> > values and errors and how? Posting to the edit form view would work
>> > but that would re-process the form.
>>
>> > On Mar 30, 12:06 am, Joel Goldstick  wrote:
>> >> On Thu, Mar 29, 2012 at 6:33 AM, Hemebond  wrote:
>> >> > I want to use the URL of an object (a detail view) as the destination
>> >> > for CRUD operations. I want it to be able to accept GET, POST and
>> >> > DELETE requests.
>>
>> >> > As part of this, I want the edit form (retrieved by appending /edit/
>> >> > to the object URL) to submit to the object URL. If the form is
>> >> > invalid, I then need to redirect back to the edit form, and display
>> >> > the errors.
>>
>> >> > Is this possible? Is there a way to redirect back to the edit form
>> >> > with the new values and the errors that occurred during processing?
>>
>> >> yes
>>
>> You need to look at form handling in django.  Here is a good starting
>> point:http://www.djangobook.com/en/2.0/chapter07/
>>
>> Then look at model forms.
>>
In Django, urlconf doesn't care about whether you are posting or
getting or deleting.  It just dispatches to your view.  In your view
you check request.method and code accordingly.

I'm just learning Django myself, so others might tear this code apart
but take a look.  Whether you come to this url with POST data or not
alters the logic.  If POST then validate, and save.  If not post, then
fill in the form and display.  If no data to fill in, then display a
blank form.  The print statements show up on stdout of the terminal
that you start your dev server.

def edit_hotel_profile(request, hotel_id):
hotel_id = int(hotel_id)
print 'Editing hotel profile with hotel_id: %d' % hotel_id
if request.method == 'POST':
print "in edit_hotel_profile with POST data for hotel_id: %d" % hotel_id
#hotel_profile = HotelsHotelProfiles.objects.get(pk=hotel_id)
hotel_profile = HotelProfiles.objects.get(pk=hotel_id)
f = HotelProfileForm(request.POST, instance=hotel_profile)
#hotel_entry = f.save()
print f.errors
#e = f.errors
if f.is_valid():
hotel_entry = f.save()
print hotel_id, "saved to db"
else:
return render_to_response('hotels/hotel_form.html', {'f' :
f,}, context_instance=RequestContext(request))

try:
print "in edit_hotel_profile with no POST data for hotel_id:
%d" % hotel_id
#hotel_profile = HotelsHotelProfiles.objects.get(pk=hotel_id)
hotel_profile = HotelProfiles.objects.get(pk=hotel_id)
f = HotelProfileForm(instance=hotel_profile)
#f.save()
except:
print e
f = HotelProfileForm()
print 'rendering blank form'
return render_to_response('hotels/hotel_form.html', {'f' : f,},
context_instance=RequestContext(request))


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



-- 
Joel Goldstick

-- 
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 Admin can be able to configure Model fields

2012-03-29 Thread Tom Evans
On Thu, Mar 29, 2012 at 2:24 PM, Deepak RK  wrote:
> Ok , I will follow these guidelines ,
> Thanks
>
> I am a newbie in django.
> Again I want to come on question :
> I did some investigation around  Django admin inbuilt  functionality
> for my requirement but I have not found yet ?
> Admin can add another field in any model  and
> it should start appearing in form.
>

Yes, although when you change a model (adding another field), Django
will not automatically change the database structure for you. So you
would need to do that manually.

Django is not really designed to dynamically add/remove fields, or
indeed models, but yes, it can be done. However, wanting to do
something like that it is normally a sign that you have a bad design.

Cheers

Tom

-- 
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 Admin can be able to configure Model fields

2012-03-29 Thread Deepak RK
Ok , I will follow these guidelines ,
Thanks

I am a newbie in django.
Again I want to come on question :
I did some investigation around  Django admin inbuilt  functionality
for my requirement but I have not found yet ?
Admin can add another field in any model  and
it should start appearing in form.


On Mar 29, 6:11 pm, Andre Terra  wrote:
> Deepak,
>
> Please read through this before posting again:
>
> https://code.djangoproject.com/wiki/UsingTheMailingList
>
> Cheers,
> AT
>
>
>
>
>
>
>
> On Thu, Mar 29, 2012 at 5:04 AM, Deepak RK  wrote:
> > Admin can add another field in any model (lets say UserProfile ) and
> > it should start appearing in registration form.
>
> > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
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 Admin can be able to configure Model fields

2012-03-29 Thread Andre Terra
Deepak,

Please read through this before posting again:

https://code.djangoproject.com/wiki/UsingTheMailingList


Cheers,
AT

On Thu, Mar 29, 2012 at 5:04 AM, Deepak RK  wrote:

> Admin can add another field in any model (lets say UserProfile ) and
> it should start appearing in registration form.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: is doing text manipulations in django's template faster than doing same in views

2012-03-29 Thread Andre Terra
If you're doing a lot of operations with your data, there's a chance it
should be moved to the view. The template should usually be restricted to
defining *how* data gets displayed, whereas the view defines *what* your
data is.


Cheers,
AT

On Thu, Mar 29, 2012 at 7:30 AM, vijay shanker wrote:

> which one is faster or considered better in terms of performance ?
>
> --
> 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.



is doing text manipulations in django-template fater than doing same in views

2012-03-29 Thread vijay shanker
i have to do basic text manipulations at times .. which is a better
way.. to do so in template or return a result only after doing so from
views ??

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



is doing text manipulations in django's template faster than doing same in views

2012-03-29 Thread vijay shanker
which one is faster or considered better in terms of performance ?

-- 
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 POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Hemebond
I don't see anything on there that deals with transferring an
redirecting with POST data. Is there a particular section that covers
this?

To be honest, I'm not sure if HTTP really supports what I'm trying to
do, let alone Django.

On Mar 30, 12:32 am, Joel Goldstick  wrote:
> On Thu, Mar 29, 2012 at 7:13 AM, Hemebond  wrote:
> > What can I pass back to the edit form view that already contains the
> > values and errors and how? Posting to the edit form view would work
> > but that would re-process the form.
>
> > On Mar 30, 12:06 am, Joel Goldstick  wrote:
> >> On Thu, Mar 29, 2012 at 6:33 AM, Hemebond  wrote:
> >> > I want to use the URL of an object (a detail view) as the destination
> >> > for CRUD operations. I want it to be able to accept GET, POST and
> >> > DELETE requests.
>
> >> > As part of this, I want the edit form (retrieved by appending /edit/
> >> > to the object URL) to submit to the object URL. If the form is
> >> > invalid, I then need to redirect back to the edit form, and display
> >> > the errors.
>
> >> > Is this possible? Is there a way to redirect back to the edit form
> >> > with the new values and the errors that occurred during processing?
>
> >> yes
>
> You need to look at form handling in django.  Here is a good starting
> point:http://www.djangobook.com/en/2.0/chapter07/
>
> Then look at model forms.
>
> --
> Joel Goldstick

-- 
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 POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Joel Goldstick
On Thu, Mar 29, 2012 at 7:13 AM, Hemebond  wrote:
> What can I pass back to the edit form view that already contains the
> values and errors and how? Posting to the edit form view would work
> but that would re-process the form.
>
> On Mar 30, 12:06 am, Joel Goldstick  wrote:
>> On Thu, Mar 29, 2012 at 6:33 AM, Hemebond  wrote:
>> > I want to use the URL of an object (a detail view) as the destination
>> > for CRUD operations. I want it to be able to accept GET, POST and
>> > DELETE requests.
>>
>> > As part of this, I want the edit form (retrieved by appending /edit/
>> > to the object URL) to submit to the object URL. If the form is
>> > invalid, I then need to redirect back to the edit form, and display
>> > the errors.
>>
>> > Is this possible? Is there a way to redirect back to the edit form
>> > with the new values and the errors that occurred during processing?
>>
>> yes
>>
You need to look at form handling in django.  Here is a good starting
point: http://www.djangobook.com/en/2.0/chapter07/

Then look at model forms.

-- 
Joel Goldstick

-- 
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 POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Hemebond
What can I pass back to the edit form view that already contains the
values and errors and how? Posting to the edit form view would work
but that would re-process the form.

On Mar 30, 12:06 am, Joel Goldstick  wrote:
> On Thu, Mar 29, 2012 at 6:33 AM, Hemebond  wrote:
> > I want to use the URL of an object (a detail view) as the destination
> > for CRUD operations. I want it to be able to accept GET, POST and
> > DELETE requests.
>
> > As part of this, I want the edit form (retrieved by appending /edit/
> > to the object URL) to submit to the object URL. If the form is
> > invalid, I then need to redirect back to the edit form, and display
> > the errors.
>
> > Is this possible? Is there a way to redirect back to the edit form
> > with the new values and the errors that occurred during processing?
>
> yes
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Joel Goldstick

-- 
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 POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Joel Goldstick
On Thu, Mar 29, 2012 at 6:33 AM, Hemebond  wrote:
> I want to use the URL of an object (a detail view) as the destination
> for CRUD operations. I want it to be able to accept GET, POST and
> DELETE requests.
>
> As part of this, I want the edit form (retrieved by appending /edit/
> to the object URL) to submit to the object URL. If the form is
> invalid, I then need to redirect back to the edit form, and display
> the errors.
>
> Is this possible? Is there a way to redirect back to the edit form
> with the new values and the errors that occurred during processing?
>

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



-- 
Joel Goldstick

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



Can I POST edit form to detail view, and redirect back if invalid?

2012-03-29 Thread Hemebond
I want to use the URL of an object (a detail view) as the destination
for CRUD operations. I want it to be able to accept GET, POST and
DELETE requests.

As part of this, I want the edit form (retrieved by appending /edit/
to the object URL) to submit to the object URL. If the form is
invalid, I then need to redirect back to the edit form, and display
the errors.

Is this possible? Is there a way to redirect back to the edit form
with the new values and the errors that occurred during processing?

-- 
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: strange problem deleting objects

2012-03-29 Thread Marc Aymerich
On Thu, Mar 29, 2012 at 11:15 AM, Daniel Roseman  wrote:
> On Thursday, 29 March 2012 00:06:29 UTC+1, Marc Aymerich wrote:
>>
>> Hi!,
>> I've overrided the save() method of one of my ModelForms and I'm
>> performing a delete of some related objects depending on some form
>> fields values. The thing is I'm getting differents behaviours
>> dependening on how the deletion is performed, consider:
>>
>> 1) self.instance.delete()
>> 2) MyModel.objects.get(pk=self.instance.pk).delete()
>>
>> I'm listening the post_delete of self.instance class, in there I
>> create a "dependency graph" of their related objects. The problem is
>> that at some point I'm retriveing self.instance like:
>> MyRelatedModel.self_instance_related_name and with the first (1)
>> delete method I can still access to self.instance but with the second
>> (2) delete method i'm getting a DoesNotExist.
>>
>> Why it's different?
>>
>> Thanks!
>> --
>> Marc
>
>
> self.instance.delete() will delete the item from the database, but the
> instance itself will still exist in memory. As long as you don't save it, it
> will disappear when it goes out of scope, or you can explicitly call del()
> on it.
> --

Hi Daniel,
thanks for your answer!
mmm, but deleting like
MyModel.objects.get(pk=self.instance.pk).delete() self.instance will
continue exist too, isn't it?

-- 
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 Admin can be able to configure Model fields

2012-03-29 Thread Deepak RK
Admin can add another field in any model (lets say UserProfile ) and
it should start appearing in registration form.

Thanks

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



Re: strange problem deleting objects

2012-03-29 Thread Daniel Roseman
On Thursday, 29 March 2012 00:06:29 UTC+1, Marc Aymerich wrote:
>
> Hi!,
> I've overrided the save() method of one of my ModelForms and I'm
> performing a delete of some related objects depending on some form
> fields values. The thing is I'm getting differents behaviours
> dependening on how the deletion is performed, consider:
>
> 1) self.instance.delete()
> 2) MyModel.objects.get(pk=self.instance.pk).delete()
>
> I'm listening the post_delete of self.instance class, in there I
> create a "dependency graph" of their related objects. The problem is
> that at some point I'm retriveing self.instance like:
> MyRelatedModel.self_instance_related_name and with the first (1)
> delete method I can still access to self.instance but with the second
> (2) delete method i'm getting a DoesNotExist.
>
> Why it's different?
>
> Thanks!
> -- 
> Marc
>

self.instance.delete() will delete the item from the database, but the 
instance itself will still exist in memory. As long as you don't save it, 
it will disappear when it goes out of scope, or you can explicitly call 
del() on it.
--
DR.

-- 
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/-/SBZb9WcCztsJ.
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: comparing custom template tag within if tag

2012-03-29 Thread Tom Evans
On Wed, Mar 28, 2012 at 4:59 PM, Nikhil Verma  wrote:
> Hi all
>
> i have a custom template tag that takes some argument and calculates the
> result.
> I want to compare that value obtained from that custom tag with another
> variable.
>
> Custom template tag
> {% price_for_pax service pax '' %}
>
> variable :
>
> {{service.price}}
>
> What i want is {% if service.price == price_for_pax service pax ' ' %}
>    do something
>  {% endif %}
>
> When i look for the result it does not show anything
> Can i compare like this ? If not what can be the solution ?
>
> Thanks in advance
>

The manual has a section on this:

https://docs.djangoproject.com/en/1.4//howto/custom-template-tags/#setting-a-variable-in-the-context

Cheers

Tom

-- 
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: Tweepy Not Displaying

2012-03-29 Thread Tom Evans
On Wed, Mar 28, 2012 at 11:56 PM, coded kid  wrote:
> Hi guys, I want to display user’s timeline in my django app but it’s
> not working. It only display a white blank page! I’m using Tweepy.
> Below are my codes:
>
> Views.py
>
> import tweepy
>
> def tweetstream(request):
>    consumer_key=""
>    consumer_secret="XXX"
>    access_token="XXX"
>    access_token_secret=""
>    auth=tweepy.OAuthHandler(consumer_key, consumer_secret)
>    auth.set_access_token(access_token, access_token_secret)
>    api=tweepy.API(auth)
>    status=api.user_timeline()
>    for status in status:
>        if status:
>            status.__getstate__()
>            return render_to_response('tweet.html',
> context_instance=RequestContext(request))

I'm not sure this is the best place to ask how to use tweepy*. I know
about django, not tweepy, so I can't tell you if you are using the
tweepy API correctly.

You're returning inside a loop. This means that the first time status
is true, you will exit the loop. I'm not sure that is intentional.

>
> Template:
> {% extends "base.html" %}
>
>  {% block content %}
>
>  {% for status in status %}

'for status in status' is probably going to work, but why be so
confusing? Also, what is this 'status' variable? You are passing no
variables named status to the template - in fact, you're not passing
anything.

Cheers

Tom

* This is one of my pet peeves. Just because you are using django +
(random bit of software), it doesn't mean you well get good support
for (random bit of software) on the django mailing lists.

-- 
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: Implementing Foreign Key without admin interface

2012-03-29 Thread Sandeep kaur
On Fri, Mar 9, 2012 at 4:31 AM, Ramiro Morales  wrote:
> On Thu, Mar 8, 2012 at 4:44 PM, Sandeep kaur  wrote:
>>                        job_no_id = client.job_no
>>                        ...
>> Am I wrong somewhere?  How should I do this?  Please help!!
>
> Yes, that client variable appears magically. Please paste working code,
> an abridged version but working code.
>
Sorry for very late reply. See my code at :

https://github.com/sandeepmadaan/TCC11_12_1/tree/master/TCC


-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

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