Am in the process of developing some app for Facebook using Django! I've started first by building the app in Django and its shaping up pretty well, now am wondering how can I make it a Facebook app.
I would really appreciate real world example for Facebook apps made with Django.
...
I use flup as fastcgi server for Django.
Please explain to me how can I use singleton?
I'm not sure I understand threading models for Flup well.
...
If I have created a template tag:
@register.simple_tag
def last_books(a_cat, cutoff=5):
objects = Books.objects.filter(category=a_cat)
return objects[:cutoff]
How can I do something like this in my template:
{% for book in last_books 'Sports' 3 %}
I am currently getting this error:
'for' statements should use the format...
I'm currently converting my site from PHP to Django, but as I'm new to Python I'm struggling to get my head around a few thingss.
Sometimes I have incomplete dates in my database (ie I may not know the day or even the month), so currently have three integer fields: date_year, date_month and date_day.
I noticed that MySQL accepted 'part...
I am using Django admin for managing my data. I have the following tables: Users, Groups, and Domains. Users has a many-to-many relationship with both Groups and Domains. Domains has a one-to-many relationship with Groups. When I remove a User from a Domain, I also want to remove any entries in Users_Groups for that particular User and G...
I'd like to save my files using the primary key of the entry.
Here is my code:
def get_nzb_filename(instance, filename):
if not instance.pk:
instance.save() # Does not work.
name_slug = re.sub('[^a-zA-Z0-9]', '-', instance.name).strip('-').lower()
name_slug = re.sub('[-]+', '-', name_slug)
return u'files/%s_%s.n...
I have a list and I am appending a dictionary to it as I loop through my data...and I would like to sort by one of the dictionary keys.
ex:
data = "data from database"
list = []
for x in data:
dict = {'title':title, 'date': x.created_on}
list.append(dict)
I want to sort the list in reverse order by value of 'date'
...
OMG!
What an apparent problem... my django based scripts have locked my sqlite db...
Does anyone know how to fix?
...
I am a long time PHP user when it comes to web applications and am mostlz comfortable with it. However, I have a one semi-large project whose maintenance / extensibility has reached its end of a life cycle. I was weighing on different PHP frameworks (there were no when the project originated), since it is the way to go for this project, ...
I am adding custom validation to my forms and custom fields in my Django app. I would like to be able to modify the value of a field when triggering an error. For example, if there is an error, the form should be redisplayed with the field value corrected by clean() and an error message "Data has been corrected below. Click save again to...
I have a few complex GUI elements (like a custom calendar with many days that can be highlighted) that appear along with standard django form input fields. I want to process the data I/O from these complex forms along with the Django forms.
Previously I would use AJAX requests to process these custom GUI elements on my HTML form after ...
So I have a model with a ManyToManyField called tournaments. I have a ModelForm with two tournament fields:
pay_tourns = forms.ModelMultipleChoiceField(
queryset=Tourn.objects.all().active().pay_tourns(),
widget=forms.CheckboxSelectMultiple())
rep_tourns = forms.ModelMultipleChoiceField(
...
both seems to be pretty cool
which is to be in used in what scenario ?
...
The whole point of an MVC framework is to separate design (templates) from logic (controllers). However, template languages often afford a limited degree of "design logic" to occur. This includes basic if statements, loops, filtering, etc.
I've created a Django template tag that can take any list or QuerySet and "pagify" it. It split...
I've been using a pre 1.0 version of django (a dev version somewhere around .97),
And now I'm considering upgrading to 1.x (I grabbed the latest thing from the svn).
There have been some changes to the way the admin interface works, so now I have to edit all my models.py files and create new admin.py files.
I remember seeing a tool t...
I have been struggling with choosing a methodology for creating a RESTful API with Django. None of the approaches I've tried seem to be the "silver" bullet. WAPI from http://fi.am is probably the closest to what I would like to accomplish, however I am not sure if it is acceptable in a true RESTful API to have parameters that are resourc...
Here is the field declaration in a form:
max_number = forms.ChoiceField(widget = forms.Select(),
choices = ([('1','1'), ('2','2'),('3','3'), ]), initial='3', required = True,)
I would like to set the initial value to be 3 and this doesn't seem to work. I have played about with the param, quotes/no quotes etc... b...
Hey everyone,
I've made a simple site in Django. The urls I use are http::/www.example.com/nl/ and http://www.example.com/fr/.
My Django urls.py has the following line:
(r'^(?Pnl|fr)/', 'example.views.index'),
In example.views.index I check the language parameter. If it's 'nl' I show a template. If it's 'fr', I show a different templ...
Suppose I have a URLconf like below, and 'foo' and 'bar' are valid values for page_slug.
urlpatterns = patterns('',
(r'^page/(?P<page_slug>.*)/', 'myapp.views.someview'),
)
Then, I could reconstruct the URLs using the below, right?
>>> from django.core.urlresolvers import reverse
>>> reverse('myapp.views.someview', kwargs={'page_...
for u in Users.objects.all():
for g in u.group.all():
if g not in Groups.objects.filter(domain__user=u.id):
u.group.filter(id=g.id).delete()
How do I delete the entries in relationship table. In this case I have a many to many relationship between Groups and Users. The delete statement in the above code delete...