django

django: trying to access my robots.txt: "TypeError at /robots.txt 'str' object is not callable"

Exception Type: TypeError at /robots.txt Exception Value: 'str' object is not callable What gives? Views: ROBOTS_PATH = os.path.join(CURRENT_PATH, 'robots.txt') def robots(request): """ view for robots.txt file """ return HttpResponse(open(ROBOTS_PATH).read(), 'text/plain') Settings: CURRENT_PATH = os.path.abspath(os.path.dirnam...

Any django\php cms for Deviantart\Flickr - like sites?

Any django\php cms for Deviantart\Flickr - like sites? I know that drupal can handle it with a lot of modules and customization.. Maybe PhpFox..but it's not free. And from django good solution is Pinax.. Any advices will be appreciated! ...

Automatic spam filtering or flagging for Django or Python?

I'm working on a Django-based site that consists mostly of user- generated content: reviews, comments, tweet-like posts, etc. I'm concerned about spam. Are there any spam filters available for Django/Python? If not, what types of algorithms can be used for automatic spam filtering or flagging? On a more general note, does anyone k...

Running a function periodically in Django

Hi, Im writing an app in Django to monitor certain services in a group of servers. I would like to have the views updated periodically. So far I've looked at writing custom admin commands (link here) and have {% ifchanged %} tags in my template. I just wanted to know if this is the best approach or if there is a better way to do it, like...

Query filtering in Django with sqlite

I've tried the following query with Django, def search(search_text): q = Info.objects.filter(title__contains=str(search_text)) print q.query The query that get printed is SELECT "d"."id", "d"."foo" FROM "d_info" WHERE "d_info"."title" LIKE %hello% ESCAPE '\' The query fails because the text after LIKE doesn't have quotes ...

How to efficiently filter a string against a long list of words in Python/Django?

Stackoverflow implemented its "Related Questions" feature by taking the title of the current question being asked and removing from it the 10,000 most common English words according to Google. The remaining words are then submitted as a fulltext search to find related questions. I want to do something similar in my Django site. What is ...

django user model and custom primary key field

Django by default makes a primary key field on each model named "id", with a type of AutoField. On my models, I'm overriding this to use a custom UUIDField as the primary key by using the "primary_key" attribute. I would also like the User model in django.contrib.auth to have a UUIDField as the primary key, but this doesn't seem to be po...

django jquery post then load

Hey. Trying to get a section on my site working when it basically acts in the same way as facebooks wall post user sees a box where they input some information about how they feel, then I use a jQuery $.post method to submit the data, and then I would like to retrive the new data. Currently this is what I have. <script type="text/jav...

Postfix hangs when sending email

If I try to send an email as follows, the process hangs and nothing happens: >>> from django.core.management import setup_environ >>> from cube import settings >>> setup_environ(settings) 'cube' >>> from django.core.mail import send_mail >>> send_mail('Subject', 'Message', '[email protected]', ['[email protected]'], fail_silently=Fal...

Django "for" loop and python dictionary problems

Hi all, I'm having a couple of issues getting django templating for loop tag to go through this dictionary: It is definitely being passed to the page ok as if I just do: {% for event in events %} {{ event }} {% endfor %} it writes 1,2,3 but when I try and do {{ event.start }} it just doesn't output anything... evs = { ...

Python pickling error when using sessions

In my django app I was creating an extended user profile using session vars. But when registration form was saved and user was about to create, I got following error : Traceback (most recent call last): File "\Python26\Lib\site-packages\django\core\servers\basehttp.py", line 279, in run self.result = application(self.environ, sel...

How to get hold of a model instance from a model formset

I have created a formset from a model that has an ImageField inside it. Now when editing the formset I would like to show the image next to the other fields in the template so the user can see what images they have uploaded. From what I understand their is no simple way of saying: {% for form in model_formset %} {{form.model}} ...

Calculating if date is in start, future or present in python

I have two date/time strings: start_date = 10/2/2010 8:00:00 end_date = 10/2/2010 8:59:00 I need to write a function to calculate if the event is in the future, in the past or if it is happening right now - I've read a fair bit of documentation but just finding it quite hard to get this to work. I've not really done much time base...

Comments moderation queue view from django.contrib.comments - gone in 1.2?

I've happily used the neat comment moderation queue view supplied with contrib.comments in 1.0.x, but recently thought I'd use it in a Django 1.2 site, only to discover that the view is no longer there (no longer referenced in contrib.comments.urls, for example) Two questions: When did it disappear? Why did it disappear? ...

Django: Count objects in a particular month

I have this model: class Person(models.Model): city = models.CharField(max_length=20, blank=True) added_date = models.DateField(default=datetime.date.today) I want to create a template/view that has a table of months and the number of people added that month (ie, 5 in january, 10 in february, 8 in march, etc.). I have a similar ...

Django / Python how to get the full request header?

I've been looking over what I can find about this and found something about denying access to specific user-agents but couldn't find how I can actually get the full request header. I am trying to make a customized analytics app so would like access to the full headers.. any info is appreciated. ...

Django + Mysql + Apache in VPS

Hello guys! Im moving my site from webfaction to linode VPS. My VPS have 512MB of ram with Fedora Core 13, and when i start apache/mysql and access the site from browser, my site take MINUTES to load, and memory looks like this Mem: 510652k total, 504652k used, 6000k free, 3460k buffers Swap: 1048568k total, 5260k ...

Django url doesn't match even though it should.

In browser I get: Request URL: http://xxxxxx:8000/person/test/ Using the URLconf defined in person.urls, Django tried these URL patterns, in this order: ^person/ ^$ ^person/ ^person/(?P<slug>[-\w]+)/$ ^admin/ The current URL, person/test/, didn't match any of these. In python shell I get: import re url = 'person/test/' p...

How to improve display and handling of a large number of inlines in django-admin?

When displaying an inline for a model, if there's a large number of inlines, the change page then loads slowly, and can be hard to navigate through all of them. I'm already using an inline-collapsing trick (found on DjangoSnippets, but the search there is not working so I can't share the link here), but still isn't easy to browse since t...

Editing related models in profile form using django-profiles

I'm using django-profiles in my app, as it gives me a few simple views that helps me get where I want to go, faster. However, I have one problem. Given the models below, how can I create a form for editing a profile that includes all the fields on UserProfile, the first_name, last_name and email fields from User, and one or more PhoneNu...