Search Results

Search found 6723 results on 269 pages for 'django models'.

Page 10/269 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Django - Better evaluation of relationship at the model level

    - by Brant
    Here's a simple relational pair of models. class Shelf(models.Model): name = models.CharField(max_length=100) def has_books(self): if Book.objects.filter(shelf=self): return True else: return False class Book(models.Model): shelf = models.ForeignKey(Shelf) name = models.CharField(max_length=100) Is there a better (or alternative) way to write the "has_book" method? I'm not a fan of the double database hit but I want to do this at the model level.

    Read the article

  • Django left join m2m field.

    - by duder
    Here's my Model: class User(models.Model): pass class Item(models.Model): pass class ItemVote(models.Model): user = models.ForeignKey(User) item = models.ForeignKey(Item) vote = models.BooleanField() I want to retrieve a list of Items, and I want to know if the current user has voted for each Item. How do I alter my query object so that it will generate sql similar to: SELECT ... FROM items LEFT OUTER JOIN item_votes ON (item_votes.user_id = ? AND item_votes.item_id = items.id)

    Read the article

  • Model Django Poll

    - by MacPython
    I followed the django tutorial here: http://docs.djangoproject.com/en/dev/intro/tutorial01/ and now I am at creating a poll. The code below works fine until I want to create choices, where for some reason I always get this error message: line 22, in unicode return self.question AttributeError: 'Choice' object has no attribute 'question' Unfortunatley, I dont understand where I made an error. Any help would be greatly appreciated. Thanks for the time! CODE: import datetime from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question def was_published_today(self): return self.pub_date.date() == datetime.date.today() class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def __unicode__(self): return self.question

    Read the article

  • django related_name for field clashes.

    - by Absolute0
    I am getting a field clash in my models: class Visit(models.Model): user = models.ForeignKey(User) visitor = models.ForeignKey(User) Error: One or more models did not validate: profiles.visit: Accessor for field 'user' clashes with related field 'User.visit_set'. Add a related_name argument to the definition for 'user'. profiles.visit: Accessor for field 'visitor' clashes with related field 'User.visit_set'. Add a related_name argument to the definition for 'visitor'. what would be a sensible 'related_field' to use on visitor field? This model basically represents the visits that take place to a particular user's profile. Also should I replace any of the ForeignKey's with a ManyToManyField? The logic is a bit confusing. Edit: This seems to fix it, but I am unsure if its what I want. :) class Visit(models.Model): user = models.ForeignKey(User) visitor = models.ForeignKey(User, related_name='visitors')

    Read the article

  • How to open python scripts directly by typing in their name in terminal (Mac OS X)

    - by Haffi112
    I'm working on installing django and running it on my system. I have a problem though, in this tutorial creating a project is explained by running the command django-admin.py startproject mysite My issue is that this doesn't work. I changed to the directory where django-admin.py is located and ran the command chmod +x django-admin.py with no results. I tried adding the directory with the file to my path without results. I ended up fixing my problem with this command python /location/of/django-admin.py startproject mysite which yielded the outcome I expected. My problem is: What do I need to change/configure such that command django-admin.py startproject mysite would be sufficient? Here are some experiments: 21:09~/Desktop/HI/NSN/Polls > django-admin.py startproject mysite -bash: django-admin.py: command not found 21:09~/Desktop/HI/NSN/Polls > ./django-admin.py startproject mysite -bash: ./django-admin.py: No such file or directory 21:09~/Desktop/HI/NSN/Polls > python django-admin.py startproject mysite python: can't open file 'django-admin.py': [Errno 2] No such file or directory 21:09~/Desktop/HI/NSN/Polls > /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1 -bash: /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: /opt/local/bin: bad interpreter: Permission denied 21:09~/Desktop/HI/NSN/Polls > sudo /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1Password: sudo: unable to execute /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: Permission denied 21:09~/Desktop/HI/NSN/Polls > sudo /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1sudo: unable to execute /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: Permission denied 21:09~/Desktop/HI/NSN/Polls > python /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1 21:09~/Desktop/HI/NSN/Polls > ls mysite prufa1 Final edit: The problem is solved, see Ian C's answer for the right solution. Thank you everyone for helping my out, this was very fast!

    Read the article

  • Django - Override admin site's login form

    - by TrojanCentaur
    I'm currently trying to override the default form used in Django 1.4 when logging in to the admin site (my site uses an additional 'token' field required for users who opt in to Two Factor Authentication, and is mandatory for site staff). Django's default form does not support what I need. Currently, I've got a file in my templates/ directory called templates/admin/login.html, which seems to be correctly overriding the template used with the one I use throughout the rest of my site. The contents of the file are simply as below: # admin/login.html: {% extends "login.html" %} The actual login form is as below: # login.html: {% load url from future %}<!DOCTYPE html> <html> <head> <title>Please log in</title> </head> <body> <div id="loginform"> <form method="post" action="{% url 'id.views.auth' %}"> {% csrf_token %} <input type="hidden" name="next" value="{{ next }}" /> {{ form.username.label_tag }}<br/> {{ form.username }}<br/> {{ form.password.label_tag }}<br/> {{ form.password }}<br/> {{ form.token.label_tag }}<br/> {{ form.token }}<br/> <input type="submit" value="Log In" /> </form> </div> </body> </html> My issue is that the form provided works perfectly fine when accessed using my normal login URLs because I supply my own AuthenticationForm as the form to display, but through the Django Admin login route, Django likes to supply it's own form to this template and thus only the username and password fields render. Is there any way I can make this work, or is this something I am just better off 'hard coding' the HTML fields into the form for?

    Read the article

  • Configuration problems with django and mod_wsgi

    - by Jimbo
    Hi, I've got problems on getting django to work on apache 2.2 with mod_wsgi. Django is installed and mod_wsgi too. I can even see a 404 page when accessing the path and I can login to django admin. But if I want to install the tagging module I get the following error: Traceback (most recent call last): File "setup.py", line 49, in <module> version_tuple = __import__('tagging').VERSION File "/home/jim/django-tagging/tagging/__init__.py", line 3, in <module> from tagging.managers import ModelTaggedItemManager, TagDescriptor File "/home/jim/django-tagging/tagging/managers.py", line 5, in <module> from django.contrib.contenttypes.models import ContentType File "/usr/lib/python2.5/site-packages/django/contrib/contenttypes/models.py", line 1, in <module> from django.db import models File "/usr/lib/python2.5/site-packages/django/db/__init__.py", line 10, in <module> if not settings.DATABASE_ENGINE: File "/usr/lib/python2.5/site-packages/django/utils/functional.py", line 269, in __getattr__ self._setup() File "/usr/lib/python2.5/site-packages/django/conf/__init__.py", line 40, in _setup self._wrapped = Settings(settings_module) File "/usr/lib/python2.5/site-packages/django/conf/__init__.py", line 75, in __init__ raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) ImportError: Could not import settings 'mysite.settings' (Is it on sys.path? Does it have syntax errors?): No module named mysite.settings My httpd.conf: Alias /media/ /home/jim/django/mysite/media/ <Directory /home/jim/django/mysite/media> Order deny,allow Allow from all </Directory> Alias /admin/media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/" <Directory "/usr/lib/python2.5/site-packages/django/contrib/admin/media/"> Order allow,deny Allow from all </Directory> WSGIScriptAlias /dj /home/jim/django/mysite/apache/django.wsgi <Directory /home/jim/django/mysite/apache> Order deny,allow Allow from all </Directory> My django.wsgi: import sys, os sys.path.append('/home/jim/django') sys.path.append('/home/jim/django/mysite') os.chdir('/home/jim/django/mysite') os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() I try to get this to work since a few days and have read several blogs and answers here on so but nothing worked.

    Read the article

  • Django Error: NameError name 'current_datetime' is not defined

    - by Diego
    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/$', hello), ) urlpatterns = patterns('', ('^time/$', current_datetime), ) And the following is the code in my views.py file: from django.http import HttpResponse import datetime def hello(request): return HttpResponse("Hello World") def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpResponse(html) Yet, I get the following error when I test the code in the development server. NameError at /time/ name 'current_datetime' is not defined Can someone help me out here? This really is just a copy-paste from the book. I don't see any mistyping.

    Read the article

  • Django Admin Form for Many to many relationship

    - by Anand
    I have a many to many relationship between 2 tables Users an Domains. I have defined this relationship in the Domains class. So in the admin interface I see the Users when I am viewing Domains. But I do not see Domains when I am viewing Users. How can I achieve this.

    Read the article

  • Django: remove a filter condition from a queryset

    - by Don
    I have a third-part funtion which gives me a filtered queryset (e.g. records with 'valid'=True) but I want to remove a particular condition (e.g. to have all records, both valid and invalid). Is there a way to remove a filter condition to an already-filtered queryset? E.g. only_valid = MyModel.objects.filter(valid=True) all_records = only_valid.**remove_filter**('valid') (I know that it would be better to define 'all_records' before 'only_valid', but this is just an example...)

    Read the article

  • [Django] Automatically Update Field when a Different Field is Changed

    - by Gordon
    I have a model with a bunch of different fields like first_name, last_name, etc. I also have fields first_name_ud, last_name_ud, etc. that correspond to the last updated date for the related fields (i.e. when first_name is modified, then first_name_ud is set to the current date). Is there a way to make this happen automatically or do I need to check what fields have changed each time I save an object and then update the related "_ud" fields. Thanks a lot!

    Read the article

  • using distinct in django query

    - by Hulk
    There is a column as designation in the defaults table,How to get the distinct designation values from defaults table In the below the distinct applies on the id field, this need to be on designation field def = defaults.objects.filter(name=sc).distinct() And can some one explain what is flat=true condition Thanks..

    Read the article

  • Is there an OR filter? - Django

    - by RadiantHex
    Hi folks, is there any way of doing the following Unicorn.objects.or_filter(magical=True).or_filter(unicorn_length=15).or_filter(skin_color='White').or_filter(skin_color='Blue') where or_filter stands for an isolated match I remember using something similar but cannot find the function anymore! Help would be great! Thanks :)

    Read the article

  • How can join two django querysets in one?

    - by diegueus9
    I need order a Queryset by date in desc order, but i need put in the end the objects at the end, I do this: qs1 = Model.objects.exclude(date=None).order_by('-date') qs2 = Model.objects.filter(date=None).order_by('-date') and my list is: l = list(qs1)+list(qs2) There is a more efficiently way for this?

    Read the article

  • Django Admin drop down combobox and assigned values

    - by Daniel Garcia
    I have several question for the Django Admin feature. Im kind of new in Django so im not sure how to do it. Basically what Im looking to do is when Im adding information on the model. Some of the fields i want them to be drop-downs and maybe combo-boxes with AutoCompleteMode. Also looking for some fields to have the same information, for example if i have a datatime field I want that information to feed the fields day, month and year from hoti.hotiapp.models import Occurrence from django.contrib import admin class MyModelAdmin(admin.ModelAdmin): exclude = ['reference',] admin.site.register(Occurrence, MyModelAdmin) Anything helps Thanks in advance

    Read the article

  • Django: testing get query

    - by Brant
    Okay, so I am sick of writing this... res = Something.objects.filter(asdf=something) if res: single = res[0] else: single = None if single: # do some stuff I would much rather be able to do something like this: single = Something.objects.filter(asdf=something) if single: #do some stuff I want to be able to grab a single object without testing the filtered results. In other words, when i know there is either going to be 1 or 0 matching entries, I would like to jump right to that entry, otherwise just get a 'None'. The DoesNotExist error that goes along with .get does not always work so well when trying to compress these queries into a single line. Is there any way to do what I have described?

    Read the article

  • How to use multiple flatpages models in a django app?

    - by the_drow
    I have multiple models that can be converted to flatpages but have to have some extra information (For example I have an about us page but I also have a blog). However I understand that there must be only one flatpages model since the middleware only returns the flatpages instance and does not resolve the child models. What do I have to do? EDIT: It seems I need to change the views. Here's the current code: from django.contrib.flatpages.models import FlatPage from django.template import loader, RequestContext from django.shortcuts import get_object_or_404 from django.http import HttpResponse, HttpResponseRedirect from django.conf import settings from django.core.xheaders import populate_xheaders from django.utils.safestring import mark_safe from django.views.decorators.csrf import csrf_protect DEFAULT_TEMPLATE = 'flatpages/default.html' # This view is called from FlatpageFallbackMiddleware.process_response # when a 404 is raised, which often means CsrfViewMiddleware.process_view # has not been called even if CsrfViewMiddleware is installed. So we need # to use @csrf_protect, in case the template needs {% csrf_token %}. # However, we can't just wrap this view; if no matching flatpage exists, # or a redirect is required for authentication, the 404 needs to be returned # without any CSRF checks. Therefore, we only # CSRF protect the internal implementation. def flatpage(request, url): """ Public interface to the flat page view. Models: `flatpages.flatpages` Templates: Uses the template defined by the ``template_name`` field, or `flatpages/default.html` if template_name is not defined. Context: flatpage `flatpages.flatpages` object """ if not url.endswith('/') and settings.APPEND_SLASH: return HttpResponseRedirect("%s/" % request.path) if not url.startswith('/'): url = "/" + url # Here instead of getting the flat page it needs to find if it has a page with a child model. f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=settings.SITE_ID) return render_flatpage(request, f) @csrf_protect def render_flatpage(request, f): """ Internal interface to the flat page view. """ # If registration is required for accessing this page, and the user isn't # logged in, redirect to the login page. if f.registration_required and not request.user.is_authenticated(): from django.contrib.auth.views import redirect_to_login return redirect_to_login(request.path) if f.template_name: t = loader.select_template((f.template_name, DEFAULT_TEMPLATE)) else: t = loader.get_template(DEFAULT_TEMPLATE) # To avoid having to always use the "|safe" filter in flatpage templates, # mark the title and content as already safe (since they are raw HTML # content in the first place). f.title = mark_safe(f.title) f.content = mark_safe(f.content) # Here I need to be able to configure what I am passing in the context c = RequestContext(request, { 'flatpage': f, }) response = HttpResponse(t.render(c)) populate_xheaders(request, response, FlatPage, f.id) return response

    Read the article

  • Django RadioButtons with icons and not label?

    - by Asinox
    Hi guy's , i have an app that have 2 fields: company_name and logo, i'm displaying the companies like radiobutton in my Form from Model, but i want to show the logo company instead of the company label (company name) Any idea ? My forms: class RecargaForm(ModelForm): compania = forms.ModelChoiceField(queryset=Compania.objects.all(), initial=0 ,empty_label='None', widget=forms.RadioSelect()) class Meta: model = Recarga Thanks :)

    Read the article

  • Django unable to update model

    - by user292652
    i have the following function to override the default save function in a model match def save(self, *args, **kwargs): if self.Match_Status == "F": Team.objects.filter(pk=self.Team_one.id).update(Played=F('Played')+1) Team.objects.filter(pk=self.Team_two.id).update(Played=F('Played')+1) if self.Winner !="": Team.objects.filter(pk=self.Winner.id).update(Win=F('Win')+1, Points=F('Points')+3) else: return if self.Match_Status == "D": Team.objects.filter(pk=self.Team_one.id).update(Played=F('Played')+1, Draw = F('Draw')+1, Points=F('Points')+1) Team.objects.filter(pk=self.Team_two.id).update(Played=F('Played')+1, Draw = F('Draw')+1, Points=F('Points')+1) super(Match, self).save(*args, **kwargs) I am able to save the match model just fine but Team model does not seem to be updating at all and no error is being thrown. am i missing some thing here ?

    Read the article

  • Manually listing objects in Django (problem with field ordering)

    - by Chris
    I'm having some trouble figuring out the best/Djangoic way to do this. I'm creating something like an interactive textbook. It has modules, which are more or less like chapters. Each module page needs to list the topics in that module, grouped into sections. My question is how I can ensure that they list in the correct order in the template? Specifically: 1) How to ensure the sections appear in the correct order? 2) How to ensure the topics appear in the correct order in the section? I imagine I could add a field to each model purely for the sake of ordering, but the problem with that is that a topic might appear in different modules, and in whatever section they are in there they would again have to be ordered somehow. I would probably give up and do it all manually were it not for the fact that I need to have the Topic as object in the template (or view) so I can mark it up according to how the user has labeled it. So I suppose my question is really to do with whether I should create the contents pages manually, or whether there is a way of ordering the query results in a way I haven't thought of. Thanks for your help!

    Read the article

  • Django Custom Template Tages: Inclusion Tags

    - by Harry
    Hello world! Im trieng to build my own template tags Im have no idea why I get the errors I get, im following the django doc's. this is my file structure of my app: pollquiz/ __init__.py show_pollquiz.html showpollquiz.py This is showpollquiz.py: from django import template from pollquiz.models import PollQuiz, Choice register = template.Library() @register.inclusion_tag('show_pollquiz.html') def show_poll(): poll = Choice.objects.all() return { 'poll' : poll } html file: <ul> {% for poll in poll <li>{{ poll.pollquiz }}</li> {% endfor </ul> in my base.html file im am including like this {% load showpollquiz %} and {% poll_quiz %} Bu then I get the the error: Exception Value: Caught an exception while rendering: show_pollquiz.html I have no idea why this happens. Any ideas? Please keep in mind Im still new to Django

    Read the article

  • Django - calling full_clean() inside of clean() equivalent?

    - by orokusaki
    For transaction purposes, I need all field validations to run before clean() is done. Is this possible? My thinking is this: @transaction.commit_on_success def clean(self): # Some fun stuff here. self.full_clean() # I know this isn't correct, but it illustrates my point. but obviously that's not correct, because it would be recursive. Is there a way to make sure that everything that full_clean() does is done inside clean()?

    Read the article

  • How to use mount points in MilkShape models?

    - by vividos
    I have bought the Warriors & Commoners model pack from Frogames and the pack contains (among other formats) two animated models and several non-animated objects (axe, shield, pilosities, etc.) in MilkShape3D format. I looked at the official "MilkShape 3D Viewer v2.0" (msViewer2.zip at http://www.chumba.ch/chumbalum-soft/ms3d/download.html) source code and implemented loading the model, calculating the joint matrices and everything looks fine. In the model there are several joints that are designated as the "mount points" for the static objects like axe and shield. I now want to "put" the axe into the hand of the animated model, and I couldn't quite figure out how. I put the animated vertices in a VBO that gets updated every frame (I know I should do this with a shader, but I didn't have time to do this yet). I put the static vertices in another VBO that I want to keep static and not updated every frame. I now tried to render the animated vertices first, then use the joint matrix for the "mount joint" to calculate the location of the static object. I tried many things, and what about seems to be right is to transpose the joint matrix, then use glMatrixMult() to transform the modelview matrix. For some objects like the axe this is working, but not for others, e.g. the pilosities. Now my question: How is this generally implemented when using bone/joint models, and especially with MilkShape3D models? Am I on the right track?

    Read the article

  • UnicodeEncodeError when uploading files in Django admin

    - by Samuel Linde
    Note: I asked this question on StackOverflow, but I realize this might be a more proper place to ask this kind of question. I'm trying to upload a file called 'Testaråäö.txt' via the Django admin app. I'm running Django 1.3.1 with Gunicorn 0.13.4 and Nginx 0.7.6.7 on a Debian 6 server. Database is PostgreSQL 8.4.9. Other Unicode data is saved to the database with no problem, so I guess the problem must be with the filesystem somehow. I've set http { charset utf-8; } in my nginx.conf. LC_ALL and LANG is set to 'sv_SE.UTF-8'. Running 'locale' verifies this. I even tried setting LC_ALL and LANG in my nginx init script just to make sure locale is set properly. Here's the traceback: Traceback (most recent call last): File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/contrib/admin/options.py", line 307, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/views/decorators/cache.py", line 79, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/contrib/admin/sites.py", line 197, in inner return view(request, *args, **kwargs) File "/srv/django/letebo/app/cms/admin.py", line 81, in change_view return super(PageAdmin, self).change_view(request, obj_id) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/utils/decorators.py", line 28, in _wrapper return bound_func(*args, **kwargs) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/utils/decorators.py", line 24, in bound_func return func(self, *args2, **kwargs2) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/db/transaction.py", line 217, in inner res = func(*args, **kwargs) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/contrib/admin/options.py", line 985, in change_view self.save_formset(request, form, formset, change=True) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/contrib/admin/options.py", line 677, in save_formset formset.save() File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/forms/models.py", line 482, in save return self.save_existing_objects(commit) + self.save_new_objects(commit) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/forms/models.py", line 613, in save_new_objects self.new_objects.append(self.save_new(form, commit=commit)) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/forms/models.py", line 717, in save_new obj.save() File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/db/models/base.py", line 460, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/db/models/base.py", line 504, in save_base self.save_base(cls=parent, origin=org, using=using) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/db/models/base.py", line 543, in save_base for f in meta.local_fields if not isinstance(f, AutoField)] File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/db/models/fields/files.py", line 255, in pre_save file.save(file.name, file, save=False) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/db/models/fields/files.py", line 92, in save self.name = self.storage.save(name, content) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/core/files/storage.py", line 48, in save name = self.get_available_name(name) File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/core/files/storage.py", line 74, in get_available_name while self.exists(name): File "/srv/.virtualenvs/letebo/lib/python2.6/site-packages/django/core/files/storage.py", line 218, in exists return os.path.exists(self.path(name)) File "/srv/.virtualenvs/letebo/lib/python2.6/genericpath.py", line 18, in exists st = os.stat(path) UnicodeEncodeError: 'ascii' codec can't encode characters in position 52-54: ordinal not in range(128) I tried running Gunicorn with debugging turned on, and the file uploads without any problem at all. I suppose this must mean that the issue is with Nginx. Still beats me where to look, though. Here are the raw response headers from Gunicorn and Nginx, if it makes any sense: Gunicorn: HTTP/1.1 302 FOUND Server: gunicorn/0.13.4 Date: Thu, 09 Feb 2012 14:50:27 GMT Connection: close Transfer-Encoding: chunked Expires: Thu, 09 Feb 2012 14:50:27 GMT Vary: Cookie Last-Modified: Thu, 09 Feb 2012 14:50:27 GMT Location: http://my-server.se:8000/admin/cms/page/15/ Cache-Control: max-age=0 Content-Type: text/html; charset=utf-8 Set-Cookie: messages="yada yada yada"; Path=/ Nginx: HTTP/1.1 500 INTERNAL SERVER ERROR Server: nginx/0.7.67 Date: Thu, 09 Feb 2012 14:50:57 GMT Content-Type: text/html; charset=utf-8 Transfer-Encoding: chunked Connection: close Vary: Cookie 500 UPDATE: Both locale.getpreferredencoding() and sys.getfilesystemencoding() outputs 'UTF-8'. locale.getdefaultlocale() outputs ('sv_SE', 'UTF8'). This seem correct to me, so I'm still not sure why I keep getting these errors.

    Read the article

  • Django - need to split a table across multiple locations [closed]

    - by MikeRand
    Hi all, I have a Django project to track our company's restructuring projects. Here's the very simple model: class Project(models.Model): code = models.CharField(max_length=30) description = models.CharField(max_length=60) class Employee(models.Model): project = models.ForeignKey(Project) employee_id = models.IntegerField() country_code = models.CharField(max_length=3) severance = models.IntegerField() Due to regulations in some European countries, I'm not allowed to keep employee-level severance information in a database that sits on a box outside of that country. In Django, how do I manage the need to have my Employee table split across multiple databases based on an Employee attribute (i.e. country_code) in a way that doesn't impact anything else in the project (e.g. views, templates, admin)? Thanks, Mike

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >