In a form submission scenario, form is post to "/submit". I want to redirect user to "/sucess" on success and pass render some message to a template at new url. How to do this in Django? render_to_response doesn't do redirect and HttpResponseRedirect doesn't do template rendering.
...
Hello guys,
Im tired of trying to put this working :(
So, here is my problem:
Added to httpd.conf :
Location "/ps3t/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE ps3t.settings
PythonOption django.root /ps3t
PythonDebug On
PythonPath "['/home/fabriciols...
I have a function that looks like this:
def post_count(self):
return self.thread_set.aggregate(num_posts=Count('post'))['num_posts']
I only want to count posts that have their status marked as 'active'. Is there an easy way to add a filter before the Count function?
Model Definitions:
class Category(models.Model):
name =...
I have writing a template tag and take it to the templates:
{% check_somethings value1 value2 as is_checked %}
{% if is_checked %}
# do it
{% endif %}
But there are some errors. I am doing so right?
check_somethings takes 2 arguments
There are:
@register.simple_tag
def check_somethings(value1, value2):
if Mymodel.objects.f...
I have an app that uses django.contrib.auth but makes no use of Django's built-in permissions system. Instead, views have the @login_required decorator and then check which group the user belongs to, and follow different branches of code execution within the view depending on the group.
A user can belong to only one group.
Checking for...
I have a simple django app that is using only the admin. This is the model as is now in the server:
from django.db import models
class School(models.Model):
school = models.CharField(max_length=200)
def __unicode__(self):
return self.school
class Lawyer(models.Model):
first = models.CharField(max_length=20)
...
Specifically, I got a form that calls a Django service (written using Piston, but I don't think that's relevant), sending via POST something like this:
edu_type[3][name] => a
edu_type[3][spec] => b
edu_type[3][start_year] => c
edu_type[3][end_year] => d
edu_type[4][0][name] => Cisco
edu_type[4][0][spec] => CCNA
edu_type[4][0][start_year...
I have PDF forms that I want to autopopulate with data from my Django web application and then offer to the user to download. What python library would let me easily pre-populate PDF forms? These forms are intended to be printed out.
...
I'm creating a Django app that uses some inheritance in it's model, mainly because I need to assign everything a UUID and a reference so I know what class it was. Here's a simplified version of the base class:
class BaseElement(models.Model):
uuid = models.CharField(max_length=64, editable=False, blank=True, default=lambda:unicode(...
This seems silly, but I don't understand how Django Templates access nested data in Contexts. I can access the values of dictionaries nested in the context data structure with the . notation -- {{ aDictionary.i_am_a_key }} works fine. But if I try to iterate over a list of keys and get their value from that same dictionary, I get nothi...
How can you have model declarations at two different directories in Django?
I have the model at the directory Code which contains "init.py", "models.py" and "admin.py".
It is working properly alone.
I want to have the directory History which has the model of the revisions of the given questions. I have the similar files in the director...
i need make a special widget for ForeignKeys in Admin, but i need get the class of model in the widget, somebody know how i can do it?
I think the Widget have a Field, and Field have a ModelForm, and obviously ModelForm have a Model, but i need this model in a widget in the admin.
...
I have quite long query with 'Q()', with Sqlite3 works very well, but with postgresql or mysql I have strange error e.g. for postgresql: invalid input syntax for integer: "("
and for mySQL: Truncated incorrect DOUBLE value: '('
How could I run that query with mysql? Where is my mistake?
Here is that query:
watchersTuple = self.getWa...
My Django templates use a lot of related stuff: images, style sheets, etc.
Where should I put these file, or how should I refer to them in the template itself?
For now I'm using the development server.
I know it's a really common thing, but I can't really figure it out.
...
How do I add different XHTML in a template for a checkbox field? I would like the following to work. I've tried to use "is_checkbox" in the example below but it doesn't work because this isn't an admin form.
{% for field in payment_form %}
<p class="{% if field.is_checkbox %}checkboxes {% endif %} ">
{% if field.is_checkbox %}
...
I'm developing a web-app where the user can create multiple related elements and then save those elements to a database. The webapp has no idea of what the primary keys will be in the database so it assigns each element a UUID. These UUIDs are saved with each element in the database. When the webapp sends the data to the webserver to ...
For example, I have an paginator object with a lot of attributes, and don't want do write something like {{ paginate(paginator) }} in templates.
How can a get context automatically in the filter function, like a django register.inclusion_tag(…, takes_context=True)?
Yes, of course, I can do something like paginate(paginator), but it loo...
I'm trying to deploy a django project via mod_python and I keep getting an error saying a handler module is missing.
My apache config:
<Location />
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE bookmarklet_server.settings
PythonOp...
In my views I sometimes use this:
return HttpResponseRedirect("/account/")
But that is hardcoding a url in my view, which I think is not very nice.
So what is the alternative? I know I can generate urls directly from the urls.py file, in my templates, via the {% url %} tag, so there has to be something I can do in my views, right?
...
Hi all,
I'm trying to call a view directly from another (if this is at all possible). I have a view:
def product_add(request, order_id=None):
# Works. Handles a normal POST check and form submission and redirects
# to another page if the form is properly validated.
Then I have a 2nd view, that queries the DB for the product d...