I think the view function is wrong.
This should do:
from django.views.decorators.csrf import csrf_protect
from django.shortcuts impor render
@csrf_protect
def login(request):
return render(request, 'login.html')
2014-06-27 6:03 GMT+02:00 sarfaraz ahmed :
> Hello
>
> I am new to django I am
Hello,
I'm not quite sure what you are trying to do, but with type: "GET"
there is no need to worry about crfs_token.
>From the link you posted:
"""
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
>From your code:
"""
if request.method=='GET':
if request.POST.get('accept'):
bid = QuotedItem.objects.get(id=2)
return render(request, 'bills/p_bill.html', {'bid' : bid})
"""
if the method is "GET", you will never have any POST parameters.
If you want POST para
Ugh , sorry of course we know ... forget what i said ...
2014-06-26 9:48 GMT+02:00 Roman Klesel :
> hard to tell since we do not know what values default_month and month.0 have
> ...
> try to print in the view and examine:
> print type(month[0]), month[0], type(today.month), today.mo
hard to tell since we do not know what values default_month and month.0 have ...
try to print in the view and examine:
print type(month[0]), month[0], type(today.month), today.month
2014-06-25 20:34 GMT+02:00 Lee Hinde :
> with view code like so:
>
> import calendar
> months_choice
Hello,
the {{j.i}} can not work as you expect. If i understand you correctly
you would like to do something like getattr(list, i) in the template.
In order to do this you have 2 possibilities:
1) Write a custom template tag like this
http://stackoverflow.com/questions/844746/performing-a-getattr
Hello,
I would recommend to create a django form and feed the post data to this
form.
Because
1) the form will extract the post data for you
2) in the form you will be able the validate and clean the post data (you
should definitively do that)
The code that saves the data to the form could also l
2013/7/3 Tomas Ehrlich :
> you can use model validation
> https://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects
This sounds very good! :-)
Thanks!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from t
Hello,
I'm programming a database front end. In many cases I want to
constrain the data written to the database. Therefore I implement some
checks either through real database constraints or trough some logic
in the model, so it will throw an exception when the constraints are
not met.
e.g.: uniq
2012/12/17 donarb
>
>
> https://github.com/django/django/commit/c57abd3c29cedcca00821d2a0d5708f10977f3c6
>
>
ahh the commit, thanks!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegrou
Hello Anssi,
thanks! Seems to work. I tried it like this:
from django.db import models
class MyModelBase(models.base.ModelBase):
def __new__(cls, name, bases, attrs):
attr_meta = attrs.pop('Meta', None)
try:
has_cpk= attr_meta.has_composite_primary_key
d be quite easy to accomplish this by paching the django
source. However I'd prefere to do
this by subclassing.
How to do this?
Best regards
Roman Klesel
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, s
2011/7/26 nixlists :
> Is it a best practice to take a bunch of code out to the stored
> procedures as much as possible, or the opposite is true with Django?
I don't want to comment on whether it's best practice or not ...
I was thinking about efficiency:
If the data processing gets too slow doi
Hello,
2011/7/25 nixlists :
> Is there a way to rewrite the dictionary code above to make it more
> readable, and/or rewrite everything in a more efficient manner in
> general?
I also consider myself a beginner in programming but I've been using
django for about 1 year now.
To me the code looks
hmm... strange...
the __unicode__ thing is nothing django-specific. It works in plain
python as well:
It's supposed to work like this:
>>> class TestClass(object):
... def __unicode__(self):
... return "unicode"
... def __repr__(self):
... return "buh"
... def __str__
2011/5/16 maaz muqri :
> I am getting this
>
Poll.objects.all()
> []
What do you get when you do:
print unicode(Poll.objects.all()[0])
?
Regards
Roman
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
Hello Yuka,
2011/4/13 Yuka Poppe :
> You could possibly resort to the extra() queryset method, allthough it eats
> raw sql, its documented in the manual. Im not sure if its in 0.96 though.
Yes, thanks!
I think I found a solution:
hw=Hardware.objects\
.filter(rack__he__isnull
Hello,
I have an old version of django here where the F() object is not
available (0.96).
Is there a chance to reference a field on the same model without using
using F()?
I'd like to write:
hw=Hardware.objects.filter(he=F('rack__he'))
... but there is no F() in this version.
Any ideas?
Rega
2011/2/18 Roman Klesel :
>> I would use pre_save signal for data modification
did not really work. In any case I need to use to_python so that the
ModelForm displays the right value, and then I'm in *BEEP*, since
to_python not only receives the values from the db but also get's
p
Hello Piotr,
2011/2/18 Piotr Zalewa :
>
> I would use pre_save signal for data modification
>
hmm ... this sounds like a good idea. It would make the whole thing a
lot more compact ... I'll give it a try.
Thank's!
Roman
--
You received this message because you are subscribed to the Google Gro
Hello guys,
I'm running django on a legacy database and in some cases the values
stored in the tables have to be converted before the can be displayed
and also have to be converted bevore bein saved to the database.
Example:
A table for storing IP addresses:
The address field contains values th
2011/2/10 :
...
Thanks for the kind words. Your comments are very welcome!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django
2011/2/10 :
'' == None
> False
yes, makes sense ... I was thinking of things like:
if '':
if []:
...
which probably lead me to a wrong conclusion.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to djan
Hello Daniel,
thanks for you reply
2011/2/10 Daniel Roseman :
>> >>> from test_django.roman.models import Jtem
>> >>> o=Jtem.objects.get(pk=29)
>> >>> o.name=''
>> >>> o.save()
>>
>> Now the record looks like this:
>>
>> mysql> select * from roman_jtem where id=29;
>> ++--+--+
>>
Hello community,
I'm using a django version 1.3 beta 1 SVN-15481 and a mysql 5 backend
I have the following field definition in my model:
class Jtem(models.Model):
name=models.CharField(blank=True, null=True, max_length=255)
nachname=models.CharField(max_length=255)
Doing manage.py sync
Hello again,
since no one responded untill now, I'd like to bring this back to attention.
If no one knows an answer to my question, maybe some one could give me
some hint what I could do?
Should I open a bug report?
Thanks in advance!
Roman
--
You received this message because you are subscr
Hello,
I'm using a current SVN checkout of django an I'm having difficulties
creating a custom field.
class ForeignKeyAX(models.ForeignKey):
__metaclass__ = models.SubfieldBase
description = "ForeignKey field prepared for Ajax Autocompletion"
def __init__(self,*args,**kwargs):
27 matches
Mail list logo