django

Using Django, why would REMOTE_ADDR return 127.0.0.1 on a web server?

When getting the IP with request.META['REMOTE_ADDR'] code. This works fine on the local system but when hosted on a web server the ip got is 127.0.0.1 - How can this be resolved? ...

Ruby on Rails for web applications, Django for webpages?

Days ago I read something like "Ruby on Rails is for web applications, Django is for standard webpages". Is that true? I have to decide in the next weeks if I go with Ruby on Rails or Django for an university project. It will be an email marketing software. What do you advise me to use? ...

Who should format my data for display ?

I have a django view, and this view returns a table which is populated asynchronously with an ajax call. From the design point of view, which one should I follow: the django view, called via ajax, returns the content of the table as a json response, containing html markups for each cell. The javascript callback handler takes the cont...

Python / Django: Is it wise to use "Item" as a class name in Python (in Django in this case)?

I'm creating this: # models.py class Item(models.Model): sku = models.CharField(max_length=20) class Attribute(models.Model): item = models.ForeignKey(Item, related_name='items') Is that going to cause naming collisions in Python? Like: # views.py some_object.items.create(sku='123abc') # Is there a place / way that this c...

Use of meta class in django

Can someone please explain why is meta class used in the following example. Ex: Class Employee (models.Model): name = models.ForeignKey(name) Gender = models.IntegerField() class Meta: ordering = ["Gender"] Thanks... ...

Problems with Django + mod-wsgi + psycopg2

So I am trying to make Django running with mod-wsgi for the first time. I have configured Apache as shown in examples and I am pretty sure I did everything right. I did not set the PYTHON_EGG_CACHE variable so it uses the default: /var/www/.python-eggs. I have created this directory and made it writeable for user www-data. When I open ...

Django - custom widget with "did you mean" hints based on validation.

Hi! I have a basic model : class MyModel(models.Model): my_field = models.CharField() I have a basic form for this model : class MyFrom(forms.ModelForm): class Meta: model = MyModel And I have a function that does a basic lookup (a lot more complex in reality, regex etc. won't do) : POSSIBLE_VALUES = ['aa', 'bb', ...

How do I change which version of python mod_python uses

I'm doing some introductory work with django which seems really easy (and fun) so far but I have been doing all this from Python 2.6 which I installed in /opt/local (RedHat 5.3) because the python that came with redhat was 2.4. I set up a symlink: /usr/bin/python2.6 -> /opt/local/bin/python and I have been using that for all the djang...

Django: serializing list to json

I am sending information between client and django server and I would like to use json to this. I am sending simple information - list of strings. I tried using django.core.serializers, but when I did, I got AttributeError: 'str' object has no attribute '_meta' It seems, this can be used only for django objects. How can I serialize si...

How to retrieve the values for only one table field in Django

If I have following database fields: id, name, emp_id. How do I make a query in Django to get the values of column name only with a where clause. Thanks... ...

Virtualenv problem

I have created a new environement in virtualenv with --no-site-packages and executed activate file. So, shouldn't my current Django app show any error? Environement doesn't have Django installed. I think, my site is using my old python with Django. How can I change it? Maybe it's because my .htaccess file, here it is: SetHandler mod_pyt...

How do I change the python_egg_cache?

I am trying to get django up and running in production mode but I get this error that I can't seem to fix: ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/home/james/.python-eggs' The Python egg cache directory ...

Cannot get images to display in simple django site

I have a very simple django site but I have trouble getting the images that I upload in the admin panel to show. my settings.py has these constants: # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '/home/jeroen/programming/python/django/ninikske/media' # URL that handles the...

Running a Django test server under twisted web

As I'm writing an application which uses twisted web for serving async requests and Django for normal content delivery, I thought it would have been nice to have both run under the same twisted reactor through the WSGI interface of Django. I also wanted to test my app using the nice test server facility that Django offers. At first I si...

Install python for 64-bit Ubuntu - trying to install mod_wsgi

I have previously had python installed because of postfix. I then installed Django. Next, I tried to install mod_wsgi for deploying a Django application. I get this error: make: * [mod_wsgi.la] error 1 Apparently it is due to an older version of python. I tried to install a newer version of python but I still get the same problem. This...

What's the difference between OneToOne and Subclassing a model in Django

For example: class Subdomain(Site): #fields here and class Subdomain(models.Model): site = models.OneToOne(Site) #fields here ...

django - inlineformset_factory with more than one ForeignKey

Hey people, Im trying to do a formset with the following models (boost is the primary): class boost(models.Model): creator = models.ForeignKey(userInfo) game = models.ForeignKey(gameInfo) name = models.CharField(max_length=200) desc = models.CharField(max_length=500) rules = models.CharField(max_length=500) subsc...

Python-MySQLdb problem: wrong ELF class: ELFCLASS32

As part of trying out django CMS (http://www.django-cms.org/), I'm struggling with getting Python-MySQLdb to work (http://pypi.python.org/pypi/MySQL-python/). I have installed Django CMS and all of its dependencies (Python 2.5, Django, django-south, MySQL server) I'm trying out the example code within Django CMS code with MySQL as chos...

Django: where can I find the template that renders the fields of the admin page?

Hi everybody, I want to change the shape of some fields showed in the admin site. I found that the template that manage everything is change_form.html with fieldset.html but I cannot find where the fields are actually transformed in html. Basically I want to change the field of the foreign key adding a link to another page. Do you hav...

In Django, I know how to build a template. render_to_response('something.html'). But, how do I include a JSON object in there?

When the page loads, I have a JavaScript function that needs to analyze the JSON. But, this JSON must be present when I load "something.html" I know how to do this, but I don't know how to combine them together. return HttpResponse(thejson, mimetype="application/javascript") ...