basically just verify if an object exists and return the object. then based on that perform actions. I'm wondering whats the right way to do it without returning a 404?
try:
listing = RealEstateListing.objects.get(slug_url = slug)
except:
listing = None
if listing:
...
Is it possible to override the html naming of fields in TabularInline admin forms so they won't contain dashes?
I'm trying to apply the knowledge obtained here to create a TabularInline admin form that has the auto-complete feature.
It all works except that Django insists in naming the fields in a tabularinline queryset as something in...
Hi,
On the flex side i have a tree component which gets his Tree data from the backend.
On the backend side we have Django using Pyamf for communication with Flex.
We use MPTT (Modified Preorder Tree Traversal) Dango app to store Categories in a tree like fashion (a category Class has a parent field). We also have an Item Model Class w...
Django is my favorite python web framework. I've tried out others like pylons, web2py, nevow and others.
But I've never looked into TurboGears with much enthusiasm.
Now with TG2 out of beta I may give it a try. I'd like to know what are some of the pros and cons compared to Django.
...
I was wondering if someone could help me out. In some web application, the app will send out emails, say when a new message has been posted. Then instead of signing into the application to post a reply you can just simply reply to the email and it will automatically update the web app with your response.
My question is, how is this do...
In Django / Pinax, I've come across the login form which starts like this :
<form class="login" method="POST" action="">
It works perfectly well. So I assume that either some java-script or something in the Django framework is putting the value into the action attribute. So my questions ;
a) How does Django insert the action?
b) Wh...
In my model I have many to many relationship between 2 tables Users and Groups.
In the admin interface I see the SelectMultiple widget for Groups. Actually, I am using filter_horizontal, I see the available groups and the selected groups in 2 separate lists.
Is it possible to filter the list of available groups that I can see (based on ...
I have had django running with mod_python for awhile now but today I get the following error
MOD_PYTHON ERROR
ProcessId: 4551
Interpreter: 'thatch'
ServerName: 'thatch'
DocumentRoot: '/var/www/thatch'
URI: '/'
Location: '/'
Directory: None
Filename: '/var/www/thatch/'
PathInfo: ''
Phas...
Hello,
I know this may be something stupid but I decided to ask any way.
I've been trying to query something like:
cursor.execute("select col1, col2 \
from my_tablem \
where afield like '%%s%'
and secondfield = %s
order by 1 desc " % (var1, var2) )
Bu...
class Domains(models.Model):
name = models.CharField(max_length=30)
description = models.CharField(max_length= 60)
user = models.ManyToManyField("Users", blank=True, null=True)
def __unicode__(self):
return self.name
class Groups(models.Model):
domain = models.ForeignKey(Domains)
name = models.CharField(m...
Businessmen typically want a web application developed. They are aware of .net or J2EE by names, without much knowledge about either.
Altho' Rails and Django offer for a much better and faster development stack, it is a big task to convince businessmen to use these platforms.
The task begins with introducing Django (or Rails), quoting ...
I would like to audit when a user has experienced an idle timeout in my Django application. In other words, if the user's session cookie's expiration date exceeds the SESSION_COOKIE_AGE found in settings.py, the user is redirected to the login page. When that occurs, an audit should also occur. By "audit", I mean a record should be wri...
class MyUserAdminForm(forms.ModelForm):
class Meta:
model = Users
group = forms.ModelMultipleChoiceField(
queryset=Groups.objects.filter(domain__user=3),
widget=forms.CheckboxSelectMultiple,
)
class UserAdmin(admin.ModelAdmin):
list_display = ('login', 'company', 'userType')
form = MyUserAdminForm
filter_horizontal = ('group',)
a...
Django's views documentation states that "the default 500 view passes no variables to this template and is rendered with an empty Context to lessen the chance of additional errors," but is it okay to use the {% extends %} tag to re-use a base view in the 500 Server Error page (500.html)?
...
I have a site running on django, (but the question applies to anything, php, etc)
Currently I'm using unison to deploy my changes, and I (kinda used to) love it because before that I was doing it manually!!
Now, as I'm getting my feet wet with git, I'm starting to love it! And I'm thinking if maybe I should use it instead of unison to ...
So, here is one of my urls.py
urlpatterns = patterns('items.views',
url(r'^(?P<item_id>[\d+])/$', 'view_listing', name="item_view"),
)
And in my template, I can do this: <a href="{% url item_view 1 %}">here</a> and I'll get a link to the right page. Everything works great!
But, here is another one
urlpatterns = patterns('django....
I am writing a web application that uses ajax to add new forms on the page. Existing forms are made using inlineformset_factory.
When client side gets the form it inserts it in the right position and updates the value of #id_form_type-TOTAL_FORMS" (form_type is name of the form in this example).
Existing forms have name for each field l...
I'm new at this, however, when it comes to configuring mod_python/apache or wsgi/apache I suffer.
I've been able to use the python debugger tool.. pdb.set_trace() to success, especially when using the django development server, i.e. it out puts to the terminal all of the server activity, including the pdb interface.
So, how does one do...
I am new to Satchmo -- picked it up because I needed payment processing for site subscriptions and physical product.
My site will have two classes of users: paid subscribers and free users. Both can order a
physical product. Paid subscribers get an automatic discount on all orders.
I don't see a configuration for this in the admin. (D...
Hi all,
I am using PyAMF to transfer a dynamically generated large image from Flex to Django.
On the Django side i receive the encodedb64 data as a parameter:
My Item model as an imagefield.
What i have trouble to do is saving the data as the File Django Field.
def save_item(request, uname, data):
""" Save a new item """
i...