I have a quite simple query set and a related generic views:
f_detail = {
'queryset': Foto.objects.all(),
'template_name': 'foto_dettaglio.html',
"template_object_name" : "foto",
}
urlpatterns = patterns('',
# This very include
(r'^foto/(?P<object_id>\d+)/$', list_detail.object_detail, f_detail, ),
)
...
I have a model called SimplePage in which I have this line:
category = models.ForeignKey('Category', related_name='items',
blank=True, null=True)
I assumed this will allow me to have SimplePage instances that do not have a Category.
But for some reason, when I try to create a SimplePage in the Admin with ...
I'm serializing User objects to JSON, and I'd like to indicate in the JSON response whether the serialized user is friends with the user making the request.
I've added a to_dict() method to my User model that does the pre-processing necessary to serialize the object--that would be a nice place to add an attribute indicating friendship, ...
Before the question, the background:
I am putting the finishing touches on an API I have written for a Django app utilizing django-piston. The API is able to search by request or IP address which are Request or IPAddress instances respectively. Each request can have 1 or more IPAddress associated with it.
So, for example I have an API...
I would like to write a Django template tag to which I can pass a variable.
I would like the template tag to behave differently depending on what type of model field the variable was derived from (CharField, BooleanField, IntegerField, etc.) as well as other information used in the field's definition (max_length, etc.)
I can pass the v...
I got tinyMCE working for flat pages by copying the change_form.html file and embedding a script element.
I followed the directions here but still have issues. I added this snippet to my Entry model:
class Entry( models.Model ):
class Admin:
# various admin options are here
js = (
'/tiny_mce/tiny_mc...
Hi,
I'm working on my honor society's website, and I'm wondering if (1.) can two websites (Django projects) point to the same database, and (2.) if that's good practice.
Background info: Currently there's only one website, and the users for it are for only for members. For our industry relations part (which we are developing now), we w...
Our site can be accessed from a full browser, from mobile browsers, and from a custom iPhone app. Since the logic is mostly the same regardless of the client, we're using the same views to process all types of requests. But at the bottom of every one of our views, we have something like:
if request.is_mobile():
return render_to_resp...
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
92. response = callback(request, *callback_args, **callback_kwargs)
File "/home/ea/ea-repos/hell/life/views.py" in linkedin_auth
137. token = oauth_linkedin.get_unauthorised_request_token()
File "/home/ea/ea-repos...
I have created a list of 5 users.How do i find out which user has logged in currently ? Also please mention , if there is any way to find out if the super-user has logged in ?
My requirement is , I want to restrict the access of certain pages in the templates only to the superuser .
Thanks in anticipation.
...
Consider the following models and form:
class Pizza(models.Model):
name = models.CharField(max_length=50)
class Topping(models.Model):
name = models.CharField(max_length=50)
ison = models.ManyToManyField(Pizza, blank=True)
class ToppingForm(forms.ModelForm):
class Meta:
model = Topping
When you view the Toppi...
I'm not going to make this into a Rails vs Framework X discussion, there's plenty of those already. After seriously contemplating what framework I'm going to use for my next deployment, I decided it's very difficult to pass up the out of the box REST exposure Rails gives you for minimal work back. This is something that requires slightly...
Hello,
Assume I have 3 Models: City, Area, Entry.
Each city has several Areas and each area can have several entries BUT for "now", there can be will be only one active Entry and it will be shown. So in logic:
Note that each city, area, entry will be using slug variable of related model class
Format will be in such:
www.mysite.com/<...
Hi!
I have an hierarchy of models that consists of four levels, all for various good reasons but which to explain would be beyond the scope of this question, I assume.
So here it goes in pseudo python:
class Base(models.Model):
...
class Top(models.Model):
base = FK(Base)
class Middle(models.Model):
top = FK(Top)
crea...
A django web app needs to make ajax calls to an external url. In development I serve directly from django so I have a cross domain problem. What is the django way to write a proxy for the ajax call?
...
I have a database object called manor_stats, with around 30 fields. For most rows, most of these fields will be null.
In my template, I'd like to loop through all the fields in the row, and print info for only the fields that aren't null.
For example, there's a field called "name": I'd like to print <li>Name: {{ manor_stats.name }}</...
Hello,
In a django app, I have models for a Word (to be learned), a Student (learning it), and StudentWord is a table to handle the many to many relationship:
class Word(models.Model):
word = models.CharField(max_length=80)
image = models.ForeignKey(Image)
language = models.ForeignKey(Language)
def __unicode__(self):
...
I see these nice "local flavors" for Canada, but they're only form fields. How would I use them in my model? I can create them all as CharFields sure, but then is there a way to set the default form widget from inside the model so that when I create a ModelForm it'll use them?
...
Hello
I would like to redirect my users to specific location areas in my website, by detecting their location from their IP address.
What would be the best way to achieve this under Django 1.1.1 ?
Thanks
Edit: I want city based locationing on europe.
...
I have created a Django model called Person, which has got a 'user' ForeignKey to django.contrib.auth.models.User
How can I set the ordering on class Person to self.user.first_name, self.user.last_name?
...