Re: Javascript AJAX url call not responding

2013-07-04 Thread Peith Vergil
If that's an AJAX POST request, then it may be because you are not passing
the CSRF token in the header. Add this code before doing the AJAX call:

function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));}$.ajaxSetup({
crossDomain: false, // obviates need for sameOrigin test
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}});

See here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax




On Fri, Jul 5, 2013 at 10:03 AM,  wrote:

> So I have django 1.5.1 installed,
> have persistent messages installed, and have messages displaying in a list
> via the template reference {% include
> "persistent_messages/message/includes/messages.jquery.html" %}
>
> The following javascript click trigger is bound to an anchor tag within
> the list:
>
> $(closeSelector).click(function(event) {
> event.preventDefault();
> $.ajax({
> url: "//url.com/"+$(this).attr('href')
> })
> if ($(messageSelector).length <= 2) {
> $(closeAllSelector).messageClose();
> }
>
> $(this).closest(messageSelector).messageClose();
> });
>
> The link being referenced is https://url.com/messages/mark_read/583/
> If I access that same link manually in the address bar, the appropriate
> call in the backend
> gets executed and the message is marked read. The ajax equivalent never
> seems to respond.
> I added logging to the persistent messages view and confirmed the ajax
> call is never
> calling mark_read() method.
>
> Chrome dev tools indicates that the ajax call is "pending" and never
> changes from this state.
>
> Any suggestions or ideas on what may be causing this?
>
> NOTE: I prepend the "//url.com" to avoid getting 'insecure content'
> warnings, since this ajax code is being executed
> from a https page. This change did not seem to affect the bug in any way,
> since the response is the same.
>
> Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [SPAM] Implementing User login expiration

2013-07-04 Thread Dave Koo
Great solution Sam!

On Tuesday, April 9, 2013 11:30:41 AM UTC-7, Sam Solomon wrote:
>
> Depending on if the expiration is a temporary thing or if you actually 
> want to permanently deactivate the user, this may be even simpler and 
> database efficient (and is what we use to ban users):
>
> class DeactivateUserMiddleware(object):
> def process_request(self, request):
> if request.user.is_authenticated() and not request.user.is_active:
> return logout(request)
>
> In coordination with a cron job that runs a management command 
> periodically with this code:
>
> from django.utils.timezone import nowUser.objects.filter(is_active=True, 
> profile__account_expiration__lte=now()).update(is_active=False)
>
>
> This will also allow you to manually deactivate users if you decide you 
> want to ban someone before their account expires.
>
>
> On Monday, April 8, 2013 8:26:47 AM UTC-7, John DeRosa (work) wrote:
>>
>> On Apr 5, 2013, at 5:33 PM, Nikolas Stevenson-Molnar <
>> nik.m...@consbio.org> wrote: 
>>
>> > How about creating request middleware to sign out deactivated users? 
>> > Something like: 
>> > 
>> > if request.user.profile.expired: 
>> >logout(request) 
>> > 
>> > If you're concerned about the extra database hit per request, then 
>> maybe 
>> > cache the expiration? 
>> > 
>> > expire_date = cache.get("%d_expire" % request.user.id) 
>> > if not expire_date: 
>> >expire_date = request.user.profile.expire_date 
>> >cache.set(...) 
>> > if expire date < now() 
>> >logout(request) 
>> > 
>> > _Nik 
>>
>> Great idea! Thank you! 
>>
>> John 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Javascript AJAX url call not responding

2013-07-04 Thread nesornet
So I have django 1.5.1 installed,
have persistent messages installed, and have messages displaying in a list
via the template reference {% include 
"persistent_messages/message/includes/messages.jquery.html" %}

The following javascript click trigger is bound to an anchor tag within the 
list:

$(closeSelector).click(function(event) {
event.preventDefault();
$.ajax({
url: "//url.com/"+$(this).attr('href')
})
if ($(messageSelector).length <= 2) {
$(closeAllSelector).messageClose();
}

$(this).closest(messageSelector).messageClose();
});

The link being referenced is https://url.com/messages/mark_read/583/ 
If I access that same link manually in the address bar, the appropriate 
call in the backend
gets executed and the message is marked read. The ajax equivalent never 
seems to respond.
I added logging to the persistent messages view and confirmed the ajax call 
is never
calling mark_read() method.

Chrome dev tools indicates that the ajax call is "pending" and never 
changes from this state.

Any suggestions or ideas on what may be causing this?

NOTE: I prepend the "//url.com" to avoid getting 'insecure content' 
warnings, since this ajax code is being executed
from a https page. This change did not seem to affect the bug in any way, 
since the response is the same.

Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




is it OK to process the "next=xxx" url parameter in the admin login view

2013-07-04 Thread panfei
for some simple use cases, it is convenient to reuse the admin login site,
if the admin login view can process the next parameter in the url, we can
reuse it more smoothly.

-- 
不学习,不知道

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




testing

2013-07-04 Thread Larry Martell
I'm just getting involved with setting up testing using the django
testing facilities, and I have a couple of questions.

If I do this from the django shell:

$ python manage.py shell
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.test.utils import setup_test_environment
>>> setup_test_environment()
>>>

Should I expect to see that the test db was created? Because I do not
see it. (The docs say "This convenience method sets up the test
database").  But then I read:

create_test_db: Creates a new test database and runs syncdb against
it. So then I thought maybe I have to call that. But I got:

>>> create_test_db()
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'create_test_db' is not defined


Concerning fixture, I read in the docs where it says you can set up
fixture files for initialing the test db. What will prevent those test
fixtures from getting loaded when I do a syncdb of my 'real' database?

Thanks!
-larry

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 runserver hangs in Chrome

2013-07-04 Thread eXt
I can confirm this issue. Exactly the same problem here.

W dniu czwartek, 4 lipca 2013 02:52:58 UTC+2 użytkownik Nikolas 
Stevenson-Molnar napisał:
>
>  Also, while Chrome is spinning, I can open Firefox and load pages 
> (including the problem page) just fine. So it's not that the server is 
> overloaded or anything like that...
>
> _Nik
>
> On 7/3/2013 5:39 PM, Nikolas Stevenson-Molnar wrote:
>  
> I've just updated to Django 1.5 and am running into a problem when using 
> Chrome with the Django devlopment server (and staticfiles). One particular 
> page which loads a lot of static content *consistently* hangs in Chrome 
> (works fine in Firefox). This seems similar to two resolved issues: 
> https://code.djangoproject.com/ticket/16099 and 
> https://code.djangoproject.com/ticket/18336. Except that I've waited 
> several minutes and the resources haven't finished loading. I've increased 
> request_queue_size as suggested in the second issue (first to 10, then 20, 
> then 50) with no change.
>
> I'd chalk this up entirely as a Chrome problem, except that if I switch 
> back to Django 1.4 (changing nothing else), everything goes back to working 
> fine. So what changed about runserver in Django 1.5 that might cause this? 
> And more importantly, how do I get around it? I'm running everything on 
> Windows 7 with Django 1.5.1 and the latest version of Chrome.
>
> Thanks,
> _Nik
>
>
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Namespace URLs in TestCase

2013-07-04 Thread Tomáš Ehrlich
As I said, it's trivial:

urlpatterns = patterns('', 
url(r'^sso/$', include(app_patterns, 'app', 'app')))

The regexp is wrong. It should be only ^sso/ because other urls are 
appended after it…

Fortunatelly, Django 1.6 has more helpful exception as it prints all url 
patterns which 'reverse' function tried.

Sorry for spam, but it took me a while to found it.

Cheers,
  Tom


Dne čtvrtek, 4. července 2013 16:53:34 UTC+2 Tomáš Ehrlich napsal(a):
>
> Hi there, 
> it's probably silly bug, but I can't figure it out: 
>
>
> I have one test: 
> ### 
> # app/tests_functional/test_app.py 
> from django.core.urlresolvers import reverse 
> from django.test import TestCase 
>
> class TestApp(TestCase): 
> urls = 'app.tests_functional.urls' 
>
> def test_app(self): 
> print(reverse('app:get'), reverse('app:retrieve')) 
> self.fail() 
>
>
> where urls are defined: 
> ### 
> # apps/tests_functional/urls.py 
> from django.conf.urls import patterns, url, include 
>
> # I use class-based views, which are tested and works. 
> def view(request): pass   
>
> app_patterns = patterns('', 
> url(r'^get/$', view, name='get'), 
> url(r'^retrieve/$', view, name='retrieve')) 
>
> urlpatterns = patterns('', 
> url(r'^sso/$', include(app_patterns, 'app', 'app'))) 
>
>
> Now, when I run tests, I got Exception: 
> NoReverseMatch: Reverse for 'get' with arguments '()' and keyword 
> arguments '{}' not found. 
>
>
> I tried to rename app_patterns to urlpatterns and reverse('get'). It 
> works, but my app uses namespaced urls, so I can't change code of view 
> to test it that way. 
>
> I believe it's really silly think. Can you see it? 
>
>
> Thank you :) 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Issue in User authentication

2013-07-04 Thread vijay shanker
*Hi*
*I am using django 1.5 and created my own user model by AUTH_USER_MODEL= 
'account.User' in settings.*

*my user model is like this:*

from django.db import models
from django.contrib.auth.models import AbstractBaseUser, UserManager, 
PermissionsMixin
# Create your models here.
GENDER = (
('M', 'Male'),
('F', 'Female')
)

class User(AbstractBaseUser, PermissionsMixin):
username = models.CharField(max_length=100, unique=True)
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
email = models.EmailField(unique=True)
gender = models.CharField(max_length=10, choices=GENDER)
is_admin = models.BooleanField(default=False)
is_staff = models.BooleanField(default=False)
is_active = models.BooleanField(default=False)
date_joined = models.DateTimeField(auto_now_add=True)

objects = UserManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username']

def __unicode__(self):
return self.get_full_name()


def get_full_name(self):
return ' '.join([self.first_name, self.last_name]) or self.username

def get_short_name(self):
return self.first_name or self.username.

The form which i present to user for signup is:

class SignupForm(forms.ModelForm):
class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'email', 'gender', 
'password']
exclude = ['last_login', 
'is_superuser','groups','user_permissions', 'is_admin', 'is_staff', 
'is_active']
widgets = {
'password': forms.PasswordInput(),
}

def save(self):
user = super(SignupForm, self).save(commit=False)
user.set_password(self.cleaned_data['password'])
user.save(commit=True)
return user


*my login view function is like this:*

class LoginView(View):
def get(self, request, *args, **kwargs):
form = LoginForm()
return render_to_response('login.html', 
{'form':form},context_instance = RequestContext(request) )

def post(self,request,*args, **kwargs ):
username = self.request.POST['username']
password = self.request.POST['password']
user = authenticate(username=username, password=password)

if user is not None:
if user.is_active:
print "You provided a correct username and password!"
login(request, user)
return redirect(reverse('bands-list'))
else:
login(request, user)
print "Your account has been disabled!"
return redirect(reverse('bands-list'))
else:
form = LoginForm()
return render_to_response('login.html', 
{'form':form},context_instance = RequestContext(request) )

*and somewhere in my template:*

{% if request.user.is_authenticated %}
hello {{ user.first_name }} Logout
{% else %}
Login
Signup
{% endif %}

*the problem i am facing are:*
*
*
*1. when the user signs up, password stored are not encrypted, ( though i 
am overriding save() to do so above)*
*2. though i provide correct password, request.user.is_authenticated does 
not works for me.*
*
*
kind suggestions are welcome.
Regards
Vijay Shanker



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: editing python module

2013-07-04 Thread Jennifer Look
Never mind. I knew I was being a complete idiot about this. THe scroll bar 
apparently doesn't show up until you hover over it, and I didn't realize 
that only the bottom page of the file was showing.

On Thursday, July 4, 2013 10:46:46 AM UTC-4, Jennifer Look wrote:
>
> I am brand new to all this, and just starting to work my way through the 
> Django tutorial. I got to the "Database setup" step, where it says to edit 
> mysite/settings.py 
> and I'm stymied.
> The previous step was to start the development server. I should quit the 
> server before editing variables, right?
> How do I edit the settings.py file? It seems like I should just be able to 
> open the file in a text editor, but I can't seem to figure our how from the 
> bask prompt.
>
> Thanks for any suggestions!
> Jen
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: editing python module

2013-07-04 Thread Jennifer Look
Oh, I should probably mention that I'm on a Mac Os X 10.8 and running 
djangostack from BitNami

On Thursday, July 4, 2013 10:46:46 AM UTC-4, Jennifer Look wrote:
>
> I am brand new to all this, and just starting to work my way through the 
> Django tutorial. I got to the "Database setup" step, where it says to edit 
> mysite/settings.py 
> and I'm stymied.
> The previous step was to start the development server. I should quit the 
> server before editing variables, right?
> How do I edit the settings.py file? It seems like I should just be able to 
> open the file in a text editor, but I can't seem to figure our how from the 
> bask prompt.
>
> Thanks for any suggestions!
> Jen
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: editing python module

2013-07-04 Thread Jennifer Look

>
> Thanks Tom! I had tried reading settings.py into nano but it didn't look 
> anything like I expected, so I thought I was doing it wrong.  I was 
> expecting a list of variables like ENGINE, NAME, etc but instead what I see 
> is: 
>
>},
> 'loggers': {
> 'django.request': {
> 'handlers': ['mail_admins'],
> 'level': 'ERROR',
> 'propagate': True,
> },
> }
> }
>

Am I supposed to create the keys inside the request bracket? Or am I just 
reading the settings.py file in incorrectly somehow?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: editing python module

2013-07-04 Thread Tom Evans
On Thu, Jul 4, 2013 at 3:46 PM, Jennifer Look  wrote:
> I am brand new to all this, and just starting to work my way through the
> Django tutorial. I got to the "Database setup" step, where it says to edit
> mysite/settings.py and I'm stymied.
> The previous step was to start the development server. I should quit the
> server before editing variables, right?
> How do I edit the settings.py file? It seems like I should just be able to
> open the file in a text editor, but I can't seem to figure our how from the
> bask prompt.
>
> Thanks for any suggestions!
> Jen
>

You can use any editor you want, it does not have to be an editor you
launch from the bash prompt. Common console based editors for *nix are
vim, emacs, pico and nano, and there are a wealth of non console based
editors like Kate, gedit, and I'm sure now I've mentioned those, a
whole host of other people will mention their favourites also.

When using the development server, you can in fact change things on
the fly. Most of the time the development server is just sitting there
waiting for you to make a request, and when it notices that you've
changed any of the files it will restart itself.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Namespace URLs in TestCase

2013-07-04 Thread Tomas Ehrlich
Hi there,
it's probably silly bug, but I can't figure it out:


I have one test:
###
# app/tests_functional/test_app.py
from django.core.urlresolvers import reverse
from django.test import TestCase

class TestApp(TestCase):
urls = 'app.tests_functional.urls'

def test_app(self):
print(reverse('app:get'), reverse('app:retrieve'))
self.fail()


where urls are defined:
###
# apps/tests_functional/urls.py
from django.conf.urls import patterns, url, include

# I use class-based views, which are tested and works.
def view(request): pass  

app_patterns = patterns('',
url(r'^get/$', view, name='get'),
url(r'^retrieve/$', view, name='retrieve'))

urlpatterns = patterns('',
url(r'^sso/$', include(app_patterns, 'app', 'app')))


Now, when I run tests, I got Exception:
NoReverseMatch: Reverse for 'get' with arguments '()' and keyword
arguments '{}' not found.


I tried to rename app_patterns to urlpatterns and reverse('get'). It
works, but my app uses namespaced urls, so I can't change code of view
to test it that way.

I believe it's really silly think. Can you see it?


Thank you :)

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




editing python module

2013-07-04 Thread Jennifer Look
I am brand new to all this, and just starting to work my way through the 
Django tutorial. I got to the "Database setup" step, where it says to edit 
mysite/settings.py 
and I'm stymied.
The previous step was to start the development server. I should quit the 
server before editing variables, right?
How do I edit the settings.py file? It seems like I should just be able to 
open the file in a text editor, but I can't seem to figure our how from the 
bask prompt.

Thanks for any suggestions!
Jen


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Call action with a link in the admin site

2013-07-04 Thread Jesús Lucas Flores
Hola Juan Antonio,

Es totalmente posible.

Puedes ver un ejemplo en alguno de mis proyectos:
https://github.com/jelukas/presupy/blob/master/presu/admin.py#L39-L47

Un saludo


2013/7/4 Juan Antonio García Cano 

> In the admin.py i have this function:
>
> actions = ['generar_pdf']
> def generar_pdf(self, request, queryset):
>
> ... (This function make a PDF of the object selected)
>
> And i show one button in the list_display (of the admin site) with this
> function:
>
> def boton_mail(self,obj):
> return mark_safe(' src="http://mypage/static/admin/img/descargar_pdf.png; alt="Descargar PDF" 
> width=30 height=25>')
>
> It is posible to call the function "generar_pdf" with a link (< a >) in
> the function "boton_mail"?
>
> (I want to call the action from a image in the list display in the admin
> site)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-

Jesús Lucas Flores
*Administrador de Sistemas y Programador Web*
*Linkedin: **www.linkedin.com/in/jesuslucas*
*Github:  **github.com/jelukas*
Twitter: @jelukas89 

-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django and Websockets

2013-07-04 Thread Nevio Vesic
This one as well works just fine :)
https://gevent-socketio.readthedocs.org/en/latest/ It's as well very easy
to implement it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Call action with a link in the admin site

2013-07-04 Thread Juan Antonio García Cano


In the admin.py i have this function:

actions = ['generar_pdf']
def generar_pdf(self, request, queryset):

... (This function make a PDF of the object selected)

And i show one button in the list_display (of the admin site) with this 
function:

def boton_mail(self,obj):
return mark_safe('http://mypage/static/admin/img/descargar_pdf.png; alt="Descargar PDF" 
width=30 height=25>')

It is posible to call the function "generar_pdf" with a link (< a >) in the 
function "boton_mail"?

(I want to call the action from a image in the list display in the admin 
site)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: problems with django-celery

2013-07-04 Thread Sachin Shenoy
Hi Mateusz,

Were you able to solve this? I am also facing the same issue.

Thanks,
Sachin


On Tuesday, March 26, 2013 4:35:41 PM UTC+5:30, Mateusz Iwański wrote:
>
> Hi,
>
> I have a problem with django-celery. When i want to delay function I get 
> an error from celery worker, it happens every second time when i want to 
> use it. 
>
> Error from celery worker:
>
> Can't decode message body: ImportError('No module named 
> manager.apps.ffmpeg.tasks',) (type:u'application/x-python-serialize' 
> encoding:u'binary' 
> raw:"'\\x80\\x02}q\\x01(U\\x07expiresq\\x02NU\\x03utcq\\x03\\x88U\\x04argsq\\x04cmanager.apps.ffmpeg.tasks\\nFfmpegTasks\\nq\\x05)\\x81q\\x06}q\\x07(U\\tfile_pathq\\x08X*\\x00\\x00\\x00/media/temp/video/2462009/8132009624142319U\\x02IDq\\tM\\x1eDU\\x0cvideo_objectq\\ncdjango.db.models.base\\nmodel_unpickle\\nq\\x0bcmanager.apps.manager.models\\nVideoContent\\nq\\x0c]cdjango.db.models.base\\nsimple_class_factory\\nq\\r\\x87Rq\\x0e}q\\x0f(U\\x08date_addq\\x10cdatetime\\ndatetime\\nq\\x11U\\n\\x07\\xd9\\x06\\x18\\x0e\\x17\\x00\\x00\\x00\\x00cpytz\\n_UTC\\nq\\x12)Rq\\x13\\x86Rq\\x14U\\x04busyq\\x15\\x89U\\x0bdescriptionq\\x16XF\\x00\\x00\\x00Spotkanie
>  
> z Wand? P\\xc3\\xb3?tawsk?, przyjaci\\xc3\\xb3?k? Jana Paw?a II cz??c 
> druga.U\\x0f_category_cacheq\\x17h\\x0bcmanager.apps.manager.models\\nVideoCategory\\nq\\x18]h\\r\\x87Rq\\x19}q\\x1a(U\\x06_stateq\\x1bcdjango.db.models.base\\nModelState\\nq\\x1c)\\x81q\\x1d}q\\x1e(U\\x06addingq\\x1f\\x89U\\x02dbq...
>  
> (1317b)"')
>
> I installed librabbitmq and worker after that give me an error:
>
> Can't decode message body: ImportError('No module named 
> manager.apps.ffmpeg.tasks',) (type:'application/x-python-serialize' 
> encoding:'binary' raw:' 0xa7af9e0> (1277b)'') 
>
> First time when i delay function everything is OK the second time I have 
> an error the third time work properly and so on.
>
> RabbitMQ 3.0.4
> Django 1.4.0
> Linux version 3.2.0-39-generic (buildd@aatxe) (gcc version 4.6.3 
> (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #62-Ubuntu SMP Wed Feb 27 22:05:17 UTC 2013
>
> celery report :
>
> software -> celery:3.0.17 (Chiastic Slide) kombu:2.5.8 py:2.7.3
> billiard:2.7.3.23 librabbitmq:1.0.1
> platform -> system:Linux arch:32bit, ELF imp:CPython
> loader   -> celery.loaders.default.Loader
> settings -> transport:librabbitmq results:disabled
>
> __class__: 
> __cmp__: 
> __contains__: 
> __delattr__: 
> __delitem__: 
> __doc__: "dict() -> new empty dictionary\ndict(mapping) -> new dictionary 
> initialized from a mapping object's\n(key, value) pairs\ndict(iterable) 
> -> new dictionary initialized as if via:\nd = {}\nfor k, v in 
> iterable:\nd[k] = v\ndict(**kwargs) -> new dictionary initialized 
> with the name=value pairs\nin the keyword argument list.  For example: 
>  dict(one=1, two=2)"
> __eq__: 
> __format__: 
> __ge__: 
> __getattribute__:  0xa6fa934>
> __getitem__: 
> __gt__: 
> __hash__: None
> __init__: 
> __iter__: 
> __le__: 
> __len__: 
> __lt__: 
> __ne__: 
> __new__: 
> __reduce__: 
> __reduce_ex__: 
> __repr__: 
> __setattr__: 
> __setitem__: 
> __sizeof__: 
> __str__: 
> __subclasshook__:  0x82bb380>
> clear: 
> copy: 
> fromkeys: 
> get: 
> has_key: 
> items: 
> iteritems: 
> iterkeys: 
> itervalues: 
> keys: 
> pop: 
> popitem: 
> setdefault: 
> update: 
> values: 
> viewitems: 
> viewkeys: 
> viewvalues: 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Django and Websockets

2013-07-04 Thread Dario Lopez Padial
Hi, I would like to use websockets in Django, but I have many options..

   - https://github.com/stephenmcd/django-socketio
   - https://github.com/clemesha/hotdot
   - https://github.com/gregmuellegger/django-websocket
   - tornado?
   
I do not worry to have 2 servers (django server and asynchronous server)

What I can do?

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with staticfiles

2013-07-04 Thread Andreas Kuhne
I found out that the CSS files where not correctly written and they should
have generated this error. Pity I have been searching for the problem for 2
days now :-)

Regards,

Andréas

2013/7/3 Andreas Kuhne 

> Hi all,
>
> I am trying to CachedStaticFilesStorage to work in our environment. I have
> been able to configure all of the settings, and am able to copy all static
> files (we have alot of them) to the correct location. However when the
> postprocessing starts and the MD5 hashes are being calculated it fails with
> an exception:
> ValueError: The file
> 'extjs/resources/css/images/default/editor/tb-sprite.gif' could not be
> found with  object at 0x146ee10>.
>
> This is because it is going through the css files trying to rewrite the
> url parts to add the MD5 hash. I have looked in the CSS files and all of
> the url calls are using relative paths, but it seems as though the rewrite
> process is forgetting to add the "../" part. The path that is in the error
> is a concatenation of the path where the CSS resides (extjs/resources/css)
> and the url (../images/default/editor), but it seems that the ../ is being
> omitted somehow. I have checked and tested the code for traversing the css
> files in a python shell and it works there. But it fails both on my
> development machine and the staging server.
>
> Has anyone had the same issues and knows what to do?
>
> Regards,
>
> Andréas
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django date format issue

2013-07-04 Thread Rafael E. Ferrero
form example:


class NewsForm(ModelForm):
class Meta:
model = News
exclude = ('id', 'Url', 'resume', 'Time_Stamp')
widgets = {
   'Tag': CheckboxSelectMultiple(attrs={'class': 'tag'}),
   'Category': CheckboxSelectMultiple(
attrs={'class':
'category'}),
   }


2013/7/4 Rafael E. Ferrero 

> I'm not shore if what i did its fine or not but works, otherwise i see you
> put some twist to the problem... nevertheless what i do its:
> In Settings set properly the time_zone and use_l10n=true... then in my
> model use something like ...models.DateTimeField('Creation Date',
> default=datetime.now())...
> then in templates use a filter like ...|date:"D d/m/Y"... to render the
> date in format "day-name" dd/mm/.
> In the form.py just use standard, exclude some fields, use some widget...
> but keep simplicity.
>
> hope to help you a little.
>
> Cheers
>
>
> 2013/7/4 Sivaram R 
>
>> views.py
>>
>> def calender(request):
>>
>> ""
>> settingsform = SettingsForm(instance=settings)
>> if request.method == 'POST':
>> reportform = ReportDateTimeForm(request.POST, instance=report)
>> if reportform.is_valid():
>> report = reportform.save(commit=False)
>> report.user = request.user
>> report.save()
>> if settings and settings.date_format:
>> date = 
>> report.manual_date.strftime(reportform.fields['manual_date'].input_formats[1])
>> createddate = report.created_date_time.strftime('%b %d %Y')
>> else:
>> date = 
>> report.manual_date.strftime(reportform.fields['manual_date'].input_formats[0])
>> createddate = report.created_date_time.strftime('%d %b %Y')
>> ""
>> return render_to_response('calender.html',
>>{
>> 'reportform': reportform,
>> 'settings': settings,
>> 'settingsform':settingsform
>>  },
>>  context_instance=RequestContext(request))
>>
>> forms.py
>>
>> DATE_FORMAT = (
>> ('0', ' dd / mm / '),
>> ('1', 'mm / dd / '),)
>> DATE_INPUT_FORMAT = ['%d/%m/%Y','%m/%d/%Y']
>> class ReportDateTimeForm(forms.ModelForm):
>> manual_date = forms.DateField(input_formats = DATE_INPUT_FORMAT,
>>   widget=forms.DateInput(format = '%d/%m/%Y'))
>> class SettingsForm(forms.ModelForm):
>> date_format = forms.ChoiceField(widget=forms.RadioSelect(), 
>> choices=DATE_FORMAT, initial='0')
>>
>>
>>   views.py
>>
>> def calender(request):
>>
>> ""
>> settingsform = SettingsForm(instance=settings)
>> if request.method == 'POST':
>> reportform = ReportDateTimeForm(request.POST, instance=report)
>> if reportform.is_valid():
>> report = reportform.save(commit=False)
>> report.user = request.user
>> report.save()
>> if settings and settings.date_format:
>> date = 
>> report.manual_date.strftime(reportform.fields['manual_date'].input_formats[1])
>> createddate = report.created_date_time.strftime('%b %d %Y')
>> else:
>> date = 
>> report.manual_date.strftime(reportform.fields['manual_date'].input_formats[0])
>> createddate = report.created_date_time.strftime('%d %b %Y')
>> ""
>> return render_to_response('calender.html',
>>{
>> 'reportform': reportform,
>> 'settings': settings,
>> 'settingsform':settingsform
>>  },
>>  context_instance=RequestContext(request))
>>
>> forms.py
>>
>> DATE_FORMAT = (
>> ('0', ' dd / mm / '),
>> ('1', 'mm / dd / '),)
>> DATE_INPUT_FORMAT = ['%d/%m/%Y','%m/%d/%Y']
>> class ReportDateTimeForm(forms.ModelForm):
>> manual_date = forms.DateField(input_formats = DATE_INPUT_FORMAT,
>>   widget=forms.DateInput(format = '%d/%m/%Y'))
>> class SettingsForm(forms.ModelForm):
>> date_format = forms.ChoiceField(widget=forms.RadioSelect(), 
>> choices=DATE_FORMAT, initial='0')
>>
>> If no values are saved in settings table,it is showing the default date
>> format.If any value is saved eg:if the selecetd format is dd/mm/ in
>> db it is saved as 0.But in calender page it is displayed as 
>> mm/dd/format,it is showing
>> mm/dd/ format for both date format,it seems like for default it is
>> showing the correct format,if any values are saved it is always showing
>> this format mm/dd/
>>
>> Any help is greatly appreciated.
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe 

Re: Django date format issue

2013-07-04 Thread Rafael E. Ferrero
I'm not shore if what i did its fine or not but works, otherwise i see you
put some twist to the problem... nevertheless what i do its:
In Settings set properly the time_zone and use_l10n=true... then in my
model use something like ...models.DateTimeField('Creation Date',
default=datetime.now())...
then in templates use a filter like ...|date:"D d/m/Y"... to render the
date in format "day-name" dd/mm/.
In the form.py just use standard, exclude some fields, use some widget...
but keep simplicity.

hope to help you a little.

Cheers


2013/7/4 Sivaram R 

> views.py
>
> def calender(request):
>
> ""
> settingsform = SettingsForm(instance=settings)
> if request.method == 'POST':
> reportform = ReportDateTimeForm(request.POST, instance=report)
> if reportform.is_valid():
> report = reportform.save(commit=False)
> report.user = request.user
> report.save()
> if settings and settings.date_format:
> date = 
> report.manual_date.strftime(reportform.fields['manual_date'].input_formats[1])
> createddate = report.created_date_time.strftime('%b %d %Y')
> else:
> date = 
> report.manual_date.strftime(reportform.fields['manual_date'].input_formats[0])
> createddate = report.created_date_time.strftime('%d %b %Y')
> ""
> return render_to_response('calender.html',
>{
> 'reportform': reportform,
> 'settings': settings,
> 'settingsform':settingsform
>  },
>  context_instance=RequestContext(request))
>
> forms.py
>
> DATE_FORMAT = (
> ('0', ' dd / mm / '),
> ('1', 'mm / dd / '),)
> DATE_INPUT_FORMAT = ['%d/%m/%Y','%m/%d/%Y']
> class ReportDateTimeForm(forms.ModelForm):
> manual_date = forms.DateField(input_formats = DATE_INPUT_FORMAT,
>   widget=forms.DateInput(format = '%d/%m/%Y'))
> class SettingsForm(forms.ModelForm):
> date_format = forms.ChoiceField(widget=forms.RadioSelect(), 
> choices=DATE_FORMAT, initial='0')
>
>
>   views.py
>
> def calender(request):
>
> ""
> settingsform = SettingsForm(instance=settings)
> if request.method == 'POST':
> reportform = ReportDateTimeForm(request.POST, instance=report)
> if reportform.is_valid():
> report = reportform.save(commit=False)
> report.user = request.user
> report.save()
> if settings and settings.date_format:
> date = 
> report.manual_date.strftime(reportform.fields['manual_date'].input_formats[1])
> createddate = report.created_date_time.strftime('%b %d %Y')
> else:
> date = 
> report.manual_date.strftime(reportform.fields['manual_date'].input_formats[0])
> createddate = report.created_date_time.strftime('%d %b %Y')
> ""
> return render_to_response('calender.html',
>{
> 'reportform': reportform,
> 'settings': settings,
> 'settingsform':settingsform
>  },
>  context_instance=RequestContext(request))
>
> forms.py
>
> DATE_FORMAT = (
> ('0', ' dd / mm / '),
> ('1', 'mm / dd / '),)
> DATE_INPUT_FORMAT = ['%d/%m/%Y','%m/%d/%Y']
> class ReportDateTimeForm(forms.ModelForm):
> manual_date = forms.DateField(input_formats = DATE_INPUT_FORMAT,
>   widget=forms.DateInput(format = '%d/%m/%Y'))
> class SettingsForm(forms.ModelForm):
> date_format = forms.ChoiceField(widget=forms.RadioSelect(), 
> choices=DATE_FORMAT, initial='0')
>
> If no values are saved in settings table,it is showing the default date
> format.If any value is saved eg:if the selecetd format is dd/mm/ in
> db it is saved as 0.But in calender page it is displayed as 
> mm/dd/format,it is showing
> mm/dd/ format for both date format,it seems like for default it is
> showing the correct format,if any values are saved it is always showing
> this format mm/dd/
>
> Any help is greatly appreciated.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

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

Django date format issue

2013-07-04 Thread Sivaram R
views.py

def calender(request):

""
settingsform = SettingsForm(instance=settings)
if request.method == 'POST':
reportform = ReportDateTimeForm(request.POST, instance=report)
if reportform.is_valid():
report = reportform.save(commit=False)
report.user = request.user
report.save()
if settings and settings.date_format:
date = 
report.manual_date.strftime(reportform.fields['manual_date'].input_formats[1])
createddate = report.created_date_time.strftime('%b %d %Y')
else:
date = 
report.manual_date.strftime(reportform.fields['manual_date'].input_formats[0])
createddate = report.created_date_time.strftime('%d %b %Y')
"" 
return render_to_response('calender.html',
   {
'reportform': reportform,
'settings': settings,
'settingsform':settingsform
 },
 context_instance=RequestContext(request))

forms.py

DATE_FORMAT = (
('0', ' dd / mm / '),
('1', 'mm / dd / '),)
DATE_INPUT_FORMAT = ['%d/%m/%Y','%m/%d/%Y']
class ReportDateTimeForm(forms.ModelForm):
manual_date = forms.DateField(input_formats = DATE_INPUT_FORMAT,
  widget=forms.DateInput(format = '%d/%m/%Y'))
class SettingsForm(forms.ModelForm):
date_format = forms.ChoiceField(widget=forms.RadioSelect(), 
choices=DATE_FORMAT, initial='0')

 
  views.py

def calender(request):

""
settingsform = SettingsForm(instance=settings)
if request.method == 'POST':
reportform = ReportDateTimeForm(request.POST, instance=report)
if reportform.is_valid():
report = reportform.save(commit=False)
report.user = request.user
report.save()
if settings and settings.date_format:
date = 
report.manual_date.strftime(reportform.fields['manual_date'].input_formats[1])
createddate = report.created_date_time.strftime('%b %d %Y')
else:
date = 
report.manual_date.strftime(reportform.fields['manual_date'].input_formats[0])
createddate = report.created_date_time.strftime('%d %b %Y')
"" 
return render_to_response('calender.html',
   {
'reportform': reportform,
'settings': settings,
'settingsform':settingsform
 },
 context_instance=RequestContext(request))

forms.py

DATE_FORMAT = (
('0', ' dd / mm / '),
('1', 'mm / dd / '),)
DATE_INPUT_FORMAT = ['%d/%m/%Y','%m/%d/%Y']
class ReportDateTimeForm(forms.ModelForm):
manual_date = forms.DateField(input_formats = DATE_INPUT_FORMAT,
  widget=forms.DateInput(format = '%d/%m/%Y'))
class SettingsForm(forms.ModelForm):
date_format = forms.ChoiceField(widget=forms.RadioSelect(), 
choices=DATE_FORMAT, initial='0')

If no values are saved in settings table,it is showing the default date 
format.If any value is saved eg:if the selecetd format is dd/mm/ in db 
it is saved as 0.But in calender page it is displayed as mm/dd/format,it is 
showing 
mm/dd/ format for both date format,it seems like for default it is 
showing the correct format,if any values are saved it is always showing 
this format mm/dd/

Any help is greatly appreciated.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django admin automatically adding slash to a URL field after update

2013-07-04 Thread Rafael E. Ferrero
I never have that issue, i use default setting of append_slash and never
have a problem with that. (version 1.3)


2013/7/4 Rafael E. Ferrero 

> What version of Django you use ??
>
>
> 2013/7/4 ecasbas 
>
>> Hi,
>>
>> I have this issue wit the admin interface:
>>
>> I try edit manually a register, I change some values and when I save the
>> data, the URL field, which I have no modifed,
>> become automatically with a slash append at the end. This issue is
>> causing inconsistencies due to I normalize each
>> URL before save to BBDD, but when I modify manually some register, then
>> the problem.
>>
>> I tried the advice from:
>> https://docs.djangoproject.com/en/dev/ref/middleware/
>> APPEND_SLASH = False
>>
>> but without success, any hints?
>>
>> TIA
>> Emilio
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Rafael E. Ferrero
> Claro: (03562) 15514856
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django admin automatically adding slash to a URL field after update

2013-07-04 Thread Rafael E. Ferrero
What version of Django you use ??


2013/7/4 ecasbas 

> Hi,
>
> I have this issue wit the admin interface:
>
> I try edit manually a register, I change some values and when I save the
> data, the URL field, which I have no modifed,
> become automatically with a slash append at the end. This issue is causing
> inconsistencies due to I normalize each
> URL before save to BBDD, but when I modify manually some register, then
> the problem.
>
> I tried the advice from:
> https://docs.djangoproject.com/en/dev/ref/middleware/
> APPEND_SLASH = False
>
> but without success, any hints?
>
> TIA
> Emilio
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-simple-multitenant

2013-07-04 Thread Nigel Legg
That's great, thanks Mario.  I will see how I get on with implementing it.
Thanks for your help.
N//

Regards,
Nigel Legg
07914 740972
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 4 July 2013 11:39, Mario Gudelj  wrote:

> You sure can Nigel.
>
> Let's say you have a model called Notes, where users can enter their notes
> that they only can see.
>
> You add User model (in 1.4 from django.contrib.auth.models, in 1.5 same or
> you can extend AbstractUser) as a foreign key to Notices.
>
> Here's some info on FK
> https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey
>
> When the user logs in you can obtain that user from "request.user", so
> when they create a Notice you save the user as a foreign key against the
> Notice.
>
> Then, when you're displaying the notices you simply use that in your
> queries e.g. Notice.objects.filter(user=request.user)
>
> I hope that makes sense.
>
> _M
>
>
>
>
> On 4 July 2013 15:59, Nigel Legg  wrote:
>
>> Mario, I am not sure what you mean here.  I want users to be able to
>> upload data to the site, and do various things with it. I want each user to
>> only see the data they have uploaded.  Whether this is
>> domain.com/uer_account or user_account.domain.com I don't know, so long
>> as it provides the functionality I need. If I use the
>> domain,com/user_account, can I do that with the standard django auth system?
>>
>> Regards,
>> Nigel Legg
>> 07914 740972
>> http://twitter.com/nigellegg
>> http://uk.linkedin.com/in/nigellegg
>>
>>
>>
>> On 4 July 2013 00:36, Mario Gudelj  wrote:
>>
>>> Depends what you need. Do you want to have users access data via
>>> www.domain.com/user_acccount/ or http://user_account.domain.com? If
>>> it's www.domain.com/user_acccount/ just foreign key your models to user
>>> model and in your queries always include user as a filter. The other option
>>> is somewhat harder.
>>>
>>> Cheers,
>>>
>>> _M
>>>
>>>
>>> On 3 July 2013 22:20, Nigel Legg  wrote:
>>>
 I am building an app to, among other things, allow people to upload
 data files and carry out various analyses online.  I would like each user
 to only see the datafiles that they or members of their team (company,
 research team, etc) have uploaded.
 It seems that 
 django-simple-multitenantwould
  be appropriate for this.  Are there any problems in using this, or
 other apps that would be easier to implement?
 Cheers N//

 Regards,
 Nigel Legg
 07914 740972
 http://twitter.com/nigellegg
 http://uk.linkedin.com/in/nigellegg

  --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To post to this group, send email to django-users@googlegroups.com.
 Visit this group at http://groups.google.com/group/django-users.
 For more options, visit https://groups.google.com/groups/opt_out.



>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit 

Re: django-simple-multitenant

2013-07-04 Thread Mario Gudelj
You sure can Nigel.

Let's say you have a model called Notes, where users can enter their notes
that they only can see.

You add User model (in 1.4 from django.contrib.auth.models, in 1.5 same or
you can extend AbstractUser) as a foreign key to Notices.

Here's some info on FK
https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey

When the user logs in you can obtain that user from "request.user", so when
they create a Notice you save the user as a foreign key against the Notice.

Then, when you're displaying the notices you simply use that in your
queries e.g. Notice.objects.filter(user=request.user)

I hope that makes sense.

_M




On 4 July 2013 15:59, Nigel Legg  wrote:

> Mario, I am not sure what you mean here.  I want users to be able to
> upload data to the site, and do various things with it. I want each user to
> only see the data they have uploaded.  Whether this is
> domain.com/uer_account or user_account.domain.com I don't know, so long
> as it provides the functionality I need. If I use the
> domain,com/user_account, can I do that with the standard django auth system?
>
> Regards,
> Nigel Legg
> 07914 740972
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>
>
> On 4 July 2013 00:36, Mario Gudelj  wrote:
>
>> Depends what you need. Do you want to have users access data via
>> www.domain.com/user_acccount/ or http://user_account.domain.com? If it's
>> www.domain.com/user_acccount/ just foreign key your models to user model
>> and in your queries always include user as a filter. The other option is
>> somewhat harder.
>>
>> Cheers,
>>
>> _M
>>
>>
>> On 3 July 2013 22:20, Nigel Legg  wrote:
>>
>>> I am building an app to, among other things, allow people to upload data
>>> files and carry out various analyses online.  I would like each user to
>>> only see the datafiles that they or members of their team (company,
>>> research team, etc) have uploaded.
>>> It seems that 
>>> django-simple-multitenantwould
>>>  be appropriate for this.  Are there any problems in using this, or
>>> other apps that would be easier to implement?
>>> Cheers N//
>>>
>>> Regards,
>>> Nigel Legg
>>> 07914 740972
>>> http://twitter.com/nigellegg
>>> http://uk.linkedin.com/in/nigellegg
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Python Fabric manage.py problem

2013-07-04 Thread Tom Evans
On Thu, Jul 4, 2013 at 3:29 AM, Roger Barnes  wrote:
> It looks like you may be missing a space after the word "source".
>
> My fabfile has these helpers, given an env.virtualenv and env.app_dir
> setting...

Another way to do it is to provide a shell script that sets up the
appropriate environment and then executes "python manage.py". Eg
(manage.sh):

#!/bin/sh
cd /path/to/project
source /path/to/activate
python manage.py "$@"

and then

sudo('/path/to/manage.sh syncdb', user='www')


Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




calling single save function on two button click

2013-07-04 Thread Sivaram R
who.html

 {% csrf_token %}
  


{{report_person.report_person.name }}

 
{{report_person.info.first_aid}}{{report_person.info.first_aid.label}}


{{report_person.info.sick_bay}}{{report_person.info.sick_bay.label}}

  
{% if report_person.info.first_aid.value or 
report_person.info.sick_bay.value %}

{%else%}

{%endif%}

Add treatment notes




Inside this div  a save button which on click submit the 
"treatment-form" form.This div is basically hidden,if user press Add 
treatment notes button,the div gets open and details can be updated and by 
clicking save the form gets submited.

Since i am doing the save operation inside a ,if the user click first_aid 
alone and click next button it wont save.

I placed the same javascript onclick to submit the "treatment-form" form in 
next button.But my problem is if the  is in open condition the check 
box gets saved ,otherwise if user clickfirst_aid alone and without clicking Add 
treatment notes button, if they click next it is not saving.

see my both buttons:

Save   
//button inside the div

Next  //next button to perform save without opening the 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-simple-multitenant

2013-07-04 Thread Nigel Legg
Mario, I am not sure what you mean here.  I want users to be able to upload
data to the site, and do various things with it. I want each user to only
see the data they have uploaded.  Whether this is domain.com/uer_account or
user_account.domain.com I don't know, so long as it provides the
functionality I need. If I use the domain,com/user_account, can I do that
with the standard django auth system?

Regards,
Nigel Legg
07914 740972
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 4 July 2013 00:36, Mario Gudelj  wrote:

> Depends what you need. Do you want to have users access data via
> www.domain.com/user_acccount/ or http://user_account.domain.com? If it's
> www.domain.com/user_acccount/ just foreign key your models to user model
> and in your queries always include user as a filter. The other option is
> somewhat harder.
>
> Cheers,
>
> _M
>
>
> On 3 July 2013 22:20, Nigel Legg  wrote:
>
>> I am building an app to, among other things, allow people to upload data
>> files and carry out various analyses online.  I would like each user to
>> only see the datafiles that they or members of their team (company,
>> research team, etc) have uploaded.
>> It seems that 
>> django-simple-multitenantwould
>>  be appropriate for this.  Are there any problems in using this, or
>> other apps that would be easier to implement?
>> Cheers N//
>>
>> Regards,
>> Nigel Legg
>> 07914 740972
>> http://twitter.com/nigellegg
>> http://uk.linkedin.com/in/nigellegg
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.