django

django string format

If I want to insert a variable %s into this <p><img src= %s alt="tetris"/></p> I have the problem that if I use "%s", it wont recognize it as the placholder it is. But if just use %s it wont link to my image. Is there a way around this? I tried to insert the url that is inserted there like this in the database ''/url/''. But that wo...

Changing the encoding of a table with django+south migrations

Hi Guys, Django and south newbie here I need to change the encoding of a table I created, does anyone know a way to do so using a migration? ...

Finding the user who uses my django web application

I have developed a small django web application. It still runs in the django development web server. It has been decided that if more than 'n' number of users like the application, it will be approved. I want to find out all the users who view my application. How can find the user who views my application? Since I was the user who ran ...

Django - Limit users who view the items

My Models: class PromoNotification(models.Model): title = models.CharField(_('Title'), max_length=200) content = models.TextField(_('Content')) users = models.ManyToManyField(User, blank=True, null=True) groups = models.ManyToManyField(Group, blank=True, null=True) I want to publish there items to templates with some p...

Display unescaped HTML String in Django Admin change list

Hey Guys! I am currently facing a serious problem. I use the standard django admin interface incl. change list to display one of my models. The model has got a field, which includes a link (e.g. in database: link). What I want now is that this string is rendered unescaped and displayed as link. I already tried the following in "change_...

django subquery via orm

I have models: class Site(models.Model): profile = models.ForeignKey(User) class Profile(models.Model): blacklist = models.ManyToManyField(Site) How can i do equivalent of this query via django orm? SELECT * FROM site WHERE 2 NOT IN (SELECT site_id FROM profile_blacklist WHERE profile_site.profile_id=site.profile_id) I nee...

Execute raw SQL after connect to database

How can I execute raw SQL after connect to database? I need to run script once, after connect to DB. Thanks. UPD: question is not how to run raw SQL. ...

problem using WSGIApplicationGroup %{GLOBAL} in apache configuration

hi all im using django with apache and mod_wsgi i am facing a problem when i use WSGIApplicationGroup %{GLOBAL} in apache configuration file (.conf) . i dont know if i am using this directive correctly or i need to use it in another way , the problem is that i needed to add this directive to fix a problem for xapian as described in thi...

Django from Java developer perspective

Hey, I'm a long time Java programmer and I'm digging into Django recently to see what it offers. It looks to me that Django doesn't fit Java web developers taste. I mean in MVC Java web frameworks we have usually a controller class that receives the request, do the logic and then forwards the request to another destination. Rails als...

Widget filling values in two fields

I know that if I need a custom "selector" for a field in django-admin I need to create a custom widget. But what if the widget have to produce two values, for example X and Y coordinates, how can I fill them in two different fields from the model? ...

Implementing workflows in Django Admin - Django

Hi folks, I have a nice admin panel setup so users can manage the data within the site. Problem is that I need to implement a workflow, so saved models can be approved from and to various stages, to then be finally published. As the model in question is just one, I thougth of adding a boolean 'approved_for_publishing' field and a 'a...

django executing common action for all the admin forms

I use fileSystem caching in my django application what I need is to clear the cache after any action(adding or editing or deleting) taken by the admin is there any way to get an action (clearing the cache) to be executed after all the submission of any form in the admin site? ...

"AttributeError: 'module' object has no attribute '__getstate__' " shows up when I use easy_install

For some reason, every time I attempt to install a new module using easy_install, I'm getting the error: AttributeError: 'module' object has no attribute '__getstate__' I'm using setuptools-0.6c11-py2.6 ...

How to make a Django passthrough view?

I want to make a Django view that does the following: Receive an HttpRequest on api/some/url/or/other Passes this through to another server at some/url/or/other (rewrite the URL, basically) Adding a cookie based on session data in Django Using the same method, data, params, et al, that were in the original request Returns verbatim th...

Django Queryset Filter (Maybe Needs a Subquery)

I want to generate a queryset to find mismatches. As an example class Vehicle(models.Model): car = models.CharField(max_length=100) model= models.CharField(max_length=100) passengers = models.IntegerField() i want to generate a query where i can find cars erroneously listed with two different models. something along th...

Using Django Flatpages in production: how to archive changes for recovery purposes

I am using Django Flatpages in a production site. I'd like to figure out the best way to make sure if an admin makes a mistake editing a file, old version of the page can be retrieved. We have backups and such, but that's a bit more cumbersome to recover from (i.e. involves sysadmin, not website editor). First, is there a package that d...

Move to 2 Django physical servers (front and backend) from a single production server?

I currently have a growing Django production server that has all of the front end and backend services running on it. I could keep growing that server larger and larger, but instead I want to try and leave that main server as my backend server and create multiple front end servers that would run apache/nginx and remotely connect to the ...

Django - How can I save users ipaddress in admin log?

Hi, I am using django auth module.Now,when user logs in I want to record users ipaddress in the admin_log table.How can I do this? thanks ...

csrf_token cookie deleted by another site?

I have a django site running on 1.2.1, and once in a while my users lose a lot of work because the csrf_token cookie does not exist and the page errors out with a 403 error on post. I narrowed this down to another site (that my users frequent) deleting the cookie on me. The site does this with the ActiveX ClearAuthenticationCache command...

Couple of questions on django

1) I am using a middleware to log users ipaddress,but this should happen only once,and also only after user is authenticated.How can I do this? 2)In my application,I have login for users which is different from admin login.Now,when admin clicks logout,he is directed to users login page.But,I want to direct to admin login page.How can I ...