django

Programattically populate sample data for Django Image/File fields?

I need to populate sample data for Django Image/File fields in automated python code. I want to initialize Django ImageFields and FileFields with some sample images and data files that are stored in my "site_media" directory of my Django project. What would the code look like? This is not for testing, I want to autopopulate sample dat...

modelform fails is_valid w/o setting form.errors

I'm using a modelform to display only a subset of the fields in the model. When the form is submitted it fails form.is_valid() but form.errors is empty. I'd rather not display all my code here, but below is a sample: Model and Form class Videofiles(models.Model): active = models.CharField(max_length=9) filenamebase = models.Cha...

How to properly columnize tables in a Django template.

I am currently trying to break a list of people (aprox 20 to 30 items) into a table with 4 columns. Here is my current code. <table> {% for person in people %} {% cycle "<tr><td>" "<td>" "<td>" "<td>" %} {{ person }} {% cycle "</td>" "</td>" "</td>" "</td></tr>" %} {% endfor %} </table> Obviously, this is pretty ugly, ...

Facebook login for django-socialregistration giving 500 error

I've installed django-socialregistration and the facebook-python-sdk dependency. Ran syncdb (so all the tables are there). I see the Facebook Connect button and when I click on it, I see the FB popup to give permission to my site. However, after that, it goes to www.mysite.com/socialregistration/facebook/login with a 500 Internal Server...

Django redirect url parsed as a query string in firefox

Hi, I'm trying to create a filtered FAQ page in Django. It filters by three categories, and defaults to 'all' for all three when someone hits the root URL. From urls.py: keywords = ('key1','key2','key3') searchurl = r'^category1/(?P<%s>\w{1,50})/category2/(?P<%s>\w{1,50})/category3/(?P<%s>\w{1,50})/$' % keywords searchall = dict(zip(ke...

Really weird Cookie header behaviour? - Cookies

Hi folks, I'm using Firefox 3.6.8 for these tests. I'm setting a cookie within the response headers of my web app using: Set-Cookie: session=7878dfdsfjsdf89sd89f8df9 This does not seem to override the session Cookie. When a request is performed instead Firefox even sends duplicate cookies: Cookie: session=7d75cd8f55895cbccb0d31e...

How to modify django cms multilingual middleware

hey guys, im trying to internationalize my site, so i have the django cms multilingual middleware class in my settings.py , when viewed from brasil, the url changes to www.ashtangayogavideo.com/pt/ash/homepage/ resulting in a 404, because my site is in www.ashtangayogavideo.com/ash/en/homepage, how can i configure the middleware, or sett...

Django standalone run in cron

I want to run automatic newsletter function in my crontab, but no matter what I try - I cannot make it work. What is the proper method for doing this ? This is my crontab entry : 0 */2 * * * PYTHONPATH=/home/muntu/rails python2.6 /home/muntu/rails/project/newsletter.py And the newsletter.py file, which is located in the top folder of ...

Django forms, saving non-user submitted data

class SomeModel(models.Model): text = models.TextField() ip = models.IPAddressField() created_on = models.DateTimeField() updated_on = models.DateTimeField() Say I have that as a model, what if I wanted to only display 'text' field widget for the user to submit data, but I obviously wouldn't want the user to see the...

How do I detect if a formset has any errors at all in a template?

Thanks to the fantastic inline model formsets in django I have a pretty advanced form with 4 inline formsets. In the template I display each formset in a tab. Everything works really slick but I would like to color a tab red if the formset in that tab has any validation errors at all. So I tried this: <div id="tabs"> <ul> <l...

additional conditions on join in django

Is it possible to add an additional condition to join statement created by django ORM? What I need in SQL is 'SELECT "post"."id", COUNT("watchlist"."id") FROM "post" LEFT OUTER JOIN "watchlist" ON ("post"."id" = "watchlist"."post_id" AND "watchlist"."user_id" = 1) WHERE "post"."id" = 123 GROUP BY … In django most of this is...

Why I'm getting "No fixtures found." when I run "python manage.py syncdb" command?

C:\mysite>python manage.py syncdb Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating table auth_message Creating table django_content_type Creating table django_session Creating table dja...

Pass a list of items via URL to a view

I have a list of items that looks like this: 'Item 1', 'Item 2', 'Item 3'... with the list being dynamic in length. My question is how can I pass this variable to my view? Edit 1 Just thought I'd clarify what I was attempting: return HttpResponseRedirect(reverse('newFeatures', kwargs={'stock_number': stock_number, 'new_feature...

How to make Django's devserver public ? Is it generaly possible ?

Hello, Experts I've got a question. I'm currently trying out the Django framework and I would share/present/show some stuff I've made to my workmate/friends. I work in Ubuntu under Win7 via VMware. So my wish/desire is to send my current pub-IP with port (e.g http://123.123.123.123:8181/django-app/) to my friends so they could test it....

Object_list always empty

Hi , the app is working this way. That i have a simple news adding model as below: class News(models.Model): title = models.CharField(max_length=100) publication_date = models.DateField(auto_now_add=True) content = models.TextField() the view def homepage(request): posts= News.objects.all() #.get(title="aaa") retu...

Making text bold with django

I have to send make some text bold in between plain text and send it to the template from the view. I do this: I save a string like this <b>TextPlaintext</b> in a variable and return it to the template. The "<b>" tags are not interpreted. How can make some text bold in a django view? ...

Django: How to completely uninstall a Django app?

What is the procedure for completely uninstalling a Django app, complete with database removal? ...

url() in Pinax Project

I cloned the basic_project in Pinax and created a new app in the apps folder. I then created a urls.py in the app. I changed the main urls.py file to: (r'^newpage/', include('newapp.urls')), However, in the newapp urls.py i need to use this url() in my patterns. Why cant I leave it out? ...

Django, PayPal IPNs & User Names - concept issues

I'm trying to sell virtual goods using PayPal (already implemented Zong+) in Django. I decided to use django-paypal to handle the IPN for me (decided that IPN was the best fully automated option.) I've currently made a buy-now button using the PayPal button wizard on their website, ie it's secure and saved on paypal to protect against t...

Various queries - MongoDB

Hi folks, This is my table: unicorns = {'name':'George', 'actions':[{'action':'jump', 'time':123123}, {'action':'run', 'time':345345}, ...]} How can I perform the following queries? Grab the time of all actions of all unicorns where action=='jump' ? Grab all actions of...