This is a portion of a template tag code, where qs is a queryset.
def foo(qs):
...
context['key'] = qs.order_by('an_invalid_field_coming_from_user')
How can I check if the queryset will be ordered by a valid field before the code execution goes out of the scope of the template tag, other than forcing an evaluation?
The cod...
Let's say that accounts in my SAAS are of the type Account(models.Model). Would the following be a good idea?
class MyModel(models.Model):
account = models.ForeignKey(Account)
spam = models.CharField(max_length=255)
class MyOtherModel(models.Model):
# The next attribute `account` is the line in question.
# Should it be ...
My apps are installed. They used to work. Now that I made some edits here and there, I must have a syntax error, or something. Instead of telling me, Django just creates the Auth, Admin, etc apps and kills all my apps. Why? And, how can I debug?
...
I'm building a site based on a highly customized django admin instance and am running into issues with user profiles as an inline to user_admin
long story short regardless of what I set for max_num and extra in the admin.StackedInline instance it allows up to 2 profiles per user - with a blank one in place by default if the user has an ...
News sites usually have a featured section and some category based news. The featured articles belong to a category but when they're featured they don't show up in the category section - what's the common way of doing this? Should I save a list of all the articles that are featured, then grab the latest news from each category, except pr...
The setup =
I have this class, Transcript:
class Transcript(models.Model):
body = models.TextField('Body')
doPagination = models.BooleanField('Paginate')
numPages = models.PositiveIntegerField('Number of Pages')
and this class, TranscriptPages(models.Model):
class TranscriptPages(models.Model):
transcript = mode...
I'm trying to add .css and .js file in my HTML template files that made for Django. I have followed the official doc, so my configurations set to:
urls.py
urlpatterns = patterns('',
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_DOC_ROOT}),
settings.py
STATIC...
Hi, I've run into a problem with using two models for my form in Django. I have two models, Animal and Family, both with a "name" field.
I use the two modelforms on my template for my form, and when it's submitted, the POST data for 'name' only returns one value.
Short of renaming the 'name' field in my models, is there any way aroun...
I use emacs when working with Django. .py files work great with Python-mode, .js files work great with js2-mode, .djhtml (templates) work great with django-html-mode -- except for Javascript blocks which aren't auto-indented nor highlighted.
Does anyone know of a way to get syntax-highlighting for Javascript blocks in Django templates i...
Hello
I'm trying to use Django's ORM in my non-HTTP part of project.
In one function I need to make bulk inserts of data, so commit_on_success decorator is what I need.
But I've found that this decorator doesn't do what supposed (didn't rollback transaction on error).
I've go into this decorator with debugger, I've fount thar reason...
How can I make a Django field that renders itself as a pair of input
fields?
Reasoning: I am trying to write a new custom field. I will use it for a
captcha-like service. The service works by requesting a question -
then receiving one and a token. The validation happens by sending the
answer along with the token. I want to write a form ...
I have a Django project. Given a url, how can I know which view will be dispatched to handle the request?
...
This question is not about which is the best, it is about which makes the most business sense to use as a company's platform of choice for ongoing freelance development.
I'm currently trying to decide what framework to move my company in regarding frameworks for web application work.
Options are
ASP.NET MVC
Django
CakePHP/Symfony etc...
Can you send a paypal payment with a script? I've been googling for this, but I can't seem to find the answer I want (yes) ;-)
An example of what I am talking about: Lets say I have a site where users share in the profit. Instead of sending each users payment out manually at the end of the month, I would like to automate this with co...
I am storing the the latitude and longitude as a charfield like ("latitude, longitude"). I prefer to keep it this way.
I need to filter the results to show only latitude > w, latitude < x, longitude > y, longitude < z.
How can I do this without change how I store the lat,long?
...
Is there any easy way to do so?
...
I'm working with some backend code that can't handle unicode very well which proves to be a bit of a problem with Django models. At the moment I just have some functions in the model that cast each parameter into a str(), and when I need the ASCII strings I just call that. But, I really doubt that's the optimal solution.
Is there any wa...
Hi!
I was trying to understand how ajax works with django several times, but looks like no tutorials on the web can help me. I'd rather try to build a small sample. So trying to solve the following.
1) I have a very simple view function which returns random number on call e.g.
def homepage(request):
id = randint(1, 6)
return r...
Given the following model:
class Project(models.Model):
project_name = models.CharField(max_length=255)
abstract = models.TextField(blank=True, null=True)
full_description = models.TextField(blank=True, null=True)
date_begun = models.DateField(blank=True, null=True)
related_projects = models.ManyToManyField('self', b...
I have some models; Vocabularies (tags lists), Labels (tags) and different articles types.
These article types have some vocabs enabled, and some not, for instance: Image can tagged with terms from A, B and a news article with terms from A or C.
This however only exists at the database level.
What i'm trying to do is to output fields ...