Why Django function django.views.static.serve() is insecure?
According to the Documentation using the django.views.static.server() function is: inefficient and insecure. I understand why it's inefficient, but in which aspect is it insecure? ...
According to the Documentation using the django.views.static.server() function is: inefficient and insecure. I understand why it's inefficient, but in which aspect is it insecure? ...
I have a problem with django's MVC. I understand that this is not the traditional MVC, but the documentation emphasizes throughout that it indeed separates presentation from business logic. However, the tutorial comes to a piece of code like this: def vote(request, poll_id): p = get_object_or_404(Poll, id=poll_id) try: ...
Hello Assume I have such simple model: class Foo(models.Model): name = models.CharField(max_length=25) b_date = models.DateField() Now assume that my query result from Foo.objects.all() , I retrieve something like this: [ {'name': 'zed', 'b_date': '2009-12-23'}, {'name': 'amy', 'b_date': '2009-12-6'}, {'name': 'j...
Hello, say I have such model: class Foo(models.Model): name = models.CharField("name",max_length=25) type = models.IntegerField("type number") after doing some query like Foo.objects.filter(), I want to group the query result as such: [ [{"name":"jb","type:"whiskey"},{"name":"jack daniels","type:"whiskey"}], [{"name":"absolute","...
I have a very basic email app. The forms class is: class ContactForm(forms.Form): name = forms.CharField(max_length=100) subject = forms.CharField(max_length=100) sender = forms.EmailField() recipient_list = forms.EmailField() message = forms.CharField(widget=forms.Textarea) cc_myself = forms.BooleanField(initial...
I have a situation where I need to check if a form has m2m relation before saving it in views.py as I am using the same views.py for different models. Example: #models.py class BaseClass(models.Model): # Some generic stuff. class SomeClass(BaseClass): # This class doesnt have any many2many relations class SomeOtherClass(BaseCla...
Simple question. I have bunch of django views. Is there a way to tell django that for each view, use foo(view) instead? Example: Instead of writing @foo @bar @baz def view(request): # do something all the time, I'd like to have def view(request): markers = ['some', 'markers'] and hook this into django: for view in all_the...
Assume I have a such model: class Foo(models.Model): name = models.CharField("ad",max_length=25) type = models.ForeignKey(Type) So at the database I have Foo objects with same name field but different types ie: name type A 1 A 2 B 1 C 2 A 3 B 3 I will use this information inorder to generate a html s...
Greetings I am hacking Django and trying to test something such as: Like woot.com , I want to sell "an item per day", so only one item will be available for that day (say the default www.mysite.com will be redirected to that item), Assume my urls for calling these items will be such: www.mysite.com/item/<number> my model for item: c...
The following is a matplotlib code that generates a scatter plot in as the response. def plot(request): r = mlab.csv2rec('data.csv') fig = Figure(figsize=(6,6)) canvas = FigureCanvas(fig) ax = fig.add_subplot(111) ax.grid(True,linestyle='-',color='gray') ax.scatter(r.x,r.y); response=django.h...
Let's say I have 3 django apps, app Country, app Social and app Financial. Country is a 'master navigation' app. It lists all the countries in a 'index' view and shows details for each country on its 'details' view. Each country's details include their Social details (from the social app) and their Financial details (from the financia...
Sorry if this is a dumb way to ask this... I have a generic list view for the homepage of a site, and would like to use a "homepage" model for informative text on that same page...is it possible? Thanks for your help. models.py from django.db import models class School(models.Model): school_name = models.CharField(max_length=250,...
In chapter 8 of the Django book there is an example showing a fundamental view wrap method, which receives another view method passed in from any single arbitrary URLconf: def requires_login(view): def new_view(request, *args, **kwargs): if not request.user.is_authenticated(): return HttpResponseRedirect('/accoun...
My models: HitCounter: hits = models.PositiveIntegerField(default=0) object_pk = models.TextField('object ID') content_type = models.ForeignKey(ContentType, verbose_name="content cype", related_name="content_type_set_for_%(class)s",) content_object = generic.GenericForeignKey('conte...
I have some codes like this: cats = Category.objects.filter(is_featured=True) for cat in cats: entries = Entry.objects.filter(score>=10, category=cat).order_by("-pub_date")[:10] But, the results just show the last item of cats and also have problems with where ">=" in filter. Help me solve these problems. Thanks so much! ...
Hello there, I came across this blog entry which describes an elegant way of handling results returned from a ChoiceField to a view using a list comprehension technique - one that eliminates empty keys/values without all the intermediate data structures. This particular approach doesn't seem to work for MultipeChoiceFields, though. Is t...
I've searched SO and the Django doc and can't seem to be able to find this. I'm extending the base functionality of the django.contrib.comments app to use the custom permission system that's in my webapp. For the moderation actions, I'm attempting to use a class-based view to handle the basic querying of the comment and permission chec...
In the following code below, how to retrieve the value of id,Id has multiple values in it.How to access the values of id and update it to result1 def parse_results (): try: xml = minidom.parseString(new_results) for xmlchild in xmldoc.childNodes[0].childNodes : result1 = {} result1.update ({'f...
Hello friends, I am new to django and was trying this code in a tutorial. But now i am not able to run my program because of the following error: IndentationError at / ('unexpected indent', ('D:\django_workspace\django_bookmarks\..\django_bookmarks\bookmarks\views.py', 14, 4, ' return HttpResponse(output)\n')) Request M...
Hello I have 3 forms at the same page and each has a different form submit. Such as: <h1>Address</h1> <form method="post" id="adress_form" action=/profile/update/> {{ form_address.as_p }} <p><button type="submit">Save</button></p> </form> <h1>Email Change</h1> <form method="post" id="email_form" action=/profile/update/> {{ form_email...