I'm a PHP guy on my first day in Python-land, trying to convert a php site to python (learning experience), and I'm hurting for advice. I never thought it would be so hard to use multi-dimensional arrays or dictionaries as you pythoners call them.
So I can create multi-dimensional arrays using this, but i can't loop it in a django templ...
I've tried the following but this seems to only create an empty migration file:
startmigration appname freeze_appname --freeze appname
i've also tried just:
startmigration --freeze appname
doesn't work either.
...
I am using django 0.96 for the appengine project. I wanted to use javascript and css in my html files unfortunately i am unable to do it via django...
One solution(which i don't like) is to make my app.yaml something like this:
handlers:
- url: /media
static_dir: static/media
But i want it to do with django itself so i avoided using...
Hi!
I want to write a unit test that performs HTTP requests directly (instead of using django.test.client.Client).
If you're curious why - it's because I want to test a Thrift-over-HTTP API that I expose from my Django application - and I want to use the Thrift client in the unit test.
The problem is that during tests, the server is n...
how we configure django with SQLAlchemy??
...
How much of a pain is it to run a Django App on App Engine? Also, does the Datastore work as-is with Django?
...
How can you know if a value is the default value for a Model's property.
For example
class Alias(models.Model) :
image = models.ImageField(upload_to='alias', default='/media/alias-default.png')
a = Alias.get("123")
# this doesn't work
if a.image == a.image.default :
pass
# nor this
if a.image == Alias.image.default :
pass
I t...
Hi
First of all, I'm using Windows, just to make that clear. I am using cmd.exe to manage runserver and the server runs just fine. However, sometimes, on a seemingly random basis, Django simply stops writing to stdout! The server responds to my requests and everything, but nothing gets printed.
To make it even clearer, I'm not even tal...
I'm working on a django website that needs to track popularity of items within a given date/time range. I'll need the ability to have a most viewed today, this week, all time, etc...
There is a "django-popularity" app on github that looks promising but only works with mysql (I'm using postgresql).
My initial thoughts are to create a g...
In ASP.NET MVC, you can use the AcceptVerbs attribute to correlate a view function with a verb:
public ActionResult Create()
{
// do get stuff
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(FormCollection collection)
{
// do post stuff
}
The Django Book suggests something like this:
def method_splitter(request, ...
Hello,
I am executing the following code (names changed to protect the innocent, so the model structure might seem weird):
memberships =
models.Membership.objects.filter(
degree__gt=0.0,
group=request.user.get_profile().group
)
exclude_count =
memberships.filter(
member__officerships__profile=req...
View
categories = Category.objects.all()
t = loader.get_template('index.html')
v = Context({
'categories': categories
})
return HttpResponse(t.render(v))
Template
{% for category in categories %}
<h1>{{ category.name }}</h1>
{% endfor %}
this works great. now im trying to print each company in that category. the company table...
On Django's admin pages, I'd like to perform an action when the administrator clicks the Delete button for an object. In other words, I'd like to execute some code prior to arriving on the "Are you sure?" delete confirmation page.
I realize I could override the template page for this object, but I was hoping for something easier (i.e.,...
@render_to('edit_operation.html')
def edit_operation(request, pk):
from forms import OpBaseForm, OperationForm
from django.forms.models import inlineformset_factory
op = Operation.objects.get(pk=pk)
OpBaseFormSet = inlineformset_factory(Operation, OpBase, form=OpBaseForm, extra=5, )
if request.method == "POST":
form = Oper...
I have come across various django development add ons, particularly,
django-extensions
django-annoying
django-debug-toolbar
django-tools
I haven't exactly used all of these.
I think it is hard to beat the simplicity and power obtained by the combination of django's pretty error pages combined with iPythonEmbed shell.
Which of the...
Given
siteInfo = \
{
'appname3': 'MSQuantDynamics11',
'siteBase': 'http://www.pil.sdu.dk/1',
}
in a "urls.py" file.
This works as expected:
urlpatterns = patterns('',
(r'^$', direct_to_template, \
{ \
'template' : "homepage.html...
Hello,
I am using Django-PayPal plugin (http://github.com/johnboxall/django-paypal/tree/master), which works almost fine with one problem.
I followed integration process and think that everything is the same as in the guide.
But there is the problem, that I always get the INVALID response flag. I will not be able to determine the sucess...
How can I have different users for different sites with django.
My application should look like this:
a.mydomain.com
b.otherdomain.com
Users should be bound to the domain, so that a.mydomain.com and b.otherdomain.com have different users.
...
Is there a benefit to passing a string in your url patters vs a function instance? It seems like it could be optimized to not actually load the function until it is needed, but is this in fact true?
from django.conf.urls.defaults import *
from myapp.views import myView
urlpatterns = patterns('',
# as a string
url(r'^as-string/$...
I was having a debate on this with some colleagues. Is there a preferred way to retrieve an object in Django when you're expecting only one?
The two obvious ways are:
try:
obj = MyModel.objects.get(id=1)
except MyModel.DoesNotExist:
# we have no object! do something
pass
and
objs = MyModel.objects.filt...