django

Django: Using django.contrib.auth for SAAS ( Users, permissions, etc. )

I'm making a SAAS and I've been asking a slew of questions on here related to the Auth system built in. I'm having trouble understanding the "why" and "how". Primarily I don't understand how it fits in with my SAAS. I (do) know the following: You can do this: http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-informa...

How to return static files passing through a view in django ?

I need to return css files and js files according to specific logic. Clearly, static serve does not perform what I need. I have a view, whose render method uses logic to find the proper file, but then I have to return it. Technically, I can just read the file and stuff it into a HttpResponse object with the proper mime type, but I was wo...

how do i get the username who login use openid ,i use django,pinax

1. 2 3. in this example,my username is zjm1126 ,and my email is [email protected], i want to get this. and this is my django-plug-in in this project: ...

Basic Django - How do view wrappers receive the request, keyword and positional arguments?

In chapter 8 of the Django book there is an example showing a fundamental view wrap method, which receives another view method passed in from any single arbitrary URLconf: def requires_login(view): def new_view(request, *args, **kwargs): if not request.user.is_authenticated(): return HttpResponseRedirect('/accoun...

extending urlize in django

the urlize function from django.utils.html converts urls to clickable links. My problem is that I want to append a target="_blank" into the "< href..>", so that I open this link in a new tab. Is there any way that I can extend the urlize function to receive an extra argument? or should I make a custom filter using regexes to do this stuf...

Regex for Time Format

Regex needed for a time of the format: 12-02-30T00:59:43. Also, I've not managed to find any decent websites or books that contain good explanations or reference material for regular expressions. Can anyone recommend any? ...

How to run a piece of code in every view in django?

Hello there! I need to check user authorization in every view of one of my Django apps (I don't use Django's built in auth system) and redirect user to a "login please" page, if authorization has failed. Code looks like this: try: admin_from_session = request.session['admin']; admin = Administrator.objects.get(login = admin_fr...

Send mail/save draft from Django admin

Hi everybody, I wonder if there is a way to override Django admin's submit_line buttons for a specific model, so that instead of showing the save & save and add another options they show send mail or save draft and actually work... Thanks a million! ...

JNDI Access from a Django app on Jython

Is it possible to access a JNDI value from Tomcat's config from a Django app running on Jython? My config has a web service URL, accessible via JDNI, that I need to get into the Django App at runtime. It's not a database connection, it's just the URL to a web service deployment. It might or might not be on the same Tomcat instance. ...

Production-ready PayPal, 2CO and Authorize.Net libraries for Python/Django?

Seems that Python lacks e-commerce solutions compared to PHP and C#. Any production-ready PayPal, 2CO and Authorize.Net libraries for Python/Django? EDIT: http://github.com/johnboxall/django-paypal http://www.djangosnippets.org/snippets/969/ E-commerce: http://www.satchmoproject.com/ http://code.activestate.com/recipes/456361/ http://...

Anonymous user in Django

How can I just enable anonymous user in Django? I mean, what is the minimum I should do to be logged in as anonymous first time I go to my site? Regards, Arshavski Alexander. ...

django apps for changing user email with verification ?

Hello, I already use django-registration : you can register with an email verification, you can reset password with an email confirmation but there is no way to change user's email with an email verification. Do you know a django application which gives the ability to change user's email address by sending to the new address a verifica...

Django(postgresql) + lighttpd. Any issues with threading and python's postgresql driver?

I'd like to deploy my Django app (which uses postgresql as database) on lighttpd using FastCGI. For postgresql i see that Django has 2 backends available 'postgresql_psycopg2' and 'postgresql'. My question is that lighttpd being a threaded server are there any issues with any of this backends? Are they thread safe? And which one of them ...

How do I prevent permission escalation in Django admin when granting "user change" permission?

I have a django site with a large customer base. I would like to give our customer service department the ability to alter normal user accounts, doing things like changing passwords, email addresses, etc. However, if I grant someone the built-in auth | user | Can change user permission, they gain the ability to set the is_superuser flag ...

How to begin learning CakePHP or any other MVC framework

I want to learn some MVC framework. I am trying to learn CakePHP by reading the docs on their website. But I am finding it very difficult to learn it. Can someone suggest a good way to begin learning CakePHP and provide some alternative websites? ...

Server-side highscores for a Javascript-written game

I'm implementing a simple game in Javascript, and am interested in having an online highscores table for it, so that players can compete against one another. I've two concerns about this: What is the simplest server-side program I need for this purpose? I don't need a full-fledged "web application", just something simple that gets POST...

Django unique_together for on sub-class model for parent attribute?

In this: class Administrator(models.Model): user = models.OneToOneField(User, primary_key=True) account = models.ForeignKey(Account) class Meta: unique_together = (('account', 'self.user.username'),) The self.user.username part is obviously incorrrect. However, in this: class Administrator(User): account = mo...

Django Forms with get_or_create

Hi I am using Django ModelForms to create a form. I have my form set up and it is working ok. form = MyForm(data=request.POST) if form.is_valid(): form.save() What I now want though is for the form to check first to see if an identical record exists. If it does I want it to get the id of that object and if not I want it to in...

Complex query in django

Hay, i have a quite complex query i cant get working in django. My model is called Car(), and i want to perform this query on it query = "SELECT *, ((ACOS(SIN("+user_lat+" * PI() / 180) * SIN(lat * PI() / 180) + COS("+user_lat+" * PI() / 180) * COS(lat * PI() / 180) * COS(("+user_lon+" - lon) * PI() / 180)) * 180 / PI()) * 60 * 1.1515)...

Writing better code for session variable check from render_to_response

Is this the most efficient and clean way to check the sessions for a username variable and output (depending on whether or not it is there) either "You are logged in." or "You are logged out."? PYTHON (DJANGO) def logged_in(request) return render_to_response('loggedincheck.html', {'request': request.session.get['username']}) HTML...