Saturday, August 31, 2013

Django-registration reset password templates not getting picked up

I am getting a bit of a problem with django-registration

django-registration was installed in a venv using pip. I have version 1.0 of django-registration and 1.5.1 of Django . I have the templates/registration directory with the templates for the pages that are to display the different pages. 
login, logout, register work fine. Proper templates get picked up - and I have modified them according to my needs. 

However, now I am trying to loop in the password reset functionality. However, when I hit the URL http://127.0.0.1:8000/accounts/password/reset/ it is picking up the default django admin reset url. I cant get this to pickup my templates. Following are my settings: 

in settings.py : 

INSTALLED_APPS = (
'registration',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
   ...
)

in urls.py 

urlpatterns = patterns('',
    #django-registration
    url(r'^accounts/',include('registration.backends.default.urls')),
    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
   ...
)

what else do i need to do ? As per the django-registration documentation, the auth_urls.py is supposed to be automatically included with the default backend. But apparently, there is some disconnect here. 

Regards,
Vibhu
--
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: MongoDB and Django

It is not supported by default.

Check django-nonrel and django-mongodb-engine projects. I am not sure if these projects are still available.


On 31 August 2013 05:22, Timothy Makobu <makobu.mwambiriro@gmail.com> wrote:
Hi,

Is MongoDB support coming to standard Django?

regards,
Tim

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Christiano Anderson 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Django driving me nuts

Try the Django IRC channel for faster answers

https://code.djangoproject.com/wiki/IrcFAQ

If you are learning Python at the same time learning Django then it can be a tough climb

K


On Saturday, August 31, 2013 5:50:19 AM UTC-7, Gerd Koetje wrote:
Why is it so hard to get as a former php programmer.

anyone willing to help me over this part?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

On 1/09/2013 2:11am, Gerd Koetje wrote:
> to explain myself a bit more:
>
> gerd12 = should be valid
> gerd1234 = should be valid
> gerd 1234 = should not be valid
> %$$%%#$ = should not be valid
> gerd123456 - should not be valid

You have just specified five cases for unit tests. Start there and
experiment with re until they all pass. Beautiful!

>
> etc etc
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: New to Django and developing website based on a Framework. What is the best order to develop website?

Add features as you need them. If you are going to launch in multiple languages I'd add that early on. Adding the stock authorization is pretty safe as well.

Learn and use the testing framework as much as possible.

K


On Saturday, August 31, 2013 1:07:46 PM UTC-7, Mark Strickland wrote:
I am starting to develop a website using django and I am wondering if I should add all the extra modules (authorization, mutliLanguages, comments), at the beginning, or should I develop the basic pages (apps) and then go back and add in the requirements for the modules I want to add.


I am trying to develop a website using django, like my current website www.serviidb.com created in drupal.,

Any advice would be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Why does the save form order make any difrance?

anyone?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

verify before make changes?

def delete_item(request, item_id):
item = get_object_or_404(Item, pk=item_id)
return render(request, 'delete_item.html', {'item':item, 'item_id':item_id},)

def delete_confirmed(request, item_id):
query = get_object_or_404(Item, pk=item_id)
query.delete()
return render(request, 'delete_success.html', {'query':query},)

I came up with these functions that delete an object from the db after a user confirmation. However, these do not check if the object actually exist and or already deleted.

How do I make these functions to verify before making any hits or changes to db?

Likewise, I will derive the understanding from it and apply to my save function, in order that I might avoid duplication of items in my db.

I'm using modelforms for the save form though

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Problems using django 1.6.x and uwsgi

Hi Rafael,

Rafael Reuber <rafaelreuber@gmail.com> writes:
> I'm working on a project that needs a feature that it's only available on
> the 1.6.x version. But I'm having problems when I run it using uswgi.
> Apparently it could be a bug on 1.6.x because when I run the project using
> 1.5.x the error doesn't appear.
>
> uwsgi --http :8000 --wsgi-file drover/wsgi.py
> ...
> line 49, in _setup
> self._wrapped = Settings(settings_module)
> File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py",
> line 132, in __init__
> % (self.SETTINGS_MODULE, e)
> ImportError: Could not import settings 'drover.settings' (Is it on
> sys.path? Is there an import error in the settings file?): cannot import
> name BaseHandler

python cannot find the settings module. That might be caused by the
change of the project layout. When you run django_admin shell, is python
able to import the settings moduke?


You might want to set PYTHONPATH;

uswgi .., --env PYTHONPATH=...


Alternativly, I'd suggest to use virtualenv/pip. It saves you from a lot
of hassles in the long run, especially when you have to deal with
multiple projects or multiple versions at the same time.


Kind regards

Michael

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

New to Django and developing website based on a Framework. What is the best order to develop website?

I am starting to develop a website using django and I am wondering if I should add all the extra modules (authorization, mutliLanguages, comments), at the beginning, or should I develop the basic pages (apps) and then go back and add in the requirements for the modules I want to add.


I am trying to develop a website using django, like my current website www.serviidb.com created in drupal.,

Any advice would be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Why does the save form order make any difrance?

if u need to see any other code let me know

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Why does the save form order make any difrance?

Hi,


Why does this save sometimes not save all forms
If i set form8 at the top it doesnt save form 8
When i set it at the bottom it does save form 8, but not any others

without the form8 all works


if request.POST:

        form = ProfielenForm(request.POST, instance=request.user.profile)
        form2 = ProfielenForm2(request.POST, instance=request.user.profile)
        form3 = ProfielenForm3(request.POST, instance=request.user.profile)
        form4 = ProfielenForm4(request.POST, instance=request.user.profile)
        form5 = ProfielenForm5(request.POST, instance=request.user.profile)
        form6 = ProfielenForm6(request.POST, instance=request.user.profile)
        form7 = ProfielenForm7(request.POST, instance=request.user.profile)
        form8 = ProfielenForm8(request.POST, instance=request.user.profile)



        if form7.is_valid():
            form7.save()

        if form6.is_valid():
            form6.save()

        if form5.is_valid():
            form5.save()

        if form4.is_valid():
            form4.save()

        if form3.is_valid():
            form3.save()

        if form2.is_valid():
            form2.save()

        if form.is_valid():
            form.save()

        if form8.is_valid():
            form8.save()

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: JSON or YAML?

Thanks for your input everybody!


On Sat, Aug 31, 2013 at 10:16 AM, Agnese Camellini <agnese.camellini@gmail.com> wrote:
I'm using JSON becuase of it's compatibility with javascript and python both. I never used YAML but i think the compatibility's problem are bigger with YAML than json.

My 2 cents.
Agnese


2013/8/31 Andre Terra <andreterra@gmail.com>
It depends on where your data is coming from. YAML has less cruft in it, so if you're writing your own serializer you can consider it to have an advantage over JSON.

OTOH, many applications can already export to JSON, so you can leverage that if that's the case.

Finally, If you're writing anything by hand, YAML is much faster.


Cheers,
AT


On Fri, Aug 30, 2013 at 4:55 PM, Rich Haase <rdhaase@gmail.com> wrote:
Personal preference.  Python has excellent libraries to support parsing both JSON and YAML.

Sent from my iPhone

On Aug 30, 2013, at 7:34 AM, Floor Tile <vloertegel@gmail.com> wrote:

Helle everybody,

Just a short and simple question:

It seams that both JSON and YAML can be used for initial data loading. (among other data types but I don't care about them for the moment)
But can't figure out what the up and/or downsides of them are.
Is it purely a matter of personal preference or there one better to use than the other for initial data loading. And which one would be the most preferred, if this is the case?

Many thanks in advance!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: How to require selection of a M2M with intermediate table/model during admin record creation?

Another application of the validation occurred to me:  Since multiple rows can be added to the form, I would want to check for and reject multiple selections of the same Position title.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

i gues im learning it the hard way atm.
Just wanna convert my php application to python, but its hard when i miss out on some basic stuff. giving me headpains haha :D

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

yeah i really should do more python learning.
and i will do :D

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

stupid me, its almost like php

 if testdata == False:

fixed it



Thanks alot for your help all.
Appreciated 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

test(data) returns True if the string is acceptable, and False if it's not. 

But False is an object, it's not the the string "False" - I'd strongly recommend you start with a Python tutorial before moving on to your Django project. 

Cheers; 


On Sat, Aug 31, 2013 at 7:27 PM, Gerd Koetje <deonlinefotograaf@gmail.com> wrote:
think i fixed the true/false thing, return True was on the wrong indent

it still doesnt trow the error , so i gues my if testdata us False:  is wrong?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

think i fixed the true/false thing, return True was on the wrong indent

it still doesnt trow the error , so i gues my if testdata us False:  is wrong?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

Because the indentation is not correct, and doesn't correspond to what I sent you.

`return True` should be 4 chars left of where it currently is.


On Sat, Aug 31, 2013 at 7:23 PM, Gerd Koetje <deonlinefotograaf@gmail.com> wrote:
it somehow keeps returning True on everything

accepted = string.letters + string.digits
max_numbers = 4


def test(word):
    numbers = 0
    for c in word:
        if c.isdigit():
            numbers += 1
        if not c in accepted or numbers > max_numbers:
           return False
        return True

# profielnaam
class ProfielenForm(forms.ModelForm):


    def clean_profielnaam(self):

        logger.debug('>>>>>>>>>>>FORMS<<<<<<<<< %s', accepted)


        data = self.cleaned_data['profielnaam']
        testdata = test(data)
        logger.debug('>>>>>>>>>>>FORMS<<<<<<<<<< >>>>>DATA<<<<< %s', testdata)

        if testdata is "False":
            raise forms.ValidationError("Je mag alleen tekst en cijfers gebruiken en geen spaties")

        return data

    class Meta:
        model = Profielen
        fields = ('profielnaam',)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

it somehow keeps returning True on everything

accepted = string.letters + string.digits
max_numbers = 4


def test(word):
    numbers = 0
    for c in word:
        if c.isdigit():
            numbers += 1
        if not c in accepted or numbers > max_numbers:
           return False
        return True

# profielnaam
class ProfielenForm(forms.ModelForm):


    def clean_profielnaam(self):

        logger.debug('>>>>>>>>>>>FORMS<<<<<<<<< %s', accepted)


        data = self.cleaned_data['profielnaam']
        testdata = test(data)
        logger.debug('>>>>>>>>>>>FORMS<<<<<<<<<< >>>>>DATA<<<<< %s', testdata)

        if testdata is "False":
            raise forms.ValidationError("Je mag alleen tekst en cijfers gebruiken en geen spaties")

        return data

    class Meta:
        model = Profielen
        fields = ('profielnaam',)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

like this?


import string
accepted = string.letters + string.digits
max_numbers = 4

def test(word):
    numbers = 0
    for c in word:
        if c.isdigit():
            numbers += 1
        if not c in accepted or numbers > max_numbers:
           return False
        return True

# Create profiel

# profielnaam
class ProfielenForm(forms.ModelForm):




    def clean_profielnaam(self):
        data = self.cleaned_data['profielnaam']
        if test(data) is False:
            raise forms.ValidationError("Je mag alleen tekst en cijfers gebruiken en geen spaties")

        return data

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

Oh, I thought you needed only 4 total chars. 


Using a regex probably is a bit overkill here:

>>> import string
>>> accepted = string.letters + string.digits
>>> max_numbers = 4
>>> 
>>> def test(word):
...     numbers = 0
...     for c in word:
...         if c.isdigit():
...             numbers += 1
...         if not c in accepted or numbers > max_numbers:
...             return False
...     return True
... 
>>> 
>>> test('gerd12')
True
>>> test('gerd1234')
True
>>> test('gerd 1234 ')
False
>>> test('gerd 1234')
False
>>> test('%$$%%#$')
False
>>> test('gerd123456')
False



On Sat, Aug 31, 2013 at 6:11 PM, Gerd Koetje <deonlinefotograaf@gmail.com> wrote:
to explain myself a bit more:

gerd12 = should be valid
gerd1234   = should be valid
gerd 1234 = should not be valid
%$$%%#$ = should not be valid
gerd123456 - should not be valid

etc etc

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

im working with this code in my forms.py btw.
I see some guys do it in models.py instead

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

to explain myself a bit more:

gerd12 = should be valid
gerd1234   = should be valid
gerd 1234 = should not be valid
%$$%%#$ = should not be valid
gerd123456 - should not be valid

etc etc

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

same result still can input spaces weird chars and more then 4 numbers

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

Oh, yes, we need to search for the end of the string:

r'^[a-zA-Z0-9]{1,4}$'


On Sat, Aug 31, 2013 at 6:03 PM, Gerd Koetje <deonlinefotograaf@gmail.com> wrote:
that still allows space,weird chars and more then 4 numbers

input: 

dfdfdf565665&^^^


got saved



    def clean_profielnaam(self):
        data = self.cleaned_data['profielnaam']
        if not re.match(r'^[a-zA-Z0-9]{1,4}', data):
            raise forms.ValidationError("Je mag alleen tekst en cijfers gebruiken en geen spaties")

        return data

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

that still allows space,weird chars and more then 4 numbers

input: 

dfdfdf565665&^^^


got saved



    def clean_profielnaam(self):
        data = self.cleaned_data['profielnaam']
        if not re.match(r'^[a-zA-Z0-9]{1,4}', data):
            raise forms.ValidationError("Je mag alleen tekst en cijfers gebruiken en geen spaties")

        return data

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Form validation number and text only no space mac 4 numbers

Change you regex to: r'^[a-zA-Z0-9]{1,4}'


On Sat, Aug 31, 2013 at 5:41 PM, Gerd Koetje <deonlinefotograaf@gmail.com> wrote:
Hi all,

How do i valididate for this?

- numbers and text only , no spaces
- max 4 number




    def clean_profielnaam(self):
        data = self.cleaned_data['profielnaam']
        if not re.match(r'^[a-z][0-9]+', data):
            raise forms.ValidationError("Je mag alleen tekst en cijfers gebruiken en geen spaties")

        return data

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Form validation number and text only no space mac 4 numbers

Hi all,

How do i valididate for this?

- numbers and text only , no spaces
- max 4 number




    def clean_profielnaam(self):
        data = self.cleaned_data['profielnaam']
        if not re.match(r'^[a-z][0-9]+', data):
            raise forms.ValidationError("Je mag alleen tekst en cijfers gebruiken en geen spaties")

        return data

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: list(form) makes my form not safe anymore

When i use it with list(form)
It shows the form normally, but when i save the form, nothing gets saved, no errors also.

im trying a difrant approach now:

Im makking multiple forms on forms.py   each with the fields i want in it.

Code so far, seems to work only when i do for before form2 it wont save form, when i di form2 and then form  then it works like a charm


Views.py

@login_required
def create(request):

    if request.POST:
        logger.debug('>>>>>>>>>>>POST POST POST<<<<<<<<<<<<<<<')
        form = ProfielenForm(request.POST, instance=request.user.profile)
        form2 = ProfielenForm2(request.POST, instance=request.user.profile)

        if form2.is_valid():
            form2.save()

        if form.is_valid():
            form.save()



            return HttpResponseRedirect('/profielen/all')
    else:

        user = request.user
        profile = user.profile
        form = ProfielenForm(instance=profile)
        form2 = ProfielenForm2(instance=profile)


    args = {}
    args.update(csrf(request))
    args['context_instance'] = RequestContext(request)
    args['form'] = form
    args['form2'] = form2


    return render(request, 'create_profiel.html', args)





create_profiel.html

{% extends "base.html" %}

{% block sidebar %}

<ul>
    <li><a href="/profielen/all">Cancel</a></li>
</ul>
{% endblock %}

{% block content %}


<form action="/profielen/create/" method="post">{% csrf_token %}

<!-- first -->
<div id="tabeltop">Kies een profielnaam</div>
<div id="tabel">

<div class="fieldWrapper">
{{ form.as_ul }}
</div>

<div style="clear: both;"></div>

</div>


<br>


    <!-- first -->
<div id="tabeltop">anders</div>
<div id="tabel">

<div class="fieldWrapper">
{{ form2.as_ul }}
</div>

<div style="clear: both;"></div>

</div>


<br>







<input type="submit" name="submit" value="Update">
</form>

{% endblock %}





forms.py

class ProfielenForm(forms.ModelForm):

    class Meta:
        model = Profielen
        fields = ('profielnaam',)



class ProfielenForm2(forms.ModelForm):


    #kleurogen = forms.ModelMultipleChoiceField(queryset=Keuzes.objects.filter(groep_id='kleurogen'))
    #lengtehaar = forms.ModelMultipleChoiceField(queryset=Keuzes.objects.filter(groep_id__name='lengtehaar'))

    burgelijkestaat = forms.ModelMultipleChoiceField(queryset=Burgelijkestaat_data.objects, widget=forms.CheckboxSelectMultiple(), required=False)

    class Meta:
        model = Profielen
        fields = ('burgelijkestaat',)

    class Media:

            css = {
            'all': 'checkbox.css',
            }

    def __init__(self, *args, **kwargs):
        super(ProfielenForm2, self).__init__(*args, **kwargs)
        self.fields['burgelijkestaat'].widget.attrs['class'] = 'checkboxen'









--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: list(form) makes my form not safe anymore

Ah, I see. Sorry.

Applying list() to the form at the end of the function does not affect the form.is_valid() you're doing before or the form at all. So your problem must be another kind.

So I must repeat what someone said in your other thread: Please describe your problem further. Why doesn't it save? Which exception is thrown?

Am Samstag, 31. August 2013 15:43:22 UTC+2 schrieb Gerd Koetje:
thats not what i trying todo

Im seperating the entire form in difrant sections of the layout

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: list(form) makes my form not safe anymore

thats not what i trying todo

Im seperating the entire form in difrant sections of the layout

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: list(form) makes my form not safe anymore

If you don't want a particular field to display, then don't include it into your form. Not showing it doesn't exclude it from form processing, so it's a security risk.

You can exclude fields with the exclude attribute of the forms inner Meta class: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#selecting-the-fields-to-use
Or even better, use include and select explicitly which fields should be used.

If you want to/must set the excluded field before saving the model instance, you got to do instance = save(commit=False) and then edit the instance. See the "Note" box just below the link above.



Am Samstag, 31. August 2013 15:21:24 UTC+2 schrieb Gerd Koetje:
atleast not with this code to seperate it

{% for field in form|slice:"1:8" %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: list(form) makes my form not safe anymore

atleast not with this code to seperate it

{% for field in form|slice:"1:8" %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: list(form) makes my form not safe anymore

without the list(form) part that doesnt seem to work

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: list(form) makes my form not safe anymore

As far as I understand, you want to iterate over all form fields. Someone correct me if I'm wrong, but I've never seen anyone trying to achieve this via list(form).

Anyway, forms are iterable, so you can iterate over them in the templates:

<form action="/contact/" method="post">      {% for field in form %}          <div class="fieldWrapper">              {{ field.errors }}              {{ field.label_tag }} {{ field }}          </div>      {% endfor %}      <p><input type="submit" value="Send message" /></p>  </form>


https://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields

Am Samstag, 31. August 2013 01:06:31 UTC+2 schrieb Gerd Koetje:

Why does list(form) make my form not safe anymore?




<code>
@login_required
def create(request):

    if request.POST:
        logger.debug('>>>>>>>>>>>POST POST POST<<<<<<<<<<<<<<<')
        form = ProfielenForm(request.POST, instance=request.user.profile)
        if form.is_valid():
            form.save()

            return HttpResponseRedirect('/profielen/all')
    else:

        user = request.user
        profile = user.profile
        form = ProfielenForm(instance=profile)

    args = {}
    args.update(csrf(request))
    args['context_instance'] = RequestContext(request)
    args['form'] = list(form)

    return render(request, 'create_profiel.html', args)
</code>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Django driving me nuts

Hope anyone can tell me why it doesnt save th eform anymore when i use list(form)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Django driving me nuts

https://groups.google.com/forum/#!topic/django-users/fgGyE_UPWq0

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Django driving me nuts

Please describe your problem a bit more and/ or show code samples? We can help out if we understand the issue.


On Sat, Aug 31, 2013 at 2:50 PM, Gerd Koetje <deonlinefotograaf@gmail.com> wrote:
Why is it so hard to get as a former php programmer.

I'm trying to cut my form in difrant sections , what seemed to work when i use list(forms)
But then my forms dont save anymore

anyone willing to help me over this part?



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Sithu Lloyd Dube

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Django driving me nuts

Why is it so hard to get as a former php programmer.

I'm trying to cut my form in difrant sections , what seemed to work when i use list(forms)
But then my forms dont save anymore

anyone willing to help me over this part?



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: db queries made twice

Thanks, though disabling django_toolbar completely (removing the
middleware, and the entry in INSALLED_APPS) did not helped.

Regards,
Marcin

On 04:34 Sat 31 Aug , Tomáš Ehrlich wrote:
> Other option is set SHOW_TEMPLATE_CONTEXT to False
> in DEBUG_TOOLBAR_CONFIG.
>
> See https://github.com/django-debug-toolbar/django-debug-toolbar#configuration
>
> Dne sobota, 31. srpna 2013 13:24:54 UTC+2 Tomáš Ehrlich napsal(a):
> >
> > Hi,
> > disable Template panel in debug_toolbar and try again.
> >
> > Debug toolbar hits database when evaluating template context.
> >
> >
> > Cheers,
> > Tom
> >
> > Dne Sat, 31 Aug 2013 12:09:00 +0100
> > Marcin Szamotulski napsal(a):
> >
> > > Hello,
> > >
> > > I am using django-1.6.b2 on a localserver (./manage.py runserver) and
> > > for every request I have the chain of db lookups made twice. For
> > > example my log looks something like this (after enabling
> > > django.db.backands logger):
> > >
> > > # HERE VIEW IS CALLED
> > > (0.001) SELECT "django_session"."session_key",
> > "django_session"."session_data", "django_session"."expire_date" FROM
> > "django_session" WHERE ("django_session"."session_key" =
> > '2dh8ly6cfqkyiauv8co5h1vossjg70ru' AND "django_session"."expire_date" >
> > '2013-08-31 11:04:33.597734+00:00' );
> > args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31
> > 11:04:33.597734+00:00')
> > > (0.001) SELECT "auth_user"."id", "auth_user"."password",
> > "auth_user"."last_login", "auth_user"."is_superuser",
> > "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
> > "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
> > "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ;
> > args=(1,)
> > >
> > > #... (AND SO ON)
> > >
> > > # HERE VIEW CALL IS FINISHED
> > > [31/Aug/2013 12:04:33] "GET /coot/ HTTP/1.1" 200 220974
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/css/style.css HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery.js HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery-ui.js HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/js/posts.js HTTP/1.1" 304
> > 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/js/confirm.js HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/css/posts.css HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET
> > /site_media/static/debug_toolbar/css/toolbar.min.css HTTP/1.1" 304 0
> > > [31/Aug/2013 12:04:34] "GET
> > /site_media/static/debug_toolbar/js/toolbar.min.js HTTP/1.1" 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/pics/django_logo.png
> > HTTP/1.1" 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/pics/python_logo.png
> > HTTP/1.1" 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/css/whitey.png HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/css/stressed_linen.png
> > HTTP/1.1" 304
> > >
> > > # DB LOOKUPS ONCE AGAIN:
> > > (0.001) SELECT "django_session"."session_key",
> > "django_session"."session_data", "django_session"."expire_date" FROM
> > "django_session" WHERE ("django_session"."session_key" =
> > '2dh8ly6cfqkyiauv8co5h1vossjg70ru' AND "django_session"."expire_date" >
> > '2013-08-31 11:04:33.597734+00:00' );
> > args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31
> > 11:04:33.597734+00:00')
> > > (0.001) SELECT "auth_user"."id", "auth_user"."password",
> > "auth_user"."last_login", "auth_user"."is_superuser",
> > "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
> > "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
> > "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ;
> > args=(1,)
> > >
> > > ... (AND SO ON)
> > >
> > >
> > > any ideas why?
> > >
> > > The views (as it is not just one) returns using render(). This also
> > > happens when using DetailedView cbv.
> > >
> > > I also setup looking on postgres (which I use) and indeed the queries
> > > are made twice.
> > >
> > > Thanks for ideas,
> > > Marcin
> > >
> >
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: I really about to give up Django

if u want someone else to understand use english

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: db queries made twice

Other option is set SHOW_TEMPLATE_CONTEXT to False
in DEBUG_TOOLBAR_CONFIG.

See https://github.com/django-debug-toolbar/django-debug-toolbar#configuration

Dne sobota, 31. srpna 2013 13:24:54 UTC+2 Tomáš Ehrlich napsal(a):
Hi,
disable Template panel in debug_toolbar and try again.

Debug toolbar hits database when evaluating template context.


Cheers,
   Tom

Dne Sat, 31 Aug 2013 12:09:00 +0100
Marcin Szamotulski napsal(a):

> Hello,
>
> I am using django-1.6.b2 on a localserver (./manage.py runserver) and
> for every request I have the chain of db lookups made twice.  For
> example my log looks something like this (after enabling
> django.db.backands logger):
>
> # HERE VIEW IS CALLED
> (0.001) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = '2dh8ly6cfqkyiauv8co5h1vossjg70ru'  AND "django_session"."expire_date" > '2013-08-31 11:04:33.597734+00:00' ); args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31 11:04:33.597734+00:00')
> (0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ; args=(1,)
>
> #... (AND SO ON)
>
> # HERE VIEW CALL IS FINISHED
> [31/Aug/2013 12:04:33] "GET /coot/ HTTP/1.1" 200 220974
> [31/Aug/2013 12:04:34] "GET /site_media/static/css/style.css HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery-ui.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/js/posts.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/js/confirm.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/css/posts.css HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/debug_toolbar/css/toolbar.min.css HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/debug_toolbar/js/toolbar.min.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/pics/django_logo.png HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/pics/python_logo.png HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/css/whitey.png HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/css/stressed_linen.png HTTP/1.1" 304  
>
> # DB LOOKUPS ONCE AGAIN:
> (0.001) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = '2dh8ly6cfqkyiauv8co5h1vossjg70ru'  AND "django_session"."expire_date" > '2013-08-31 11:04:33.597734+00:00' ); args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31 11:04:33.597734+00:00')
> (0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ; args=(1,)
>
> ... (AND SO ON)
>
>
> any ideas why?
>
> The views (as it is not just one) returns using render().  This also
> happens when using DetailedView cbv.
>
> I also setup looking on postgres (which I use) and indeed the queries
> are made twice.
>
> Thanks for ideas,
> Marcin
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: db queries made twice

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBAgAGBQJSIdKGAAoJEJ9WpvTpw+EqHA8P/REuYNqd06ZmvZ8QaW61St2w
dt9PgK1obiSTy5/pffSuCL8PNz+AukLKNeM3ZLlB3j9iEYYOEBPhnM3cOh3t1ljd
QKxZqmhk/Y/akS+VEcrgZX+rix9lHBj8HYOLeTfdmY4VqUqZHRpHYU/ED/1nBQOO
7Dg9oLgJlfYnQKfBI6eWFndvG1tF5q0n20YSz1RHX5aJraY4RBaDRxnGUHQZF0C3
Rp1H7U17XS3fsb+k23Jh954Yyh7OAezkzicpsXpuaEH5bstHcJs7MJ5eTe8RB4m8
aqrtThCZv7L8+mjV9Ue0Da1Qbc6CFC7oQyrG84C/ReoWZkrVmGbVhrO9kIzf4cn8
ewF96bJ60+NSXsFuRD/M/oALyBWimTifd8UPVvWqhXtfGQyJ/0bt2Suhaoq49BgI
k8kXxhvf5bUmXAzFGML2aFdxPNFYcpxh7GqIisCH7KXrmoyBQlXNA+k4h8eVHmtM
sqg3/kw86y2o74JB4C8fySBHOa/Y41785D2WA35/KyAj4KDzqfAFSoBxnuFbvI0O
ZdY6FCbkY8ap8gzh/xWh9GefgjZdAttds0X05zPAzlOIC/pgGM4KBBByxSEQZgOZ
x8atp/kzmQccuVZGdmkjZlmYAUVRLVLIrkacVY+PH4LC7YLjA4KGdqQz/FSsURYo
42mLc37guDzhQt6LDRWR
=s2R/
-----END PGP SIGNATURE-----
Hi,
disable Template panel in debug_toolbar and try again.

Debug toolbar hits database when evaluating template context.


Cheers,
Tom

Dne Sat, 31 Aug 2013 12:09:00 +0100
Marcin Szamotulski <mszamot@gmail.com> napsal(a):

> Hello,
>
> I am using django-1.6.b2 on a localserver (./manage.py runserver) and
> for every request I have the chain of db lookups made twice. For
> example my log looks something like this (after enabling
> django.db.backands logger):
>
> # HERE VIEW IS CALLED
> (0.001) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = '2dh8ly6cfqkyiauv8co5h1vossjg70ru' AND "django_session"."expire_date" > '2013-08-31 11:04:33.597734+00:00' ); args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31 11:04:33.597734+00:00')
> (0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ; args=(1,)
>
> #... (AND SO ON)
>
> # HERE VIEW CALL IS FINISHED
> [31/Aug/2013 12:04:33] "GET /coot/ HTTP/1.1" 200 220974
> [31/Aug/2013 12:04:34] "GET /site_media/static/css/style.css HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery-ui.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/js/posts.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/js/confirm.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/css/posts.css HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/debug_toolbar/css/toolbar.min.css HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/debug_toolbar/js/toolbar.min.js HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/pics/django_logo.png HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/pics/python_logo.png HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/css/whitey.png HTTP/1.1" 304 0
> [31/Aug/2013 12:04:34] "GET /site_media/static/css/stressed_linen.png HTTP/1.1" 304
>
> # DB LOOKUPS ONCE AGAIN:
> (0.001) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = '2dh8ly6cfqkyiauv8co5h1vossjg70ru' AND "django_session"."expire_date" > '2013-08-31 11:04:33.597734+00:00' ); args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31 11:04:33.597734+00:00')
> (0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ; args=(1,)
>
> ... (AND SO ON)
>
>
> any ideas why?
>
> The views (as it is not just one) returns using render(). This also
> happens when using DetailedView cbv.
>
> I also setup looking on postgres (which I use) and indeed the queries
> are made twice.
>
> Thanks for ideas,
> Marcin
>

db queries made twice

Hello,

I am using django-1.6.b2 on a localserver (./manage.py runserver) and
for every request I have the chain of db lookups made twice. For
example my log looks something like this (after enabling
django.db.backands logger):

# HERE VIEW IS CALLED
(0.001) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = '2dh8ly6cfqkyiauv8co5h1vossjg70ru' AND "django_session"."expire_date" > '2013-08-31 11:04:33.597734+00:00' ); args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31 11:04:33.597734+00:00')
(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ; args=(1,)

#... (AND SO ON)

# HERE VIEW CALL IS FINISHED
[31/Aug/2013 12:04:33] "GET /coot/ HTTP/1.1" 200 220974
[31/Aug/2013 12:04:34] "GET /site_media/static/css/style.css HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery.js HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery-ui.js HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/js/posts.js HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/js/confirm.js HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/css/posts.css HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/debug_toolbar/css/toolbar.min.css HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/debug_toolbar/js/toolbar.min.js HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/pics/django_logo.png HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/pics/python_logo.png HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/css/whitey.png HTTP/1.1" 304 0
[31/Aug/2013 12:04:34] "GET /site_media/static/css/stressed_linen.png HTTP/1.1" 304

# DB LOOKUPS ONCE AGAIN:
(0.001) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = '2dh8ly6cfqkyiauv8co5h1vossjg70ru' AND "django_session"."expire_date" > '2013-08-31 11:04:33.597734+00:00' ); args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31 11:04:33.597734+00:00')
(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ; args=(1,)

... (AND SO ON)


any ideas why?

The views (as it is not just one) returns using render(). This also
happens when using DetailedView cbv.

I also setup looking on postgres (which I use) and indeed the queries
are made twice.

Thanks for ideas,
Marcin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Implementing Raw SQL in Models problem

### PART A

Hello, in Python shell I run a Raw SQL and get a One-to-Many list output.

$ python manage.py shell
Python 2.7.3 (default, Apr 10 2013, 05:13:16) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> 
>>> 
>>> from navi_polls.models import Word, Altword
>>> from django.db import connection
>>> 
>>> cursor = connection.cursor()
>>> 
>>> for row in cursor.execute('SELECT navi_polls_word.rosword, navi_polls_altword.alt_ros_word, navi_polls_altword.votes FROM navi_polls_altword INNER JOIN navi_polls_word ON (navi_polls_altword.rosword_id=navi_polls_word.id)'):
...     print row
... 
(u'Paper', u'Leaf', 300)
(u'Paper', u'Leafy', 0)
(u'Page', u'Leafy 2', 18)
(u'Page', u'Leafy 3', 50)
>>> 
____________________________________________________________________________________________
### PART B

I don't really understand how to implement this Raw SQL into my Models file so that it returns the above same
list when I type this in Python shell:

>>> Altword.objects.vote_order()
____________________________________________________________________________________________
### PART C

class AltwordManager(models.Manager):
    def vote_order(self):
        "Returns a 1:M list ordered by votes."
        cursor =  connection.cursor()
        cursor.execute("""
SELECT navi_polls_word.rosword, navi_polls_altword.alt_ros_word, navi_polls_altword.votes
FROM navi_polls_altword INNER JOIN navi_polls_word
ON (navi_polls_altword.rosword_id=navi_polls_word.id)
        """)
        return for row in cursor.fetchall()


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.