django

Django startup problems

Hi, This is something similar to what's posted here: http://stackoverflow.com/questions/312549/no-module-named-django-core To reiterate, I'm getting this error on running "django-admin.py startproject mysite"(without the double quotes): C:\Documents and Settings\fixavier\Desktop>django-admin.py startproject mysite Traceback (most recen...

How does Django know which location the user is from?

I am reading the Django localization documentation:http://docs.djangoproject.com/en/dev/topics/i18n/localization/ Of course, where the user is from determines what "message file" to use. How do I determine where the user is from and what to use? Does it do it automatically? ...

Can Django be used for web services?

My friend said, "Pylons is so much better for web services." My other friend said, "You can modify Django in a way to do exactly whatever you like." In Django, what is necessary to be modified (urls.py? models classes? settings?) in order to do "web services" with APIs and REST and versioning, etc etc.? ...

Django's manage.py shell won't indent

I seem to have run into a strange bug or more likely some setting I am unfamiliar with on my system that is not allowing me to tab when I am in Django's shell (python manage.py shell is how I run it). For obvious reasons this is proving to be annoying since I can't do any loops or conditonals in the shell. If I hit tab it completes all ...

Making REST calls only available to local applications?

Suppose I have a url like http://mysite.com/get-users which returns a JSON object of all users. But, I don't want anyone (or any bots) to be able to go to this url to fetch this information. I want it to only respond to calls from other local modules in the same website. How would I go about implementing someting like this? ...

Select distinct users with referrals

I have a bunch of Users. Since Django doesn't really let me extend the default User model, they each have Profiles. The Profiles have a referred_by field (a FK to User). I'm trying to get a list of Users with >= 1 referral. Here's what I've got so far Profile.objects.filter(referred_by__isnull=False).values_list('referred_by', flat=Tr...

how to delete old image when update ImageField?

hi using Django to create a stock photo site, i have a ImageField in my model, the problem is that when the user update the image field, the original image file isn't deleted from the hard disk. how can I make to delete those images after an update? Thanks! ...

Why is django.test.client.Client not keeping me logged in.

I'm using django.test.client.Client to test whether some text shows up when a user is logged in. However, I the Client object doesn't seem to be keeping me logged in. This test passes if done manually with Firefox but not when done with the Client object. class Test(TestCase): def test_view(self): user.set_password(passwor...

ModelMultipleChoiceField and reverse()

I have a form containing a ModelMultipleChoiceField. Is it possible to come up with a url mapping that will capture a varying number of parameters from said ModelMultipleChoiceField? I find myself doing a reverse() call in the view passing the arguments of the form submission and realized that I don't know how to represent, in the url...

Is there a way to simplify this Django query?

accepted_bids = Bid.objects.filter(shipment__user=u, status='acc').select_related('shipment') completed_shipments = [] for b in accepted_bids: completed_shipments.append(b.shipment) vehicles_shipped = [] for s in completed_shipments: vehicles_shipped.extend(s.items.all()) In the end, I want a list of shipped vehicles. A vehicle...

Help with Django localization--doesn't seem to be working. Nothing happens

Can someone help me with Localization? I put {% trans "..." %} in my template, I filled in my django.po after running "makemessages". #: templates/main_content.html:136 msgid "Go to page" msgstr "▒~C~Z▒~C▒▒~B▒▒~L~G▒~Z" #: templates/main_content.html:138 msgid "Page" msgstr "▒~C~Z▒~C▒▒~B▒" #: templates/main_content.html:154 msgid "Ne...

Django Error: NameError name 'current_datetime' is not defined

I'm working through the book "The Definitive Guide to Django" and am stuck on a piece of code. This is the code in my settings.py: ROOT_URLCONF = 'mysite.urls' I have the following code in my urls.py from django.conf.urls.defaults import * from mysite.views import hello, my_homepage_view urlpatterns = patterns('', ('^hello/$', hell...

psycopg2 on cygwin: no such process

I am trying to install postgrepsql to cygwin on a windows 7 machine and want it to work with django. After built and installed postgrepsql in cygwin, I built and installed psycopg2 in cygwin as well and got no error, but when use it in python with cygwin, I got the "no such process" error: import psycopg2 Tracebac...

Python Django vs ASP.NET MVC

Hey guys ! i'm fairly new at web development scene and i was wondering if you guys can help me break up the pros and cons of using python django vs asp.net mvc besides the maturity level of its framework. I have intermediate experience with JAVA. As of right now, i'm leaning towards python but i just wanted to make sure i am making the r...

Django 1.2 crash course needed

I know Python but I've never used Django. What do I need to know about Django 1.2 to port my typical PHP CRUD web application in one weekend? (Yes I've read Joel Spolsky's Netscape article :-)) I'm reading this tutorial right now and it's excellent. I'm already playing around with inspectdb to generate my models from the existing sch...

ValueError while using AutoSlugField and Django-tagging

Am running into ValueError, here is the full traceback, the end of which is: Exception Type: ValueError at /admin/blog/post/add/ Exception Value: invalid literal for int() with base 10: 'treef' I'm using AutoSlugField from django-command-extensions. I am trying to get django-tagging working, this is my models.py: class Post(mod...

GAE : Open Source Django Apps

Am looking for open source Django apps in Google App engine. I want to play around with the code and learn in the process. Not mandatory, but Would be great feature in the app: - account registration/login - image/file upload ...

Session handling in python / django

I am creating an application that lets users login using Google, Facebook and the website's native login. The site is being built in Python / Django. What would be the best way to handle login, session management and user authentication? I do not want to use the in-built Django user management. I am using Django very sparingly(URLs, te...

Django: automatically import MEDIA_URL in context

Hi, like exposed here, one can set a MEDIA_URL in settings.py (for example i'm pointing to Amazon S3) and serve the files in the view via {{ MEDIA_URL }}. Since MEDIA_URL is not automatically in the context, one have to manually add it to the context, so, for example, the following works: #views.py from django.shortcuts import render_...

When to use context processor

I have a site on which I'm including a userBox with some data shown for each logged user (your name, avatar etc). From what I already know about django it seems obvious, that I should add query for user to context processor (so that I can use {{user}} variable in this included userBox ). But while using django-lfs shop I've noticed, that...