hey,
i want to use 2 model in one foreignkey
it means;
i have 2 model named screencasts and articles. and i have a fave model, for favouriting this model entrys. can i use model dynamicly ?
class Articles(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()
class Casts(models.Model):
title = ...
I've been trying to understand what's the optimal way to do Ajax in Django. By reading stuff here and there I gathered that the common process is:
formulate your Ajax call using some JavaScript library (e.g., jQuery), set up a URL pattern in Django that catches the call and passes it to a view function
in the Python view function retr...
Hello, I'm building a site with django that lets users move content around between a bunch of photo services. As you can imagine the application does a lot of api hits.
for example: user connects picasa, flickr, photobucket, and facebook to their account. Now we need to pull content from 4 different apis to keep this users data up to da...
I have an inlineformset which displays a maximum of 10 forms. But when I try to save/update the formset these extra objects ( which are blank in content ) also get saved. So everytime the formset is saved/edited these blank records keep entering into the database. What could the reason be ?
...
On a django site, I want to generate an excel file based on some data in the database.
I'm thinking of using xlwt, but it only has a method to save the data to a file. How can get the file to the HttpResponse object? Or maybe do you know a better library?
I've also found this snippet but it doesn't do what I need. All I want is a way t...
How do you define a specific ordering in Django QuerySets?
Specifically, if I have a QuerySet like so: ['a10', 'a1', 'a2'].
Regular order (using Whatever.objects.order_by('someField')) will give me ['a1', 'a10', 'a2'], while I am looking for: ['a1', 'a2', 'a10'].
What is the proper way to define my own ordering technique?
...
Hi, I've had some problems with a Django application after I deployed it. I use a Apache + mod-wsgi on a ubuntu server. A while after I reboot the server the time goes foobar, it's wrong by around -10 hours. I made a Django view that looks like:
def servertime():
return HttpResponse( datetime.now() )
and after I reboot the server an...
I've got a bunch of classes that inherit from a common base class. This common base class does some cleaning up in its delete method.
class Base(models.Model):
def delete(self):
print "foo"
class Child(Base):
def delete(self):
print "bar"
super(Child, self).delete()
When I call delete on the Child from...
This is a newbie theory question - I'm just starting to use Python and looking into Django and orm. Question: If I develop my objects and through additional development modify the base object structures, inheritance, etc. - would Django's ORM solution modify the database automatically OR do I need to perform a conversion (if the app is ...
Hi,
Let say that I have:
proj1/app1
proj1/app1/templatetags/my_shared_tags.py
proj1/app2
proj1/templates
proj1/templates/app1/index.html
proj1/templates/app2/index.html
Now, how can I reuse a tag from my_shared_tag.py from app1 in my app2.
...
Hello,
I'm building a web application with Django. The reasons I chose Django were:
I wanted to work with free/open-source tools
I like Python and feel it's a "long term" language, whereas regarding Ruby I wasn't sure, and PHP seemed like a huge hassle to learn.
I'm building a prototype for an idea and wasn't thinking too much about t...
Is it possible to run django without shell access? My hoster supports the following for 5€/month:
python (I assume via mod_python)
mysql
There is no shell nor cronjob support, which costs additional 10€/month, so I'm trying to avoid it.
I know that Google Apps also work without shell access, but I assume that is possible because of...
I have the concept of a team in my django app.
class Team(models.Model):
name = models.CharField(max_length=200)
#snip
team_members = models.ManyToManyField(User)
I would like to fetch all teams the currently logged in user is member of. Something along the lines of
Team.objects.all().filter(request.user.id__in = team_me...
I'd like to call the equivalent of manage.py loaddata from a Django view. I'd like to be able to specify where to load the data from and which application to load it into.
Any ideas?
...
I'm trying to define a many-to-one field in the class that is the "Many". For example, imagine a situation where a user can only be a member of one group but a group can have many users:
class User(models.Model):
name = models.CharField()
class Group(models.Model):
name = models.CharField()
# This is what I want to do -> ...
I'm new, and confused. I want to create a module that keeps track of the "top hit" instances of both an article and a blog model. I don't want to touch the code for the article or blog models. Is this a candidate for middleware? looking at the HttpRequest.path?
Thanks
...
I have a Django model like:
class Category(models.Model):
status=models.CharField(max_length=16)
machineName=models.CharField(max_length=50)
readableName=models.CharField(max_length=100)
description=models.CharField(max_length=1024)
parents=models.ManyToManyField('self')
Where each category may exist in many parent...
So, I'm passing an object with a "content" property that contains html.
<div>{{ myobject.content }}</div>
I want to be able to output the content so that the characters are rendered as the html characters.
The contents of "conent" might be: <p>Hello</p>
I want this to be sent to the browser as: pHello/p>
Is there something I can...
Hello!
Is there any difference in using login_required decorator in urls.py and in views.py ?
If I put this line:
url(r'^add/$', login_required(views.add_media), name = 'add_media_action')
into urls.py will I achieve the same effect as decorating add_media function in views.py:
@login_required
def add_media(request):
...
...
I was looking at a SO member's open source project. It was a web framework written in C++.
Now you are all probably ready to respond about how C++ is a horrible language to do websites in, and that in websites, the bottleneck is in the database.
But... I read this post:
http://art-blog.no-ip.info/cppcms/blog/post/42
and in there he m...