Re: How to configure client side SSL trusted CA certificate ?

2017-02-08 Thread Pankaj Singh
Hi,

You can put export commands in you daemon script. Look at this
stackoverflow answers:
1. http://stackoverflow.com/a/3865077/353550
2. http://stackoverflow.com/a/27718602/353550

You can also find different ways to set environment variables for
supervisord, uwsgi, apache mod_wsgi by Google Search
<https://www.google.com/search?q=site:stackoverflow.com%20set%20environment%20variable%20wsgi%20python>
.

I hope it helps solve your problem.

On Thu, Feb 9, 2017 at 3:07 AM, Gang Yang <gangya...@gmail.com> wrote:

> Hi, Pankaj,
>
> Thanks for the reply. The REQUESTS_CA_BUNDLE env var worked as long as I
> start the server manually. But I don't seem to be able to "export" this env
> var into the server daemon process, which is started from /etc/init.d. I'll
> keep digging on the daemon env var.
>
> Gang
>
> On Wednesday, February 8, 2017 at 5:08:44 AM UTC-5, Pankaj Singh wrote:
>
>> Hi,
>>
>> My question is where does SSL client code get the trusted CA certificates
>>> from, from Django, Python or the underlying OS?
>>
>>
>> As per official documentation of requests
>> <http://docs.python-requests.org/en/latest/user/advanced/#ca-certificates>
>> library:
>>
>> By default, Requests bundles a set of root CAs that it trusts, sourced
>>> from the Mozilla trust store. However, these are only updated once for each
>>> Requests version. This means that if you pin a Requests version your
>>> certificates can become extremely out of date.
>>>
>>
>>
>> From Requests version 2.4.0 onwards, Requests will attempt to use
>>> certificates from certifi if it is present on the system. This allows for
>>> users to update their trusted certificates without having to change the
>>> code that runs on their system.
>>>
>>
>>
>> For the sake of security we recommend upgrading certifi frequently!
>>
>>
>> You can read more about certifi on it's official docs page
>> <https://certifi.io/en/latest/>.
>>
>> What configuration do I need in order for the SSL client to conduct the
>>> SSL handshake successfully?
>>
>>
>> You can set REQUESTS_CA_BUNDLE
>> <http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification>
>>  environment variable pointing to .cert file and it will pick it from
>> there.
>>
>> If you have just one `.crt` file which is self signed then you can do
>> following
>>
>> export REQUESTS_CA_BUNDLE='~/Download/bar.example.com.cert'
>>
>>
>> But if you have multiple certificates which are self signed then you can
>> put them in a folder and set the folder path in environment variable. In
>> case of a folder, make sure to run c_rehash
>> <https://www.openssl.org/docs/man1.0.2/apps/c_rehash.html> command for
>> folder.
>>
>> mkdir -p /tmp/custom-certs
>> cp ~/Download/foo.example.com.cert /tmp/custom-certs
>> cp ~/Download/bar.example.com.cert /tmp/custom-certsexport 
>> REQUESTS_CA_BUNDLE='/tmp/custom-certs'
>>
>>
>> Relevant source code in requests library: https://github.com/ke
>> nnethreitz/requests/blob/v2.13.0/requests/sessions.py#L658-L662
>>
>>
>> On Tue, Feb 7, 2017 at 10:30 PM, Gang Yang <gang...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'm pretty new to Django and encountered some client side SSL issue. I'm
>>> trying to use django-cas-ng (CAS client) to do CAS authentication and the
>>> CAS server is using a self-signed server certificate. After obtaining the
>>> service ticket (ST), django-cas-ng tried to verify the ST by calling
>>> requests.get(...) and failed with CERTIFICATE_VERIFY_FAILED error.
>>> Following some suggestions on the internet, I've tried to modify
>>> django-cas-ng's code to call requests.get(..) with verify parameter, such
>>> as requests.get(..., verify=False) and requests.get(..., verify="CAS server
>>> cert"). Both workarounds worked, but I can't change third-party package
>>> code. I also tried to add the CAS server cert to the underlying OS (Windows
>>> 2008 and CentOS 6.7), but it did not help.
>>>
>>> My question is where does SSL client code get the trusted CA
>>> certificates from, from Django, Python or the underlying OS? What
>>> configuration do I need in order for the SSL client to conduct the SSL
>>> handshake successfully?
>>>
>>> Appreciate any help!
>>>
>>> Gang
>>>
>>> --
>>> You received this message because you are subscribed to the Google

Re: How to configure client side SSL trusted CA certificate ?

2017-02-08 Thread Pankaj Singh
Hi,

My question is where does SSL client code get the trusted CA certificates
> from, from Django, Python or the underlying OS?


As per official documentation of requests

library:

By default, Requests bundles a set of root CAs that it trusts, sourced from
> the Mozilla trust store. However, these are only updated once for each
> Requests version. This means that if you pin a Requests version your
> certificates can become extremely out of date.
>


>From Requests version 2.4.0 onwards, Requests will attempt to use
> certificates from certifi if it is present on the system. This allows for
> users to update their trusted certificates without having to change the
> code that runs on their system.
>


For the sake of security we recommend upgrading certifi frequently!


You can read more about certifi on it's official docs page
.

What configuration do I need in order for the SSL client to conduct the SSL
> handshake successfully?


You can set REQUESTS_CA_BUNDLE

environment
variable pointing to .cert file and it will pick it from there.

If you have just one `.crt` file which is self signed then you can do
following

export REQUESTS_CA_BUNDLE='~/Download/bar.example.com.cert'


But if you have multiple certificates which are self signed then you can
put them in a folder and set the folder path in environment variable. In
case of a folder, make sure to run c_rehash
 command for
folder.

mkdir -p /tmp/custom-certs
cp ~/Download/foo.example.com.cert /tmp/custom-certs
cp ~/Download/bar.example.com.cert /tmp/custom-certsexport
REQUESTS_CA_BUNDLE='/tmp/custom-certs'


Relevant source code in requests library:
https://github.com/kennethreitz/requests/blob/v2.13.0/requests/sessions.py#L658-L662


On Tue, Feb 7, 2017 at 10:30 PM, Gang Yang  wrote:

> Hi,
>
> I'm pretty new to Django and encountered some client side SSL issue. I'm
> trying to use django-cas-ng (CAS client) to do CAS authentication and the
> CAS server is using a self-signed server certificate. After obtaining the
> service ticket (ST), django-cas-ng tried to verify the ST by calling
> requests.get(...) and failed with CERTIFICATE_VERIFY_FAILED error.
> Following some suggestions on the internet, I've tried to modify
> django-cas-ng's code to call requests.get(..) with verify parameter, such
> as requests.get(..., verify=False) and requests.get(..., verify="CAS server
> cert"). Both workarounds worked, but I can't change third-party package
> code. I also tried to add the CAS server cert to the underlying OS (Windows
> 2008 and CentOS 6.7), but it did not help.
>
> My question is where does SSL client code get the trusted CA certificates
> from, from Django, Python or the underlying OS? What configuration do I
> need in order for the SSL client to conduct the SSL handshake successfully?
>
> Appreciate any help!
>
> Gang
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/f07875b8-f3b8-4bcb-b95f-2d936f5ece34%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Regards,
Pankaj Kumar Singh

Mobile: +91 9618754327
Skype: psjinx
Emal: psj...@gmail.com

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPLvEUY6nxY%2BJFswe75jrqh7MFG3DBtr2C%3DJGBrQVFAxSpSGBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to configure client side SSL trusted CA certificate ?

2017-02-08 Thread Pankaj Singh
I forgot to put c_rehash command in the example in my last reply. Here it
goes:

mkdir -p /tmp/custom-certs
cp ~/Download/foo.example.com.cert /tmp/custom-certs
cp ~/Download/bar.example.com.cert /tmp/custom-certs
c_rehash /tmp/custom-certsexport REQUESTS_CA_BUNDLE='/tmp/custom-certs'


On Wed, Feb 8, 2017 at 12:23 PM, Pankaj Singh <psj...@gmail.com> wrote:

> Hi,
>
> My question is where does SSL client code get the trusted CA certificates
>> from, from Django, Python or the underlying OS?
>
>
> As per official documentation of requests
> <http://docs.python-requests.org/en/latest/user/advanced/#ca-certificates>
> library:
>
> By default, Requests bundles a set of root CAs that it trusts, sourced
>> from the Mozilla trust store. However, these are only updated once for each
>> Requests version. This means that if you pin a Requests version your
>> certificates can become extremely out of date.
>>
>
>
> From Requests version 2.4.0 onwards, Requests will attempt to use
>> certificates from certifi if it is present on the system. This allows for
>> users to update their trusted certificates without having to change the
>> code that runs on their system.
>>
>
>
> For the sake of security we recommend upgrading certifi frequently!
>
>
> You can read more about certifi on it's official docs page
> <https://certifi.io/en/latest/>.
>
> What configuration do I need in order for the SSL client to conduct the
>> SSL handshake successfully?
>
>
> You can set REQUESTS_CA_BUNDLE
> <http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification>
>  environment variable pointing to .cert file and it will pick it from
> there.
>
> If you have just one `.crt` file which is self signed then you can do
> following
>
> export REQUESTS_CA_BUNDLE='~/Download/bar.example.com.cert'
>
>
> But if you have multiple certificates which are self signed then you can
> put them in a folder and set the folder path in environment variable. In
> case of a folder, make sure to run c_rehash
> <https://www.openssl.org/docs/man1.0.2/apps/c_rehash.html> command for
> folder.
>
> mkdir -p /tmp/custom-certs
> cp ~/Download/foo.example.com.cert /tmp/custom-certs
> cp ~/Download/bar.example.com.cert /tmp/custom-certsexport 
> REQUESTS_CA_BUNDLE='/tmp/custom-certs'
>
>
> Relevant source code in requests library: https://github.com/
> kennethreitz/requests/blob/v2.13.0/requests/sessions.py#L658-L662
>
>
> On Tue, Feb 7, 2017 at 10:30 PM, Gang Yang <gangya...@gmail.com> wrote:
>
>> Hi,
>>
>> I'm pretty new to Django and encountered some client side SSL issue. I'm
>> trying to use django-cas-ng (CAS client) to do CAS authentication and the
>> CAS server is using a self-signed server certificate. After obtaining the
>> service ticket (ST), django-cas-ng tried to verify the ST by calling
>> requests.get(...) and failed with CERTIFICATE_VERIFY_FAILED error.
>> Following some suggestions on the internet, I've tried to modify
>> django-cas-ng's code to call requests.get(..) with verify parameter, such
>> as requests.get(..., verify=False) and requests.get(..., verify="CAS server
>> cert"). Both workarounds worked, but I can't change third-party package
>> code. I also tried to add the CAS server cert to the underlying OS (Windows
>> 2008 and CentOS 6.7), but it did not help.
>>
>> My question is where does SSL client code get the trusted CA certificates
>> from, from Django, Python or the underlying OS? What configuration do I
>> need in order for the SSL client to conduct the SSL handshake successfully?
>>
>> Appreciate any help!
>>
>> Gang
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/f07875b8-f3b8-4bcb-b95f-2d936f5ece34%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/f07875b8-f3b8-4bcb-b95f-2d936f5ece34%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
> Regards,
> Pankaj Kumar Singh
>
> Mobile: +91 9618754327 <+91%2096187%2054327>
> Skype: psjinx
> Emal: psj...@gmail.com
>



-- 

R

Re: No installed app with label 'province'.

2017-02-08 Thread Pankaj Singh
Hi Gerald,

Have you added your new app in 'INSTALLED_APPS' in `settings.py`?

Can you tell more about context of ther error, e.g. this error occurs on
`python manage.py runserver` or when you access a page on django admin?

Also, it would be much easier to find the issue if you can share the
traceback of error.

On Tue, Feb 7, 2017 at 6:19 PM, Gerald Brown  wrote:

> I have just started an app on Ubuntu 16.04 Server using Python 3.5 and
> Django 1.10.5.
>
> When I do "@admin.register(Province)" in my admin.py file I get the error
> that is the subject of this post.
>
> Of course there is NO app with label of 'province' as that is the label of
> a 'Model'.
>
> Why is Django trying to register an app instead of the Model?
>
> Thanks,
>
> Gerald
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/5e94b0d3-c6cd-4b24-b323-544d10e97923%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Regards,
Pankaj Kumar Singh

Mobile: +91 9618754327
Skype: psjinx
Emal: psj...@gmail.com

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPLvEUa2-%2BDR8LZ1Zr6BwAvkCG%2BGE39K_ucdiBxXkWONkXbj2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to cat'ing string in html file

2013-04-07 Thread Pankaj Singh
{% with "/media/"|add:i.no|add:".jpg" as template_str %}

Above line worked for me.

On Sun, Apr 7, 2013 at 3:05 PM, Fatih Tiryakioglu <fatih...@gmail.com> wrote:
> Thank you again Pankaj,
>
> But evaluated string is just ".jpg" . "/media/" and i.no are absent..
>
> On Sunday, April 7, 2013 12:16:34 PM UTC+3, psjinx wrote:
>>
>> On Sun, Apr 7, 2013 at 1:11 PM, Fatih Tiryakioglu <fati...@gmail.com>
>> wrote:
>>
>> > {% with "/media/"|add:"{{ i.no }}"|add:".jpg" as template_str %}
>> This should be
>>
>> {% with "/media/"|add:i.no|add".jpg" as template_str %}
>> 
>> {% endwith %}
>>
>> You don't need to use `{{ }}` inside `{% %}`.
>>
>> --
>>
>> Sincerely,
>> Pankaj Singh
>> http://about.me/psjinx
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to cat'ing string in html file

2013-04-07 Thread Pankaj Singh
On Sun, Apr 7, 2013 at 1:11 PM, Fatih Tiryakioglu <fatih...@gmail.com> wrote:

> {% with "/media/"|add:"{{ i.no }}"|add:".jpg" as template_str %}
This should be

{% with "/media/"|add:i.no|add".jpg" as template_str %}

{% endwith %}

You don't need to use `{{ }}` inside `{% %}`.

-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: couldn't render a media image via a template

2013-04-07 Thread Pankaj Singh
Make sure that "django.core.context_processors.media" is listed in
TEMPLATE_CONTEXT_PROCESSORS of your settings.py.

If above context processor is not listed then MEDIA_URL won't be
available in template.

Another reason for this can be that you are using render_to_response
instead of render in your view function. render forces the use of
RequestContext but in render_to_response you have to manually  use the
request variable while creating RequestContext.

Please have a look at
http://stackoverflow.com/questions/5154358/django-what-is-the-difference-between-render-render-to-response-and-direc
for more details.

Ref - 
https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media

On Sun, Apr 7, 2013 at 1:03 PM, Fatih Tiryakioglu <fatih...@gmail.com> wrote:
> Thank you very much.
>
> I think the problem is about printing variable. {{ MEDIA_URL }} doesn't
> print anything in the template. For now, I solved the problem by using
> absolute path, /media/... .
>
>
> --
>
>
> On Sunday, April 7, 2013 9:20:16 AM UTC+3, psjinx wrote:
>>
>> On Sat, Apr 6, 2013 at 4:11 PM, Fatih Tiryakioglu <fati...@gmail.com>
>> wrote:
>> > MEDIA_ROOT = '/home/mehmet/internet_projeleri/site4ust/site4/media'
>> This is the absolute path to your media directory.
>> > MEDIA_URL = '/media/'
>> This means files/directories at MEDIA_ROOT directory will be
>> accessible at an url starting with /media/. For example,
>> /home/mehmet/internet_projeleri/site4ust/site4/media/hello.jpg can be
>> viewed at /media/hello.jpg
>>
>> > STATIC_ROOT = ' '
>> This should be set to absolute path of your static directory. `python
>> manage.py collectstatic` command collects static files from different
>> apps in this directory.
>> > STATIC_URL = '/unnamed/'
>> As explained above for MEDIA_URL
>>
>> If you want to use an image located at
>> /home/mehmet/internet_projeleri/site4ust/unnamed/60830071673353216.jpg
>> then change
>>
>> MEDIA_ROOT="/home/mehmet/internet_projeleri/site4ust/unnamed"
>> MEDIA_URL="/media/"
>>
>> > 
>>
>> Above code will work now.
>>
>> --
>>
>> Sincerely,
>> Pankaj Singh
>> http://about.me/psjinx
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: couldn't render a media image via a template

2013-04-07 Thread Pankaj Singh
On Sat, Apr 6, 2013 at 4:11 PM, Fatih Tiryakioglu <fatih...@gmail.com> wrote:
> MEDIA_ROOT = '/home/mehmet/internet_projeleri/site4ust/site4/media'
This is the absolute path to your media directory.
> MEDIA_URL = '/media/'
This means files/directories at MEDIA_ROOT directory will be
accessible at an url starting with /media/. For example,
/home/mehmet/internet_projeleri/site4ust/site4/media/hello.jpg can be
viewed at /media/hello.jpg

> STATIC_ROOT = ' '
This should be set to absolute path of your static directory. `python
manage.py collectstatic` command collects static files from different
apps in this directory.
> STATIC_URL = '/unnamed/'
As explained above for MEDIA_URL

If you want to use an image located at
/home/mehmet/internet_projeleri/site4ust/unnamed/60830071673353216.jpg
then change

MEDIA_ROOT="/home/mehmet/internet_projeleri/site4ust/unnamed"
MEDIA_URL="/media/"

> 

Above code will work now.

-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: need help designing models

2013-04-07 Thread Pankaj Singh
College field in Batch model is redundant. You can get college of a
batch using batch.department.college.

On Sun, Apr 7, 2013 at 10:57 AM, surya <kasturisu...@gmail.com> wrote:
> Consider a university college.
> 1. College has name, uid, website
> 2. Each college has a many departments - Each department has name, uid.
> 3. Each batch in a department has name, and ratings.
>
> from django.db import models
>
> class College(models.Model):
> name = models.CharField(max_length=200)
> uid = models.CharField(max_length=10, primary_key=True)
> website = models.URLField()
>
> def __unicode__(self):
> return self.name
>
> class Department(models.Model):
> name = models.CharField(max_length=200)
> uid = models.CharField(max_length=10)
> college = models.ForeignKey(College)
>
> def __unicode__(self):
> return self.name
>
> class Batch(models.Model):
> name = models.IntegerField(max_length=100)
> department = models.ForeignKey(Department)
> college = models.ForeignKey(College)
> rating = models.IntegerField(default=0)
>
> def __unicode__(self):
> return self.name
>
> Would you suggest any better design ? (actually, I never formally read DB)
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Stop django admin

2013-04-07 Thread Pankaj Singh
Hey,

You can run phpmyadmin on different port by creating a virtualhost having
default phpmyadmin conf.

NameVirtualHost *:
Listen 

# Paste contents of default phpmyadmin conf here




For example, visit http://pastie.org/7347686.

Save this in /etc/apache2/sites-enabled/phpmyadmin

After restarting apache server you can visit phpmyadmin at http://:/phpmyadmin/

On Sun, Apr 7, 2013 at 2:52 AM, Hylda <xiayh2...@gmail.com> wrote:

> Hi all,
>
> After I switch to apache, I cannot run myphpadmin. I wonder how I can vist
> them simultaneously or stop django admin? Thanks so much!
>
> run sudo yum install mod_wsgi to install the apache and the module
> necessary for serving your django app.
> Add these lines to /etc/httpd/conf/httpd.conf
>
> Alias /static /var/www/mysite/static
>   Order deny,allow
>   Allow from all
> WSGIScriptAlias / /var/www/mysite/apache/django.wsgi
>
>
>
> Page not found (404) Request Method:GETRequest URL:
> http://ec2-xx-xxx-x-xx.compute-1.amazonaws.com/phpmyadmin
>
> Using the URLconf defined in mysite.urls, Django tried these URL
> patterns, in this order:
>
>1. ^polls/
>2. ^admin/
>
> The current URL, phpmyadmin, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard
> 404 page.
>
>  --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: FileField delete and update handling

2013-03-30 Thread Pankaj Singh
Please have a look at following code.

pre_save and post_delete signal handlers are used here to
automatically delete unused files.

Signal handlers are generic in nature as the use isinstance(field,
models.FileField) to identify file fields.

Source - 
https://github.com/un1t/django-cleanup/blob/master/django_cleanup/models.py.

import os
from django.db import models
from django.db.models.signals import pre_save, post_delete
from django.db.models.loading import cache


def find_models_with_filefield():
result = []
for app in cache.get_apps():
model_list = cache.get_models(app)
for model in model_list:
for field in model._meta.fields:
if isinstance(field, models.FileField):
result.append(model)
break
return result

def remove_old_files(sender, instance, **kwargs):
if not instance.id:
return

try:
old_instance = instance.__class__.objects.get(id=instance.id)
except instance.DoesNotExist:
return

for field in instance._meta.fields:
if not isinstance(field, models.FileField):
continue
old_file = getattr(old_instance, field.name)
new_file = getattr(instance, field.name)
if old_file and old_file != new_file and os.path.exists(old_file.path):
try:
os.remove(old_file.path)
except OSError:
pass

def remove_files(sender, instance, **kwargs):
for field in instance._meta.fields:
if not isinstance(field, models.FileField):
continue
file = getattr(instance, field.name)
if file and os.path.exists(file.path):
try:
os.remove(file.path)
except OSError:
pass


for model in find_models_with_filefield():
pre_save.connect(remove_old_files, sender=model)
post_delete.connect(remove_files, sender=model)

On Sat, Mar 30, 2013 at 9:57 PM,  <temp4...@gmail.com> wrote:
> Hi,
>
> As it seems Django doesn't handle the update and delete of files from a
> FileField by itself leaving you them pretty hard to use by default.
>
> I tried search around but couldn't find a proper answer as to the correct
> way of handling this.
>
> I'm looking for the case where when the file is updated to a new name or
> deleted, it will be deleted properly from the file system, preferably not
> leaving empty directories too.
>
> Not having this done at the model level means all the generic views and
> admin pages are useless and require customization to delete and update the
> file name in them.
>
> The other option is a script that is going to iterate the entire directory
> and look for files not listed in the db, which is a really expensive and
> slow operation.
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django+virtualenv+git(hub)

2013-03-30 Thread Pankaj Singh
Hey,

I would recommend using virtualenvwrapper to manage virtual
environments for different projects.
[http://virtualenvwrapper.readthedocs.org/en/latest/]

Once you have virtualenvwrapper installed, you can create virtualenv
for new projects using

$ mkvirtualenv 

.. and you can activate this virtualenv in future using

$ workon 

For using git,

1. initialize git when you create the project
2. Copy content of required .gitignore files from
https://github.com/github/gitignore in .gitignore file for your
project

You should read `Two Scoops of Django` book
(https://django.2scoops.org/). It has dedicated chapters on optimal
django environment setup , project layouts, app design and much more.
It's worth reading.

You can find project layout explained in book at
https://github.com/twoscoops/django-twoscoops-project

On Sat, Mar 30, 2013 at 1:26 PM, John <wasteland.t...@gmail.com> wrote:
> Hi list,
>
> I'm a Django newbie and have been reading of usefulness of using it with
> virtualenv+git. I'm not clear however how to set it up in terms of
> structure/hierarchy.
>
> Say I've got my ~/projects/django-projects where I want to create my
> projects so I'd initialise git inside ~/projects/django-projects. Then
> I'd create separate virtual environments inside that adjusting
> .gitignore to ignore things like:
>
> *.pyc
> .*swp
>
> # Django files
> include
> lib
> local
> man
> share
> Scripts
> .Python
> *.pyc
> *~
> *.db
>
>
> # Packages
> *.egg
> *.egg-info
> dist
> build
> eggs
> parts
> bin
> var
> sdist
> develop-eggs
> .installed.cfg
>
> # Installer logs
>  pip-log.txt
>
>
>
> Is that a recommended setup/logic?
>
> Thank you
>
> John
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django HTML controls and CRUD creation functionalities

2013-03-29 Thread Pankaj Singh
Hey,

On Fri, Mar 29, 2013 jacku...@gmail.com wrote:
> I just learn about asp.net/and Yii in PhP, for the HTML control(textbox,
> button, image, etc.) they have their own built in controls, in order to save
> state across page posting back, I am not sure does Django has similar
> built-in controls, or it is using only the html control? If it is using HTML
> control, does it have any special functionalists built into the HTML
> control?
I have never used ASP.NET or Yii, but you can achieve everything
offered by HTML Control from Forms, Templates, Models and Views in
Django.

> The other question is, for Yii, it has user interface for generating CRUD,
> does Django have such features?
Yes, Django has a very powerful admin site[1]. For screenshots of
admin site visit[2].

Links-
1. https://docs.djangoproject.com/en/1.5/ref/contrib/admin/
2. http://goo.gl/H9B5S

-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Displaying And Selecting Tags in Admin Site

2013-03-28 Thread Pankaj Singh
Hey,

You will need to use custom widget for tag field. Please have a look at
https://bitbucket.org/fabian/django-taggit-autosuggest and below screenshot.

[image: Inline image 1]

On Thu, Mar 28, 2013 at 7:03 PM, Jonathan Harris
<jtnhar...@googlemail.com>wrote:

> Hi All
>
> New to Django and coding in general, so sorry if this has been covered - I
> did search the group postings, have read the documentation, trawled the net
> etc, but couldn't find anything directly relevant
>
> I have been following various tutorials (django homepage, youtube etc) for
> how to start creating a blog site
>
> What I would like to do seems really simple, but I cannot find a solution
>
> Django 1.5 on Ubuntu Server 12.04LTS
>
> It uses Taggable Manager, so in models.py we see
>
> #models.py
>
> from taggit.managers import TaggableManager
>
> class Post(models.Model):
> title = models.CharField(max_length=100)
> 
> tags = TaggableManager()
>
> #admin.py
>
> from blog.models import Post
>
> class PostAdmin(admin.ModelAdmin):
> fieldsets = [
> ('Title',  {'fields': ['title']}),
> ..
> ('Tags', {'fields': ['tags'], 'classes': ['collapse']}),
> ]
>
> admin.site.register(Post, PostAdmin)
>
> 
>
> This works fine
>
> What I would like to do is change the way that tags can be viewed and
> selected in the admin site
>
> Currently, it is as a comma separated list
>
> I would like to pre-create the tags, then see them in a drop down, or
> table, or similar, so that one or more may be selected
> The view I am looking to achieve would be as if 'filter_horizontal =
> ['tags']' had been applied
>
> However, I cannot find a way to do it
>
> I have tried to give the tags a separate class, with a ManyToManyField
> link into Post, but any tags that are created are not displayed - and this
> is probably really not the right approach
>
> So is it possible to change the way that tags from TaggableManager is
> displayed? Can it be as a selection box, or check boxes or anything else?
> Or are we stuck with the list approach?
>
> Any advice would be gratefully received
>
> Many Thanks
>
> Jon
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


<>

Re: management commands in namespaced apps

2013-03-28 Thread Pankaj Singh
This is a known bug in django - https://code.djangoproject.com/ticket/14087.

On Thu, Mar 28, 2013 at 7:17 PM, Alexis Roda <
alexis.roda.villalo...@gmail.com> wrote:

> Hi all,
> I'm having a hard time making management commands defined in a namespaced
> app available to "manage.py".
>
> I have a namespace python package "dja.skel.core" that provides some
> functionality and a namespace app "dja.skel.django_skel" which defines
> functionality specific to django, a management command named "skel".
>
> "dja.skel.django_skel" is in INSTALLED_APPS but when I run "python
> manage.py help" the "skel" management command is not listed.
>
> Tracking down the problem it seems to be caused by the "imp.find_module()"
> function in "django.core.management.find_**management_module()".
>
> When calling imp.find_module("dja", None) it returns
> '/home/alex/prog/dja_skel/dja.**skel.core/dja' for the path, so locating
> "dja.skel.django_skel.**management" will fail as it is being searched for
> in "dja.skel.core".
>
> So my question is if is this a bug or namespace apps are no supported by
> django in the way I'm trying to use them?
>
>
>
> 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<django-users%2bunsubscr...@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?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>


-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-03-28 Thread Pankaj Singh
te-packages/django/core/urlresolvers.py"
> in get_callable
>   92. lookup_view = getattr(import_module(mod_name),
> func_name)
> File
> "/home/env/project/lib/python2.7/site-packages/django/utils/importlib.py"
> in import_module
>   35. __import__(name)
>
> Exception Type: ImportError at /
> Exception Value: No module named views
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: showing an Integerfield as checkbox in form with defaulted as "check"

2013-03-28 Thread Pankaj Singh
Hey Abhishek,

In your form, you need to specify a form field to use
django.forms.widgets.CheckboxInput (
https://docs.djangoproject.com/en/dev/ref/forms/widgets/#checkboxinput) for
this.

Here is an example

from django import formsfrom django.form.widgets import
CheckboxInputfrom django.forms.fields import IntegerField
def my_check_test(some_integer):
"""
A custom check test used by CheckboxInput.
"""
return some_integer%2 == 0
class SimpleForm(forms.Form):
my_field = IntegerField(widget=CheckboxInput(check_test=my_check_test))


On Thu, Mar 28, 2013 at 5:57 PM, Abhishek Kumar <abhi.creati...@gmail.com>
wrote:
> I am trying to show an integer field as check box and wanted to show it as
> default check.
> Does anyone know how to do this.
>
> thanks
> ak
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: manytomany field and intermediary table from a legacy database

2013-03-28 Thread Pankaj Singh
Hey Vittorio,

ManyToManyField has one optional argument for specifying
db_table(http://bit.ly/10ciWdu).

Since, you have different column names, you should create a new model.
and specify that model as `through` argument(http://bit.ly/10cjdgz).
And set `db_table` in `Meta` class of this model.

In this new `through` model, specify all fields and for each field you
can set `db_column` (http://bit.ly/10cjjEU).

Example code

class Person(models.Model):
name = models.CharField(max_length=128)

def __unicode__(self):
return self.name

class Group(models.Model):
name = models.CharField(max_length=128)
members = models.ManyToManyField(Person, through='Membership')

def __unicode__(self):
return self.name

class Membership(models.Model):
person = models.ForeignKey(Person, db_column="person_column_name")
group = models.ForeignKey(Group, db_column="group_column_name")
date_joined = models.DateField(db_column="date_joined_column_name")
invite_reason = models.CharField(max_length=64,
db_column="invite_reason_column_name")

class Meta:
db_table = "membership_table_name"

On Wed, Mar 27, 2013 at 11:28 PM, Vittorio <ml-...@de-martino.it> wrote:
> I know that when I define a manytomany field automagically "behind the scene
> Django creates an intermediary join table to represent the many-to-many
> relationship".
> Now I have a legacy MySQL db, feeded by an existing procedure built in
> Filemaker  via ODBC, which I would like to use with django too. In this
> legacy db the "intermediary join table" already exists but with a different
> name and with different name fields.
> How can I tell Django to use that table without creating a new one?
> An example would be very useful.
> Bye from Rome
> Vittorio
>
> --
> 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+unsubscr...@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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Looking for a simple newsletter app

2013-03-13 Thread Pankaj Singh
Hey,

Have a look at https://www.djangopackages.com/grids/g/newsletter/.

I have used emencia django newsletter previously (http://vimeo.com/16793999
).

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Wed, Mar 13, 2013 at 6:00 PM, frocco <faro...@gmail.com> wrote:

> Hello,
>
> Does anyone know of a simple newsletter app I can add to my website?
>
> Thanks
>
> --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django payment gateway with subscription management

2013-03-06 Thread Pankaj Singh
Hey Jaimin,
For recurring submissions managed by Stripe, have a look at
https://github.com/eldarion/django-stripe-payments

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Wed, Mar 6, 2013 at 2:27 AM, Jaimin Patel <jaimin9...@gmail.com> wrote:

> Yes, we are USA based and I come across stripe. It seems very developer
> friendly. Is there any example on setting up recurring payments using
> stripe?
>
>
> On Tuesday, March 5, 2013 3:47:06 PM UTC-5, Mayukh Mukherjee wrote:
>
>> Stripe if you're in the us (am not sure which other countries they've
>> rolled out to).
>>
>>
>> On Tue, Mar 5, 2013 at 3:34 PM, Jaimin Patel <jaimi...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> We are evaluating different payment gateways for subscription management
>>> for one of the app which requires the subscription based model (monthly, 6
>>> months, year).
>>>
>>> I checked different packages available here -
>>> https://www.djangopackages.**com/grids/g/payment-**processing/<https://www.djangopackages.com/grids/g/payment-processing/>
>>>
>>> Though I am confuse which one I should be using, can someone recommend
>>> which one is actively maintained and most commonly used for subscription
>>> based model where users can signup for free and if they want they can
>>> subscribe later on. We don't required to store the credit card details and
>>> it can be taken care by the payment gateway.
>>>
>>> Thanks.
>>>
>>> --
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> Mayukh Mukherjee
>> http://www.linkedin.com/in/**mayukhmmukherjee<http://www.linkedin.com/in/mayukhmmukherjee>
>>
>>
>>   --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: comment templates

2013-02-21 Thread Pankaj Singh
>
> so this means enabling the comment app will not render comments
> anywhere and developer needs to manually choose to include it in page
> templates

Yes.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Thu, Feb 21, 2013 at 3:38 PM, yakoub abaya <yakoub.ab...@gmail.com>wrote:

>
> thank you, so this means enabling the comment app will not render comments
> anywhere
> and developer needs to manually choose to include it in page templates
>
>
> On Thursday, February 21, 2013 11:54:34 AM UTC+2, psjinx wrote:
>
>> Hey,
>>
>> From Django Docs (https://docs.djangoproject.**com/en/1.4/ref/contrib/**
>> comments/#quickly-rendering-a-**comment-list<https://docs.djangoproject.com/en/1.4/ref/contrib/comments/#quickly-rendering-a-comment-list>
>> )
>>
>> The easiest way to display a list of comments for some object is by using
>> render_comment_list<https://docs.djangoproject.com/en/1.4/ref/contrib/comments/#std:templatetag-render_comment_list>
>> :
>>
>> {% render_comment_list for [object] %}
>>
>> For example:
>>
>> {% render_comment_list for event %}
>>
>> This will render comments using a template named comments/list.html, a
>> default version of which is included with Django.
>>
>> Sincerely,
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Thu, Feb 21, 2013 at 3:22 PM, yakoub abaya <yakoub...@gmail.com>wrote:
>>
>>>  can someone please explain where and how this template :
>>> django/contrib/comments/**templates/comments/list.html
>>> gets rendered into the main page html template ?
>>>
>>> --
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: comment templates

2013-02-21 Thread Pankaj Singh
Hey,

>From Django Docs (
https://docs.djangoproject.com/en/1.4/ref/contrib/comments/#quickly-rendering-a-comment-list
)

The easiest way to display a list of comments for some object is by using
render_comment_list<https://docs.djangoproject.com/en/1.4/ref/contrib/comments/#std:templatetag-render_comment_list>
:

{% render_comment_list for [object] %}

For example:

{% render_comment_list for event %}

This will render comments using a template named comments/list.html, a
default version of which is included with Django.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Thu, Feb 21, 2013 at 3:22 PM, yakoub abaya <yakoub.ab...@gmail.com>wrote:

> can someone please explain where and how this template :
> django/contrib/comments/templates/comments/list.html
> gets rendered into the main page html template ?
>
> --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Cannot find ../django/contrib/admin/media

2013-02-20 Thread Pankaj Singh
Hey,

In case it helps, I have shared my apache conf at -
http://pastebin.com/bsK26gek and project tree is at -
http://pastebin.com/NRTypUCi .. I generally create a local wsgi file which
activates virtual env and then imports everything from wsgi.py.

I generally symlink my project root to /opt/webapps/project_name.

I will upload an example project to Github in few days.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Wed, Feb 20, 2013 at 9:06 PM, Vittorio <ml-...@de-martino.it> wrote:

> As a newbye I'm using django 1.4.3 under Mac OS X.
> Reading the tutorials (and an Italian book on django by Marco Beri), I was
> able to set up my app 'home' using a legacy mysql db, and play  with it as
> admin by means of the server 'python manage.py runserver'. Nice layout
> indeed!
> I modified my apache2 httpd.conf in order to run the same app adding:
>
> VirtualHost *:8000>
>
> ServerAdmin webmaster@localhost
> 
>  SetHandler python-program
>  PythonHandler django.core.handlers.modpython
>  PythonPath "['/home/vittorio','/home/vittorio/miosito/home'] +
> sys.pat$
>  SetEnv DJANGO_SETTINGS_MODULE home.settings
>  PythonDebug On
> 
>
> 
>
> OR (an alternative httpd.conf)
>
>
> WSGIScriptAlias / /home/vittorio/miosito/home/django.wsgi
> WSGIPythonPath /home/vittorio/miosito/home
>
> 
> 
> Order deny,allow
> Allow from all
> 
> 
>
>
> Both work  but their layout is simply awful, not at all elegant like that
> obtained by means of runserver.
> My point is that I would like to fix this and have the same elegant layout
> of the standard python manage.py runserver
>
> leafing thru this list I understand that I should have added an alias
> reference to the directory of the django media that im my case, according
> to the many mails (very old indeed, usually referring to django 1.0),
> should be
> /Library/Python/2.7/site-packages/django/contrib/admin/media
> which simply does not exist (also under FreeBSD which I use too)
>
> What wrong with it and how can I solve this problem
>
> Ciao
> Vittorio
>
> --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: No django 1.0.4 file on PYPI

2013-02-20 Thread Pankaj Singh
>
> But most reading materials I could get was written for Django 1.0.x
> version.


Django 1.0.4 is really old and a lot has been changed in last 4-5 years. I
would suggest you to get started with latest stable releases.

Korean docs for Django -
https://django-document-korean.readthedocs.org/en/latest/intro/tutorial01.html

Only some of topics have been translated till now. This translation project
on Github (https://github.com/python-docs-ko/django-docs-ko). May be you
can contribute in future :)

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Wed, Feb 20, 2013 at 6:35 PM, Joey Espinosa <jlouis.espin...@gmail.com>wrote:

> You can always just install directly from djangoproject.com.
>
> https://www.djangoproject.com/download/1.0.4/tarball/
>
> In fact, you can use pip to install that:
>
> pip install https://www.djangoproject.com/download/1.0.4/tarball/
>
> If you maintain a package requirements file for your project, you can put
> that link in there and pip will know to install it along with everything
> else.
>
> requirements.txt:
> https://www.djangoproject.com/download/1.0.4/tarball/
>
> pip install -r requirements.txt
>
> Let me know if you run into any issues.
>
> --
> Joey Espinosa
> Python Developer
> http://about.me/joelinux
> On Feb 20, 2013 7:55 AM, "Kyungsoo Park" <peaceb...@gmail.com> wrote:
>
>> I've been studying Django with Python thesedays.
>> But most reading materials I could get was written for Django 1.0.x
>> version.
>> So I tried to install Django 1.0.4 on virtualenv environment to read a
>> old Korean Django guide book.
>> (yes, I'm from Korea)
>> However I found out that there is no Django 1.0.4 file on PYPI.
>> I couldn't install it with pip.
>> See the link below.
>> https://pypi.python.org/pypi/Django/1.0.4
>> So I'd like to know the reason why.
>> Tell me if it's just a mistake or has a reason.
>>
>> I need to install 1.0.4 version.
>> So is it right if I install it with tar.gz file on virtualenv environment?
>>
>> --
>> 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+unsubscr...@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?hl=en.
>> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: looking for a Django app for annual subscriptions

2013-02-20 Thread Pankaj Singh
Hey Mike,

As James has already mentioned about Stripe here, you should have a look at
https://github.com/amccloud/django-stripe, a user subscription Django app
that integrates with Stripe.

If no-one suggests anything, I'll start my own and welcome any
> contributors. It would end up being open sourced.


I would like to contribute if you end up writing a new app.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Wed, Feb 20, 2013 at 11:16 AM, James Socol <james.so...@gmail.com> wrote:

> On Tuesday, February 19, 2013 10:36:49 PM UTC-5, Mike Dewhirst wrote:
>>
>> Does anyone know of an annual subscriptions application for Django?
>>
>
> If you aren't looking to handle all the payment processing yourself,
> Stripe <https://stripe.com/> has really good subscription/recurring
> support.
>
> You'd need to build some functionality on top of that, to handle some of
> the other things you're talking about, but Stripe (or another provider)
> would help handle the subscription billing aspect, and their webhooks can
> help a lot for keeping things in sync.
>
>
>>
>> I want to be able to offer a service to multiple organisations whereby
>> their employees can subscribe to a serialised product which is paid for
>> by subscription and each organisation can see what it is funding. I also
>> want the organisations to be able to optionally subsidise groups or
>> individual subscriptions.
>>
>> There doesn't seem to be anything on Django Packages relating to
>> subscriptions and I don't think an ordinary web shop is the solution.
>> There is no need for ecommerce transactions. The organisations would be
>> invoiced directly outside the app.
>>
>> If no-one suggests anything, I'll start my own and welcome any
>> contributors. It would end up being open sourced.
>>
>> Thanks anyone
>>
>> Mike
>>
>  --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to create attribute for image in django models.py

2013-02-20 Thread Pankaj Singh
Hey Avnesh,

You should

   1. Complete Polls tutorial first -
   https://docs.djangoproject.com/en/dev/intro/tutorial01/
   2. walk through full documentation at https://docs.djangoproject.com/ at
   least once.
   3. See list of open source projects in Django at
   https://code.djangoproject.com/wiki/DjangoResources#Open-SourceDjangoprojects
   4. There is an extensive list of other resources as well on above wiki
   page.
   5. Walk through source code of different apps at
   https://github.com/nathanborror/django-basic-apps/tree/master/basic
   6. Read `Two Scoops of Django` once you are good at basics. This book is
   not for beginners.

It's good to do your homework before posting a question on public
forums/mailing lists. Please read

   1. http://www.catb.org/esr/faqs/smart-questions.html
   2. http://stackoverflow.com/questions/how-to-ask

Happy Coding !!

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Wed, Feb 20, 2013 at 6:06 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:

> thanks alot plz share any small project for beginners, if u have
>
>
> On Wed, Feb 20, 2013 at 6:02 PM, Tom Evans <tevans...@googlemail.com>wrote:
>
>> On Wed, Feb 20, 2013 at 12:26 PM, Avnesh Shakya <avnesh.n...@gmail.com>
>> wrote:
>> > plz help me... i want to store image in database using model,how is it
>> > possible...?
>> >
>>
>> https://docs.djangoproject.com/en/1.4/ref/models/fields/#imagefield
>>
>> Cheers
>>
>> Tom
>>
>> --
>> 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+unsubscr...@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?hl=en.
>> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: error in templates...

2013-02-19 Thread Pankaj Singh
Hey,

You are not using reverse in your views.py. I'm not sure what is causing
your problem.

hi, if you have any mini project on django, plz share, i m beginner it can
> be helpful for me... plz share if u have..


Django By Example - http://lightbird.net/dbe2/

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Tue, Feb 19, 2013 at 6:00 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:

> hi, if you have any mini project on django, plz share, i m beginner it can
> be helpful for me... plz share if u have..
> thanks alot
>
> On Tue, Feb 19, 2013 at 5:58 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:
>
>> hi, i m adding my views.py file
>>
>>
>>
>> On Tue, Feb 19, 2013 at 5:44 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>
>>> Hey,
>>>
>>> Every things worked for me when I used your original templates and
>>> following urls.py.
>>>
>>> As you can notice, I have used generic view as I did not have original
>>> view function.
>>>
>>> Please share views.py because it's hard to help help without that.
>>>
>>> FYI, you can test reverse match by using
>>> django.core.urlresolvers.reverse in shell.
>>>
>>>  ### urls.py
>>> from django.conf.urls import patterns, include, url
>>> from django.views.generic.simple import direct_to_template
>>>
>>> urlpatterns = patterns('',
>>> url(r'^$', direct_to_template, {"template": "home.html"},
>>> name="home"),
>>> url(r'^about/$', direct_to_template, {"template": "about.html"},
>>> name="about"),
>>> url(r'^contact/$', direct_to_template, {"template":
>>> "contact.html"},
>>> name="contact"),
>>> url(r'^archive/$', direct_to_template, {"template":
>>> "archive.html"},
>>> name="archive"),
>>> )
>>>
>>> Sincerely,
>>> Pankaj Singh
>>> http://about.me/psjinx
>>>
>>>
>>> On Tue, Feb 19, 2013 at 5:06 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:
>>>
>>>> ya i have done it but error has occured again..
>>>>
>>>>
>>>> On Tue, Feb 19, 2013 at 5:04 PM, Pankaj Singh <ps.j...@gmail.com>wrote:
>>>>
>>>>> Hey,
>>>>>
>>>>> I asked you to make changes in templates (i.e. home.html, about.html
>>>>> etc.) and not urls.py.
>>>>>
>>>>>
>>>>> Sincerely,
>>>>> Pankaj Singh
>>>>> http://about.me/psjinx
>>>>>
>>>>>
>>>>> On Tue, Feb 19, 2013 at 4:56 PM, Avnesh Shakya 
>>>>> <avnesh.n...@gmail.com>wrote:
>>>>>
>>>>>> hi pankaj, i have got again error same..
>>>>>> if i change
>>>>>>
>>>>>> from django.conf.urls.defaults import *
>>>>>> urlpatterns= patterns('myapp.views',
>>>>>> url(r'^$','home',name="home"),
>>>>>> url(r'^about/$','about',name="about"),
>>>>>> url(r'^contact/$','contact',name="contact"),
>>>>>> url(r'^contact/$','archive',name="archive"),
>>>>>> )
>>>>>> its to
>>>>>>
>>>>>> from django.conf.urls.defaults import *
>>>>>> urlpatterns= patterns('myapp.views',
>>>>>> url(r'^$','home',name="home"),
>>>>>> url(r'^$','about',name="about"),
>>>>>> url(r'^$','contact',name="contact"),
>>>>>> url(r'^$','archive',name="archive"),
>>>>>> )
>>>>>> then it's not generating error but that links are not opening.
>>>>>> thanks
>>>>>>
>>>>>> On Tue, Feb 19, 2013 at 4:28 PM, Pankaj Singh <ps.j...@gmail.com>wrote:
>>>>>>
>>>>>>> Hey Avnesh,
>>>>>>>
>>>>>>> In your templates you have written following lines
>>>>>>>
>>>>>>> homeabout>>>>>> href="{% url archive %}">archivecontact
>>>>>>>
>>>>>>> Change them to following, notice single quotes surrounding url
>>>>>>&

Re: error in templates...

2013-02-19 Thread Pankaj Singh
Hey,

Every things worked for me when I used your original templates and
following urls.py.

As you can notice, I have used generic view as I did not have original view
function.

Please share views.py because it's hard to help help without that.

FYI, you can test reverse match by using django.core.urlresolvers.reverse
in shell.

 ### urls.py
from django.conf.urls import patterns, include, url
from django.views.generic.simple import direct_to_template

urlpatterns = patterns('',
url(r'^$', direct_to_template, {"template": "home.html"},
name="home"),
url(r'^about/$', direct_to_template, {"template": "about.html"},
name="about"),
url(r'^contact/$', direct_to_template, {"template": "contact.html"},
name="contact"),
url(r'^archive/$', direct_to_template, {"template": "archive.html"},
name="archive"),
)

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Tue, Feb 19, 2013 at 5:06 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:

> ya i have done it but error has occured again..
>
>
> On Tue, Feb 19, 2013 at 5:04 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>
>> Hey,
>>
>> I asked you to make changes in templates (i.e. home.html, about.html
>> etc.) and not urls.py.
>>
>>
>> Sincerely,
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Tue, Feb 19, 2013 at 4:56 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:
>>
>>> hi pankaj, i have got again error same..
>>> if i change
>>>
>>> from django.conf.urls.defaults import *
>>> urlpatterns= patterns('myapp.views',
>>> url(r'^$','home',name="home"),
>>> url(r'^about/$','about',name="about"),
>>> url(r'^contact/$','contact',name="contact"),
>>> url(r'^contact/$','archive',name="archive"),
>>> )
>>> its to
>>>
>>> from django.conf.urls.defaults import *
>>> urlpatterns= patterns('myapp.views',
>>> url(r'^$','home',name="home"),
>>> url(r'^$','about',name="about"),
>>> url(r'^$','contact',name="contact"),
>>> url(r'^$','archive',name="archive"),
>>> )
>>> then it's not generating error but that links are not opening.
>>> thanks
>>>
>>> On Tue, Feb 19, 2013 at 4:28 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>>
>>>> Hey Avnesh,
>>>>
>>>> In your templates you have written following lines
>>>>
>>>> homeabout>>> href="{% url archive %}">archivecontact
>>>>
>>>> Change them to following, notice single quotes surrounding url pattern
>>>> name
>>>>
>>>> homeabout>>> href="{% url 'archive' %}">archivecontact
>>>>
>>>>
>>>>
>>>> Sincerely,
>>>> Pankaj Singh
>>>> http://about.me/psjinx
>>>>
>>>>
>>>> On Tue, Feb 19, 2013 at 4:06 PM, Avnesh Shakya 
>>>> <avnesh.n...@gmail.com>wrote:
>>>>
>>>>>
>>>>>
>>>>> On Tue, Feb 19, 2013 at 3:47 PM, Avnesh Shakya 
>>>>> <avnesh.n...@gmail.com>wrote:
>>>>>
>>>>>> ya i have completed and i m just doing copy n paste from from
>>>>>> tutorial but there is no error but i m facing this error again n again...
>>>>>>
>>>>>> https://www.udemy.com/full-django-tutorial/#lecture/63701/question/9902
>>>>>> can i add my page for help. i need your help plz..
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Feb 19, 2013 at 3:39 PM, Thomas Weholt <
>>>>>> thomas.weh...@gmail.com> wrote:
>>>>>>
>>>>>>> It means you haven't added any url matching / in your urlconfig, but
>>>>>>> it's hard to give a good answer without a bit more information. Have
>>>>>>> you completed the django tutorial which explains how these things
>>>>>>> work?
>>>>>>>
>>>>>>> Thomas
>>>>>>>
>>>>>>> On Tue, Feb 19, 2013 at 11:04 AM, Avnesh Shakya <
>>>>>>> avnesh.n...@gmail.com> wrote:
>>>>>>> > Hello, I'm stuck in teplagte page. error i

Re: error in templates...

2013-02-19 Thread Pankaj Singh
Hey,

I asked you to make changes in templates (i.e. home.html, about.html etc.)
and not urls.py.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Tue, Feb 19, 2013 at 4:56 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:

> hi pankaj, i have got again error same..
> if i change
>
> from django.conf.urls.defaults import *
> urlpatterns= patterns('myapp.views',
> url(r'^$','home',name="home"),
> url(r'^about/$','about',name="about"),
> url(r'^contact/$','contact',name="contact"),
> url(r'^contact/$','archive',name="archive"),
> )
> its to
>
> from django.conf.urls.defaults import *
> urlpatterns= patterns('myapp.views',
> url(r'^$','home',name="home"),
> url(r'^$','about',name="about"),
> url(r'^$','contact',name="contact"),
> url(r'^$','archive',name="archive"),
> )
> then it's not generating error but that links are not opening.
> thanks
>
> On Tue, Feb 19, 2013 at 4:28 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>
>> Hey Avnesh,
>>
>> In your templates you have written following lines
>>
>> homeabout> href="{% url archive %}">archivecontact
>>
>> Change them to following, notice single quotes surrounding url pattern
>> name
>>
>> homeabout> href="{% url 'archive' %}">archivecontact
>>
>>
>>
>> Sincerely,
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Tue, Feb 19, 2013 at 4:06 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:
>>
>>>
>>>
>>> On Tue, Feb 19, 2013 at 3:47 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:
>>>
>>>> ya i have completed and i m just doing copy n paste from from tutorial
>>>> but there is no error but i m facing this error again n again...
>>>> https://www.udemy.com/full-django-tutorial/#lecture/63701/question/9902
>>>> can i add my page for help. i need your help plz..
>>>>
>>>>
>>>>
>>>> On Tue, Feb 19, 2013 at 3:39 PM, Thomas Weholt <thomas.weh...@gmail.com
>>>> > wrote:
>>>>
>>>>> It means you haven't added any url matching / in your urlconfig, but
>>>>> it's hard to give a good answer without a bit more information. Have
>>>>> you completed the django tutorial which explains how these things
>>>>> work?
>>>>>
>>>>> Thomas
>>>>>
>>>>> On Tue, Feb 19, 2013 at 11:04 AM, Avnesh Shakya <avnesh.n...@gmail.com>
>>>>> wrote:
>>>>> > Hello, I'm stuck in teplagte page. error is occuring here
>>>>> after
>>>>> > runserver..
>>>>> >
>>>>> > error..
>>>>> >
>>>>> >  NoReverseMatch at / Reverse for '' with arguments '()' and keyword
>>>>> > arguments '{}' not found.
>>>>> >
>>>>> > I can't figure out why I'm getting the error, plz tell me, i have
>>>>> totally
>>>>> > confused here.
>>>>> >
>>>>> >
>>>>> > thanks
>>>>> >
>>>>> > avnesh shakya
>>>>> >
>>>>> > --
>>>>> > 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+unsubscr...@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?hl=en.
>>>>> > For more options, visit https://groups.google.com/groups/opt_out.
>>>>> >
>>>>> >
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Mvh/Best regards,
>>>>> Thomas Weholt
>>>>> http://www.weholt.org
>>>>>
>>>>> --
>>>>> 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+unsubscr...@googlegroups.com.
>>>>> To post to this group, se

Re: error in templates...

2013-02-19 Thread Pankaj Singh
Hey Avnesh,

In your templates you have written following lines

homeaboutarchivecontact

Change them to following, notice single quotes surrounding url pattern name

homeaboutarchivecontact



Sincerely,
Pankaj Singh
http://about.me/psjinx


On Tue, Feb 19, 2013 at 4:06 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:

>
>
> On Tue, Feb 19, 2013 at 3:47 PM, Avnesh Shakya <avnesh.n...@gmail.com>wrote:
>
>> ya i have completed and i m just doing copy n paste from from tutorial
>> but there is no error but i m facing this error again n again...
>> https://www.udemy.com/full-django-tutorial/#lecture/63701/question/9902
>> can i add my page for help. i need your help plz..
>>
>>
>>
>> On Tue, Feb 19, 2013 at 3:39 PM, Thomas Weholt 
>> <thomas.weh...@gmail.com>wrote:
>>
>>> It means you haven't added any url matching / in your urlconfig, but
>>> it's hard to give a good answer without a bit more information. Have
>>> you completed the django tutorial which explains how these things
>>> work?
>>>
>>> Thomas
>>>
>>> On Tue, Feb 19, 2013 at 11:04 AM, Avnesh Shakya <avnesh.n...@gmail.com>
>>> wrote:
>>> > Hello, I'm stuck in teplagte page. error is occuring here after
>>> > runserver..
>>> >
>>> > error..
>>> >
>>> >  NoReverseMatch at / Reverse for '' with arguments '()' and keyword
>>> > arguments '{}' not found.
>>> >
>>> > I can't figure out why I'm getting the error, plz tell me, i have
>>> totally
>>> > confused here.
>>> >
>>> >
>>> > thanks
>>> >
>>> > avnesh shakya
>>> >
>>> > --
>>> > 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+unsubscr...@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?hl=en.
>>> > For more options, visit https://groups.google.com/groups/opt_out.
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Mvh/Best regards,
>>> Thomas Weholt
>>> http://www.weholt.org
>>>
>>> --
>>> 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+unsubscr...@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?hl=en.
>>> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re:

2013-02-18 Thread Pankaj Singh
Right. 'UsernaBaseProfile' should be 'UserenaBaseProfile'.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Tue, Feb 19, 2013 at 12:53 PM, Zhao Quan <felixz2...@gmail.com> wrote:

> thanks I resolve that issue,
> seems the parameter miss a 'e'.
>
>
> On Tue, Feb 19, 2013 at 3:15 PM, Zhao Quan <felixz2...@gmail.com> wrote:
>
>> thanks Pankaj for replay my question so quickly. :)
>>
>> I already add this code in models.py
>> code as below.
>> I place it under path "mysite/accounts/models.py"
>>
>> models.py
>> from django.db import models
>>
>> # Create your models here.
>> from django.contrib.auth.models import User
>> from django.utils.translation import ugettext as _
>> from userena.models import UserenaBaseProfile
>>
>> class MyProfile(UsernaBaseProfile):
>>   user = models.OneToOneField(User,
>>   unique=True,
>>   verbose_name=_('user'),
>>   related_name='my_profile')
>>   favourite_snack = models.CharField(_('favourite snack'),
>>  max_length=5)
>>
>> So many thanks for u,
>> Felix Zhao
>>
>>
>> On Tue, Feb 19, 2013 at 3:10 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>
>>> Hey,
>>>
>>> You need to import UserenaBaseProfile in your models.py before defining
>>> MyProfile class.
>>>
>>> from userena.models import UserenaBaseProfile
>>>
>>> http://docs.django-userena.org/en/latest/installation.html#profiles
>>>
>>> Sincerely,
>>> Pankaj Singh
>>> http://about.me/psjinx
>>>
>>>
>>> On Tue, Feb 19, 2013 at 12:36 PM, Zhao Quan <felixz2...@gmail.com>wrote:
>>>
>>>> Hi all,
>>>>
>>>> I fish for django.
>>>> So, I want to use some code to handle use login and registion issue.
>>>> I find the code name "django-userena"
>>>>
>>>> But, after I follow the guide to setup.
>>>> http://docs.django-userena.org/en/latest/installation.html
>>>>  I get exception like this: NameError: name 'UsernaBaseProfile' is not
>>>> defined
>>>>
>>>> detial info as below
>>>> -
>>>>
>>>> ~/djcode/mysite$ ./manage.py check_permissions
>>>> Traceback (most recent call last):
>>>>   File "./manage.py", line 10, in 
>>>> execute_from_command_line(sys.argv)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
>>>> line 443, in execute_from_command_line
>>>> utility.execute()
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
>>>> line 382, in execute
>>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
>>>> line 196, in run_from_argv
>>>> self.execute(*args, **options.__dict__)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
>>>> line 231, in execute
>>>> self.validate()
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
>>>> line 266, in validate
>>>> num_errors = get_validation_errors(s, app)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py",
>>>> line 30, in get_validation_errors
>>>> for (app_name, error) in get_app_errors().items():
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
>>>> 158, in get_app_errors
>>>> self._populate()
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
>>>> 64, in _populate
>>>> self.load_app(app_name, True)
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
>>>> 88, in load_app
>>>> models = import_module('.models', app_name)
>>>>   File
>>>> "/usr/local/lib/

Re:

2013-02-18 Thread Pankaj Singh
Hey,

You need to import UserenaBaseProfile in your models.py before defining
MyProfile class.

from userena.models import UserenaBaseProfile

http://docs.django-userena.org/en/latest/installation.html#profiles

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Tue, Feb 19, 2013 at 12:36 PM, Zhao Quan <felixz2...@gmail.com> wrote:

> Hi all,
>
> I fish for django.
> So, I want to use some code to handle use login and registion issue.
> I find the code name "django-userena"
>
> But, after I follow the guide to setup.
> http://docs.django-userena.org/en/latest/installation.html
>  I get exception like this: NameError: name 'UsernaBaseProfile' is not
> defined
>
> detial info as below
> -
>
> ~/djcode/mysite$ ./manage.py check_permissions
> Traceback (most recent call last):
>   File "./manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 443, in execute_from_command_line
> utility.execute()
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 382, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 196, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 231, in execute
> self.validate()
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 266, in validate
> num_errors = get_validation_errors(s, app)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py",
> line 30, in get_validation_errors
> for (app_name, error) in get_app_errors().items():
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
> 158, in get_app_errors
> self._populate()
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
> 64, in _populate
> self.load_app(app_name, True)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
> 88, in load_app
> models = import_module('.models', app_name)
>   File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py",
> line 35, in import_module
> __import__(name)
>   File "/home/quanzhao/djcode/mysite/accounts/models.py", line 8, in
> 
> class MyProfile(UsernaBaseProfile):
> NameError: name 'UsernaBaseProfile' is not defined
>
>  --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Is it necessary to restart server after a change?

2013-02-18 Thread Pankaj Singh
Hey,

so touching wsgi.py will make it reload?


Please have a look at http://en.wikipedia.org/wiki/Touch_(Unix)

*touch* is a standard Unix <http://en.wikipedia.org/wiki/Unix>
program<http://en.wikipedia.org/wiki/Computer_program> used
> to change a file <http://en.wikipedia.org/wiki/Computer_file>'s access
> and modification timestamps <http://en.wikipedia.org/wiki/System_time>.
> It is also used to create a new empty file.


Since, timestamp of is changed, server thinks that actual wsgi script has
changed.

Detection of the change in the script file will occur at the time of the
> first request to arrive after the change has been made. The way that the
> restart is performed does not affect the handling of the request, with it
> still being processed once the daemon process has been restarted.


This is standard deployment practice.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Mon, Feb 18, 2013 at 8:43 PM, frocco <faro...@gmail.com> wrote:

> Thank you, so touching wsgi.py will make it reload?
> That's great, I am also learning linux. :-)
>
>
> On Monday, February 18, 2013 9:26:40 AM UTC-5, frocco wrote:
>>
>> Hello,
>>
>> In PHP, if I make a change to the database query, like adding a where
>> clause to filter only active records, the user sees the change on the next
>> browser refresh.
>> In django, it seems I have to restart the server and knock everyone off.
>>
>> I am a newbie, so is there a better way?
>> I just started a trial on webfraction
>>
>  --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Templates error on partial rendering

2013-02-18 Thread Pankaj Singh
Hey Andrea,

Please have a look at
http://stackoverflow.com/questions/4300442/show-undefined-variable-errors-in-templates

Put this in your debug settings:

class InvalidString(str):
def __mod__(self, other):
from django.template.base import TemplateSyntaxError
raise TemplateSyntaxError(
"Undefined variable or unknown value for: \"%s\"" % other)

TEMPLATE_STRING_IF_INVALID = InvalidString("%s")

This should raise an error when the template engine sees or finds an
undefined value.

Another trick is to set TEMPLATE_STRING_IF_INVALID to "%s %s" and that
will cause a formatting error to be raised.

https://docs.djangoproject.com/en/1.2/ref/templates/api/#how-invalid-variables-are-handled

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Mon, Feb 18, 2013 at 4:02 PM, andrea crotti
<andrea.crott...@gmail.com> wrote:
> I have a case where we use django templates, but it really makes no sense to
> render the templates if a value is not passed in the contentx, and it should
> just fail..
>
> I don't find anywhere how to force that though, I understand the default of
> failing silently but there should be a way also to fail making some noise,
> right?
>
> --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Is it necessary to restart server after a change?

2013-02-18 Thread Pankaj Singh
Hey,

Touching wsgi.py file is enough. Find more details at
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Reloading_In_Daemon_Mode

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Mon, Feb 18, 2013 at 7:56 PM, frocco <faro...@gmail.com> wrote:

> Hello,
>
> In PHP, if I make a change to the database query, like adding a where
> clause to filter only active records, the user sees the change on the next
> browser refresh.
> In django, it seems I have to restart the server and knock everyone off.
>
> I am a newbie, so is there a better way?
> I just started a trial on webfraction
>
> --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Custom Http404 like exception

2013-02-18 Thread Pankaj Singh
Hey Serge,

Here is a brief description of how status code is set in request response
cycle of Django.

*Http404* inherits from *Exception* defined here -
https://github.com/django/django/blob/1.4.3/django/http/__init__.py#L132-L133

*get_response() method of django.core.handlers.base.BaseHandler handles
Http404 and sets status code here* -
https://github.com/django/django/blob/stable/1.4.x/django/core/handlers/base.py#L138-L155

*django.core.handlers.base.BaseHandler* has some code for setting
status_code to 403 and 500 as well.

I want to make the same but with for a 401 code and a custom redirection
> according to the resource to be accessed.


There is really simple way to do this.

class HttpResponseUnauthorizedRequest(HttpResponse):
status_code = 401


You can use this class similar to HttpResponse

def protected_view(request):
## handle authorization
## if not authorized then return above response
return HttpResponseUnauthorizedRequest("Authorazation is required")


There are similar classes for different status code as well -
https://github.com/django/django/blob/stable/1.4.x/django/http/__init__.py#L751-L770

Similar implementation by django-tastypie -
https://github.com/toastdriven/django-tastypie/blob/master/tastypie/http.py

So you have set status code, now what

*process_response()* method of
*django.middleware.common.CommonMiddleware*checks if status code is
404 and sends an email to admins for broken urls -
https://github.com/django/django/blob/stable/1.4.x/django/middleware/common.py#L94-L109

You can see status_code based processing of response in other middlewares
as well, e.g. cache, http and csrf.

Finally request handlers set status code is response header -

1. django.core.handlers.wsgi.WSGIHandler sets status code in response
header -
https://github.com/django/django/blob/stable/1.4.x/django/core/handlers/wsgi.py#L245-L253

2. If you are using modpython then status_code in header is set by
django.core.handlers.modpython.ModPythonHandler -
https://github.com/django/django/blob/stable/1.4.x/django/core/handlers/wsgi.py#L245-L253

This response is served by Webserver.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Mon, Feb 18, 2013 at 6:15 PM, Serge G. Spaolonzi <se...@cobalys.com>wrote:

> Hi,
>
> How does the Http404 exception works internally?
> I want to make the same but with for a 401 code and a custom
> redirection according to the resource to be accessed.
> I have thought about using a middleware to archive this but I am not
> sure if it is standard way used by 'django.http.Http404'.
>
> Thanks
>
> --
> Serge G. Spaolonzi
> Cobalys Systems
> http://www.cobalys.com
>
> --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Conflict of admin applications for jquery

2013-02-18 Thread Pankaj Singh
Hey,

By default, Django's Admin moves the jQuery namespace into a custom one,
django.jQuery, to prevent conflicts[1]. So core of django admin won't get
affected until and unless you override django.jQuery.

I understand why developers plug in latest jquery version, but why Django
> is stuck with jQuery 1.4?


As you can see on Github[2], last change to some javascript files was 2
years ago. That's why admin still has jQuery 1.4.2 which was released on
February 19, 2010 [4].

Migrating to a newer release will require a lot of effort (which may not be
worth it), that's why Django is stuck with jQuery 1.4.2.

Further, many people use django-grappelli[5] and django-admin-tools[6]
nowadays to replace default admin interface.

By the way, django-markitup uses settings.JQUERY_URL[3]. If you want to use
a specific version of jQuery then you can specify that in settings.py.

Links:
1.
https://github.com/django/django/blob/1.4.3/django/contrib/admin/static/admin/js/jquery.init.js
2.
https://github.com/django/django/tree/master/django/contrib/admin/static/admin/js
3. http://goo.gl/Mhwlj
4. http://en.wikipedia.org/wiki/JQuery#Release_history
5. http://www.grappelliproject.com/
6. http://django-admin-tools.readthedocs.org/en/latest/

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Sun, Feb 17, 2013 at 1:11 PM, Владимир Паль <mail.v...@gmail.com> wrote:

> Hi, I have following problem.
> It is quite often that django admin plugins include their own version of
> jquery and it is not possible to use them together.
>
> For example: django-markitup and django-sortable. Is there any way to get
> around the issue? Do I need to rewrite plugin(s) to use noConflict?
>
> I understand why developers plug in latest jquery version, but why Django
> is stuck with jQuery 1.4?
>
>  --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error passing data from views to template

2013-02-18 Thread Pankaj Singh
Hey Tiago,


> Exception Value: 'str' object has no attribute 'update'


It means that context_instance variable passed to render_to_string() is of
str type. context_instance needs to be an instance of
django.template.context.Context class.

Example use of render_to_string -

from django.template.loader import render_to_string
rendered = render_to_string('my_template.html', { 'foo': 'bar' })


Django docs -
https://docs.djangoproject.com/en/1.4/ref/templates/api/#the-render-to-string-shortcut

If interested, you can have a look at source code for Context class (
https://github.com/django/django/blob/1.4.3/django/template/context.py#L84).

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Mon, Feb 18, 2013 at 12:04 AM, Tiago Carvalho <tyagucarva...@gmail.com>wrote:

> Hello,
>
> I'm new to Django and I'm with an error, passing data from views to
> templates.
>
> Here is the traceback: http://dpaste.com/942117/
>
> Request URL: http://localhost:8000/about/
> Django Version: 1.4.3
> Exception Type: AttributeError
> *Exception Value: 'str' object has no attribute 'update'*
> Exception Location: 
> /usr/local/lib/python2.7/dist-packages/django/template/loader.py
> in render_to_string, line 174
>
>
> Somebody can help me, please?
>
> --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django superstars I should be following?

2013-02-05 Thread Pankaj Singh
Hey,

I follow these people on twitter -

https://twitter.com/jacobian
https://twitter.com/aymericaugustin
https://twitter.com/spookylukey
https://twitter.com/julienphalip
https://twitter.com/freakboy3742
https://twitter.com/jezdez

And these too
https://twitter.com/djangohire
https://twitter.com/djangolinks
https://twitter.com/djangodose
https://twitter.com/djangosnippets


You might be interested in
https://twitter.com/statuscode (weekly newsletter)
https://twitter.com/pycoders (weekly newsletter)

You can find more in twitter recommendations.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Wed, Feb 6, 2013 at 2:21 AM, Glyn Jackson <cfspa...@gmail.com> wrote:

> I'm looking for suggestions on who to follow on twitter.
> Who are the Django superstars, and the opinionated and guy/grils I should
> be following?
>
>
> :) 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to delete in the admin - strategy needed

2013-02-05 Thread Pankaj Singh
Hey Mike,

I tried to replicate what you were trying to do and I got it working.

By the way, you can directly delete filtered child objects, no need to
create a list. And you don't need to create a list for iterating over a
queryset.

Queryset supports iteration by default(
https://docs.djangoproject.com/en/dev/topics/db/queries/#querysets-are-lazy
).

Here is models.py:

from django.db import modelsfrom django.db.models.signals import
pre_deletefrom django.dispatch import receiver

class Master(models.Model):
name = models.CharField(max_length=200)

def __unicode__(self):
return self.name

class Parent(models.Model):
name = models.CharField(max_length=200)
master = models.ForeignKey(Master)
mark = models.CharField(max_length=40)

def __unicode__(self):
return self.name

def clean_out(self):
Child.objects.filter(master=self.master, tags=self.mark).delete()

child_lst = Child.objects.filter(master=self.master,
 tags__contains=self.mark)
for child in child_lst:
marks = child.tags.split()
marks.remove(self.mark)
child.tags = ' '.join(marks)
child.save()

class Child(models.Model):
name = models.CharField(max_length=200)
tags = models.TextField()
master = models.ForeignKey(Master)

def __unicode__(self):
return self.name

@receiver(pre_delete, sender=Parent)def parent_delete_handeler(sender,
instance, *args, **kwargs):
instance.clean_out()


Sincerely,
Pankaj Singh
http://about.me/psjinx


On Tue, Feb 5, 2013 at 12:15 PM, Mike Dewhirst <mi...@dewhirst.com.au>wrote:

> Could someone please point out my mistake?
>
> def clean_out(self):
> child_lst = list(Child.objects.filter(**master=self.master,
>   tags=self.mark))
> for child in child_lst:
> child.delete()
>
> child_lst = list(Child.objects.filter(**master=self.master,
>   tags__contains=self.mark))
> for child in child_lst:
> marks = child.tags.split()
> marks = marks.remove(self.mark)
> child.tags = ' '.join(marks)
> child.save()
>
>
> The "self" in this case is an instance of the Parent class and clean_out()
> is a Parent model method. Both Parent and Child have a foreign key
> relationship with the Master model. Nothing has a foreign key pointing to
> either Parent or Child.
>
> Parent.clean_out() method is connected to the pre_delete signal of the
> Parent model.
>
> The purpose of the method is more or less documented below.
>
> I've tried this a number of different ways and always get the "Select a
> valid choice ..." error mentioned below.
>
>
> On 4/02/2013 6:14pm, Mike Dewhirst wrote:
>
>> This is the error ... Select a valid choice. That choice is not one of
>> the available choices.
>>
>> I want to delete a bunch of "child" records when a "parent" record is
>> deleted. While I'm using that terminology they are not actually related
>> in the usual sense. All however are in foreign key relationships with
>> the same owner/master.
>>
>> The child records all know which parents they have because the parent
>> added its mark to a field in the child when the child record got created
>> and linked to the master. In fact if that child had been added by
>> another parent, the next parent just adds its mark instead of adding
>> another child.
>>
>> When a parent gets deleted from the master, its mark is removed from all
>> the child records it was involved with and if it was the only mark the
>> child gets deleted too. Or at least that is what I want to happen.
>>
>> My question is:
>>
>> In overview, how should I be doing this?
>>
>> At the moment I'm trying to do it all via model methods calling various
>> managers because it feels like the right place to do it.
>>
>> I have tried to make a custom manager with use_for_related_fields = True
>> but still get the same error.
>>
>> Thanks for any help
>>
>> Mike
>>
>>
> --
> 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<django-users%2bunsubscr...@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?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
>

Re: Custum save on Foreignkey in Admin

2013-02-05 Thread Pankaj Singh
Hey Avnesh,

First of all, your question is not related to current conversation. You
should have started a new thread this.

You are getting this error because foo.views.index does not exist, i.e.,
there is no `index` function in views.py file of your `foo` app.

P.S. - Please use regular font size.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Tue, Feb 5, 2013 at 1:13 PM, Avnesh Shakya <avnesh.n...@gmail.com> wrote:

>  plz tell me why this error is coming here... after setting urls.py.
> plz help me..
> ViewDoesNotExist at /admin/
>
>
> Could not import foo.views.index. View does not exist in module foo.views.
>
> Request Method: GETRequest URL: http://127.0.0.1:8000/admin/ Django
> Version:1.4.3 Exception Type:ViewDoesNotExist Exception Value:
>
> Could not import foo.views.index. View does not exist in module foo.views.
>
> Exception Location:C:\Python27\lib\site-packages\django\core\urlresolvers.py 
> in get_callable,
> line 101 Python Executable:C:\Python27\python.exe Python Version:2.7.3Python 
> Path:
>
> ['C:\\mysite',
>  'C:\\Windows\\system32\\python27.zip',
>  'C:\\Python27\\DLLs',
>  'C:\\Python27\\lib',
>  'C:\\Python27\\lib\\plat-win',
>  'C:\\Python27\\lib\\lib-tk',
>  'C:\\Python27',
>  'C:\\Python27\\lib\\site-packages']
>
> Server time: Tue, 5 Feb 2013 13:08:47 +0530
>
>
> On Tue, Feb 5, 2013 at 12:47 PM, Rob van Dam | Camping het Wieskamp <
> r...@wieskamp.nl> wrote:
>
>> Hi Pankaj,
>>
>> I tested the code at it works perfectly. Thanks again!
>>
>> I have one question out of curiosity (I don't need this for this
>> project). When a ticketitem is deleted, def save_formset is called, but no
>> instance is made, hence an error message "instance referenced before
>> assignment"
>>
>> What is the correct way to deal with this?
>>
>> I don't need this for my current project, so if you don't answer it, it
>> is no problem at all.
>>
>> Regards,
>>
>> Rob
>>
>> On 04-02-13 18:50, Pankaj Singh wrote:
>>
>>> Yes, save_formset() has only those instances whose fields were changed.
>>>
>>> Sincerely,
>>> Pankaj Singh
>>> http://about.me/psjinx
>>>
>>>
>>> On Mon, Feb 4, 2013 at 10:46 PM, Rob van Dam <r...@wieskamp.nl> wrote:
>>>
>>>> Hi Pankaj,
>>>>
>>>> Thank you so much!!!! You have saved my day :-) I will be able to test
>>>> it
>>>> tomorrow, and I will let you know if it worked.
>>>>
>>>> I tested all my previous attempts saving an existing item in Admin. But
>>>> when
>>>> nothing is changed in the admin form, def save_formset is not
>>>> called..
>>>>
>>>> Regards,
>>>>
>>>> Rob
>>>>
>>>>
>>>>
>>>> On 04-02-13 17:26, Pankaj Singh wrote:
>>>>
>>>>> Hey Rob,
>>>>>
>>>>> I tested following code and it works.
>>>>>
>>>>>  models.py
>>>>>
>>>>> from django.db import models
>>>>>
>>>>> # Create your models here.
>>>>>
>>>>> class Ticket(models.Model):
>>>>>   ticketnumber = models.IntegerField()
>>>>>   total_amount = models.DecimalField(max_**digits=7,
>>>>> decimal_places=2,
>>>>> blank=True)
>>>>>
>>>>>   def update_total_amount(self):
>>>>>   total = 0
>>>>>   for ti in self.ticketitem_set.all():
>>>>>   total += ti.price * ti.amount
>>>>>   self.total_amount = total
>>>>>   self.save()
>>>>>
>>>>> class TicketItem(models.Model):
>>>>>   name = models.CharField(max_length=**30)
>>>>>   ticket = models.ForeignKey(Ticket)
>>>>>   price = models.DecimalField(max_**digits=7, decimal_places=2)
>>>>>   amount = models.IntegerField()
>>>>>
>>>>>
>>>>>  admin.py
>>>>> from django.contrib import admin
>>>>> from tickets.models import Ticket, TicketItem
>>>>>
>>>>>
>>>>> class TicketItemInline(admin.**TabularInline):
>>>>>   model = TicketItem
>>>>>
>>>>> class TicketAdmin(admin.ModelAdmin):
>>>>>   inlines = [TicketItemInline,]
>>>>>
>>>>>

Re: Custum save on Foreignkey in Admin

2013-02-04 Thread Pankaj Singh
Yes, save_formset() has only those instances whose fields were changed.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Mon, Feb 4, 2013 at 10:46 PM, Rob van Dam <r...@wieskamp.nl> wrote:
> Hi Pankaj,
>
> Thank you so much You have saved my day :-) I will be able to test it
> tomorrow, and I will let you know if it worked.
>
> I tested all my previous attempts saving an existing item in Admin. But when
> nothing is changed in the admin form, def save_formset is not called..
>
> Regards,
>
> Rob
>
>
>
> On 04-02-13 17:26, Pankaj Singh wrote:
>>
>> Hey Rob,
>>
>> I tested following code and it works.
>>
>>  models.py
>>
>> from django.db import models
>>
>> # Create your models here.
>>
>> class Ticket(models.Model):
>>  ticketnumber = models.IntegerField()
>>  total_amount = models.DecimalField(max_digits=7, decimal_places=2,
>> blank=True)
>>
>>  def update_total_amount(self):
>>  total = 0
>>  for ti in self.ticketitem_set.all():
>>  total += ti.price * ti.amount
>>  self.total_amount = total
>>  self.save()
>>
>> class TicketItem(models.Model):
>>  name = models.CharField(max_length=30)
>>  ticket = models.ForeignKey(Ticket)
>>  price = models.DecimalField(max_digits=7, decimal_places=2)
>>  amount = models.IntegerField()
>>
>>
>>  admin.py
>> from django.contrib import admin
>> from tickets.models import Ticket, TicketItem
>>
>>
>> class TicketItemInline(admin.TabularInline):
>>  model = TicketItem
>>
>> class TicketAdmin(admin.ModelAdmin):
>>  inlines = [TicketItemInline,]
>>
>>  def save_formset(self, request, form, formset, change):
>>  instances = formset.save(commit=False)
>>  for instance in instances:
>>  instance.save()
>>  formset.save_m2m()
>>  instance.ticket.update_total_amount()
>>
>>
>> admin.site.register(Ticket, TicketAdmin)
>>
>>
>> I hope it helps.
>>
>> Sincerely,
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Mon, Feb 4, 2013 at 9:01 PM, Rob van Dam | Camping het Wieskamp
>> <r...@wieskamp.nl> wrote:
>>>
>>> Hi Pankaj,
>>>
>>> I have tried many things today, but unfortunately I cannot get anything
>>> working :-( Can you give me a bit more information on this issue? Any
>>> hint
>>> would be highly appreciated!
>>>
>>> I cannot get anything saved in the database. For testing I made this
>>> setup
>>> (added ordernumber to the Tickets model):
>>>
>>>
>>> class TicketAdmin(admin.ModelAdmin):
>>>  def save_formset(self, request, form, formset, change):
>>>      instances = formset.save(commit=False)
>>>  for instance in instances:
>>>  instance.ordernumber = 100
>>>  instance.save()
>>>  formset.save_m2m()
>>>
>>> I expected the value 100 to be saved in the databasebut nothing
>>> works.
>>>
>>> Rob
>>>
>>>
>>>
>>>
>>> On 02-02-13 21:04, Pankaj Singh wrote:
>>>>
>>>>
>>>>
>>>> http://stackoverflow.com/questions/8294889/override-save-on-django-inlinemodeladmin
>>>>
>>>> Sincerely,
>>>> Pankaj Singh
>>>> http://about.me/psjinx
>>>>
>>>>
>>>> On Sun, Feb 3, 2013 at 1:34 AM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>>>>
>>>>> Hey Rob,
>>>>>
>>>>> You can override save_formset() method of ModelAdmin for this. Create
>>>>> a method update_total_amount(self) in your Ticket Model.
>>>>>
>>>>> class TicketAdmin(admin.ModelAdmin):
>>>>>   def save_formset(self, request, form, formset, change):
>>>>>   instances = formset.save(commit=False)
>>>>>   for instance in instances:
>>>>>   instance.user = request.user
>>>>>   instance.save()
>>>>>   formset.save_m2m()
>>>>>
>>>>>   ## call update_total_amount()
>>>>>   instance.update_total_amount()
>>>>>
>>>>> Useful Links -
>>>>> 1.
>>>>>
>>>>

Re: Custum save on Foreignkey in Admin

2013-02-04 Thread Pankaj Singh
Hey Rob,

I tested following code and it works.

 models.py

from django.db import models

# Create your models here.

class Ticket(models.Model):
ticketnumber = models.IntegerField()
total_amount = models.DecimalField(max_digits=7, decimal_places=2,
blank=True)

def update_total_amount(self):
total = 0
for ti in self.ticketitem_set.all():
total += ti.price * ti.amount
self.total_amount = total
self.save()

class TicketItem(models.Model):
name = models.CharField(max_length=30)
ticket = models.ForeignKey(Ticket)
price = models.DecimalField(max_digits=7, decimal_places=2)
amount = models.IntegerField()


 admin.py
from django.contrib import admin
from tickets.models import Ticket, TicketItem


class TicketItemInline(admin.TabularInline):
model = TicketItem

class TicketAdmin(admin.ModelAdmin):
inlines = [TicketItemInline,]

def save_formset(self, request, form, formset, change):
instances = formset.save(commit=False)
for instance in instances:
instance.save()
formset.save_m2m()
instance.ticket.update_total_amount()


admin.site.register(Ticket, TicketAdmin)


I hope it helps.

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Mon, Feb 4, 2013 at 9:01 PM, Rob van Dam | Camping het Wieskamp
<r...@wieskamp.nl> wrote:
> Hi Pankaj,
>
> I have tried many things today, but unfortunately I cannot get anything
> working :-( Can you give me a bit more information on this issue? Any hint
> would be highly appreciated!
>
> I cannot get anything saved in the database. For testing I made this setup
> (added ordernumber to the Tickets model):
>
>
> class TicketAdmin(admin.ModelAdmin):
> def save_formset(self, request, form, formset, change):
> instances = formset.save(commit=False)
> for instance in instances:
> instance.ordernumber = 100
> instance.save()
> formset.save_m2m()
>
> I expected the value 100 to be saved in the database....but nothing works.
>
> Rob
>
>
>
>
> On 02-02-13 21:04, Pankaj Singh wrote:
>>
>>
>> http://stackoverflow.com/questions/8294889/override-save-on-django-inlinemodeladmin
>>
>> Sincerely,
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Sun, Feb 3, 2013 at 1:34 AM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>>
>>> Hey Rob,
>>>
>>> You can override save_formset() method of ModelAdmin for this. Create
>>> a method update_total_amount(self) in your Ticket Model.
>>>
>>> class TicketAdmin(admin.ModelAdmin):
>>>  def save_formset(self, request, form, formset, change):
>>>  instances = formset.save(commit=False)
>>>  for instance in instances:
>>>  instance.user = request.user
>>>  instance.save()
>>>  formset.save_m2m()
>>>
>>>  ## call update_total_amount()
>>>  instance.update_total_amount()
>>>
>>> Useful Links -
>>> 1.
>>> https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset
>>> 2.
>>> https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset
>>>
>>> Sincerely,
>>> Pankaj Singh
>>> http://about.me/psjinx
>>>
>>>
>>> On Sat, Feb 2, 2013 at 8:29 PM, Rob <r...@wieskamp.nl> wrote:
>>>>
>>>>   I have two models:
>>>>
>>>> class Tickets(models.Model):
>>>> ticketnumber = models.IntegerField()
>>>> total_amount = models.DecimalField()
>>>>
>>>> class TicketItems(models.Model):
>>>> name = models.Charfield(max_length=30)
>>>> ticket = models.ForeignKey(Tickets)
>>>> price = models.DecimalField()
>>>> amount = models.IntergerField()
>>>>
>>>> I have an inline Adminpage were users can add TicketItems. How do I
>>>> update
>>>> the total_amount of model Tickets from all TicketItems on save (price *
>>>> amount)?
>>>>
>>>> Django 1.4
>>>>
>>>> --
>>>> 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+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> V

Re: Custum save on Foreignkey in Admin

2013-02-02 Thread Pankaj Singh
http://stackoverflow.com/questions/8294889/override-save-on-django-inlinemodeladmin

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Sun, Feb 3, 2013 at 1:34 AM, Pankaj Singh <ps.j...@gmail.com> wrote:
> Hey Rob,
>
> You can override save_formset() method of ModelAdmin for this. Create
> a method update_total_amount(self) in your Ticket Model.
>
> class TicketAdmin(admin.ModelAdmin):
> def save_formset(self, request, form, formset, change):
> instances = formset.save(commit=False)
> for instance in instances:
> instance.user = request.user
> instance.save()
> formset.save_m2m()
>
> ## call update_total_amount()
> instance.update_total_amount()
>
> Useful Links -
> 1. 
> https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset
> 2. 
> https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset
>
> Sincerely,
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Sat, Feb 2, 2013 at 8:29 PM, Rob <r...@wieskamp.nl> wrote:
>>  I have two models:
>>
>> class Tickets(models.Model):
>>ticketnumber = models.IntegerField()
>>total_amount = models.DecimalField()
>>
>> class TicketItems(models.Model):
>>name = models.Charfield(max_length=30)
>>ticket = models.ForeignKey(Tickets)
>>price = models.DecimalField()
>>amount = models.IntergerField()
>>
>> I have an inline Adminpage were users can add TicketItems. How do I update
>> the total_amount of model Tickets from all TicketItems on save (price *
>> amount)?
>>
>> Django 1.4
>>
>> --
>> 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+unsubscr...@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?hl=en.
>> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Custum save on Foreignkey in Admin

2013-02-02 Thread Pankaj Singh
Hey Rob,

You can override save_formset() method of ModelAdmin for this. Create
a method update_total_amount(self) in your Ticket Model.

class TicketAdmin(admin.ModelAdmin):
def save_formset(self, request, form, formset, change):
instances = formset.save(commit=False)
for instance in instances:
instance.user = request.user
instance.save()
formset.save_m2m()

## call update_total_amount()
instance.update_total_amount()

Useful Links -
1. 
https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset
2. 
https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset

Sincerely,
Pankaj Singh
http://about.me/psjinx


On Sat, Feb 2, 2013 at 8:29 PM, Rob <r...@wieskamp.nl> wrote:
>  I have two models:
>
> class Tickets(models.Model):
>ticketnumber = models.IntegerField()
>total_amount = models.DecimalField()
>
> class TicketItems(models.Model):
>name = models.Charfield(max_length=30)
>ticket = models.ForeignKey(Tickets)
>price = models.DecimalField()
>amount = models.IntergerField()
>
> I have an inline Adminpage were users can add TicketItems. How do I update
> the total_amount of model Tickets from all TicketItems on save (price *
> amount)?
>
> Django 1.4
>
> --
> 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+unsubscr...@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?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Bookmarker Site

2013-01-29 Thread Pankaj Singh
Hey Ranjith,

For example bookmark apps in django please have a look at follwing urls:

https://github.com/brosner/django-bookmarks
https://github.com/raynesax/django-bookmarks
http://django-generic-bookmarks.readthedocs.org/en/latest/

If you want to extract text and title etc. for an url then you can use
http://viewtext.org/help/api for this. I have embedded an interactive code
snippet below.

I used python-requests(http://docs.python-requests.org/en/latest/) and
html2text (https://github.com/aaronsw/html2text) for this.

In [1]: import requestsIn [2]: from html2text import html2textIn [3]:
r = 
requests.get("http://viewtext.org/api/text?url=https://docs.djangoproject.com/en/1.4/topics/testing/=json=false;)In
[4]: data = r.json()In [5]: print html2text(data["title"])Testing
Django applications | Django documentation | DjangoIn [6]: print
html2text(data["content"][:400])Automated testing is an extremely
useful bug-killing tool for the modern Webdeveloper. You can use a
collection of tests - a **test suite** - to solve, oravoid, a number
of problems:Testing a Web application is a complex task, because a Web
application is madeof several layers of logic - from HTTP-level
request handling, to formvalidation and proceIn [7]:


--
Pankaj Singh
http://about.me/psjinx


On Mon, Jan 28, 2013 at 8:21 AM, Ranjith Kumar <ranjitht...@gmail.com>
wrote:
> Hello All,
> I wanted to build bookmarking web application using django, in this app
user
> can not only bookmark the site also they scrape few datas from the
> bookmarked page.
>
> Looking for good python/django tools which can help me achieve this aim
>
> Thank you!
>
> --
> Cheers,
> Ranjith Kumar K,
> Chennai.
>
> http://ranjithtenz.wordpress.com
>
>
> --
> 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-users+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> 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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Missing files on a new project

2013-01-27 Thread Pankaj Singh
Hey,

Django-book has not been updated for a long time and tutorials you went
through are based on Django 1.0

In Django 1.4, settings.py, urls.py and other project related files are
located under a directory with project name.

In you case if you look into demo/ folder, you will see urls.py and
setting.py.

On Monday, January 28, 2013, Ricardo Diaz wrote:

> Hi, I'm pretty noob with Django.
>
> I've readed a few pages of the Django-book and just started to create my
> own projects.
>
> When I try to create a new project using django-admin startproject demo,
> it just creates 2 things
>
> project
>   l--demo
>   l--manage.py
>
> I don't know why it doesn't create the missing files: __init__.py
> settings.py and urls.py
>
> I'm working on Ubuntu 12.04 and this happens on Django 1.4.3 and 1.4
> versions
>
> Thx for your help.
>
> --
> 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<javascript:_e({}, 'cvml', 
> 'django-users@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com <javascript:_e({}, 'cvml',
> 'django-users%2bunsubscr...@googlegroups.com');>.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
--
Pankaj Singh
http://about.me/psjinx

-- 
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-users+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How Django sends push notifications.

2013-01-27 Thread Pankaj Singh
On 00:39 -0500 / 28 Jan, Chen Xu wrote:
> I am recently building a web service for my iphone app, just wondering if
> Django can send push notifications to iPhone.
Django has no in-built feature for this, however, you can use 3rd party python 
libraries for this.

Please have a look at this blog post - 
http://highonpython.com/index.php/setting-up-ios-push-notifications-apns-with-pythondjango-through-pyapns/

--
Pankaj

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: BigAutoField

2013-01-23 Thread Pankaj Singh
Hey Steve,

You should ask this questions in django-developers mailing list as
it's related to development of django itself. It will be best to hear
comments from Core Developers.

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 6:58 PM, SteveB <smbroo...@gmail.com> wrote:
> Can anybody provide an update on the request to define a BigAutoField in
> Django?
> We could really use this model field type without having to do workarounds
> and customizations.
> Can any of the Django developers comment on when this will be released?
>
> Thanks,
> Steve
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/etnu2n_Fc6wJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: interplay between django and twitter-bootstrap...

2013-01-23 Thread Pankaj Singh
Hey Sameer,

Django gives you complete freedom for choosing client side libraries.
You can easily use twitter-bootstrap in django templates. There are
many libraries written using django and bootstrap to create beautiful
forms. Here are some example -

1. http://django-crispy-forms.readthedocs.org/en/d-0/
2. https://github.com/pinax/django-forms-bootstrap
3. https://github.com/brutasse/django-floppyforms
4. https://github.com/earle/django-bootstrap
5. https://github.com/dyve/django-bootstrap-toolkit

For getting started with bootstrap and django,
1. Download twitter-bootstrap from official website
2. Create a new django project
3. Copy your html files in templates folder
4. Copy javascript files, css files and images in static folder
5. Try to get a static template up using TemplateView.
6. Now you can customize your templates further and use features of
django templates and views to make things more dynamic

This will give you basic understanding of `how to integrate django+bootstrap".

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 9:53 AM, SameerOak <sameer@gmail.com> wrote:
> Hello,
>
> I am new to web development and python and django was my immediate choice to
> start with. I am in a process of developing a moderated traffic portal.
> Coming straight to the query, can I design my web pages using
> twitter-bootstrap and django framework in the back-end?
>
> Kindly help.
>
> Regards,
> - sameer oak.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/WypNp46wXB0J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django admin - changelist view: keep selected items on multiple pages

2013-01-23 Thread Pankaj Singh
Hey Luke,

This is not related to link you mentioned. That link only talks about
`How to customize the admin change list`.

You can achieve what you want using cookies.

Please have a look at similar question
http://css-tricks.com/forums/discussion/12141/javascript-remember-what-was-selected-after-refresh/p1.

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 2:12 PM, luke lukes <lordluk...@gmail.com> wrote:
> a question about admin: in the changelist page, is it possible to keep the
> selected items of a page while going to another page and returning to it.
>
> I mean:
>
> I'm on the page 1;
> I select some items;
> then i go to page 2;
> I select other items;
> I return to page 1;
> my previous selection is lost.
>
> Is it possible to keep that selection somewhere (cookie, session,...)?
>
> thanks, Luke
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/h4gvzMFOXMcJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-registration-template

2013-01-23 Thread Pankaj Singh
Hey Sameer,

His project uses twitter bootstrap forms in templates. That's the only
unique thing about this project.

If you are looking for an email based registration app in django which
uses bootstrap forms then you can use this one.

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 2:21 PM, SameerOak <sameer@gmail.com> wrote:
> Hello,
>
> Sorry if you find my question too foolish or naive. Actually, I don't have
> any web development experience and this is the first time I'm trying to
> learn django and twitter-bootstrap. While searching on the forum for a
> solution about how to use twitter-bootstrap on the client side while django
> as MVC engine, I found link to your project. It isn't very clear to me as to
> what exactly your project is about? But my gut feel is this is something
> what I'm looking for.
>
> Please provide some more details.
>
> Regards,
> - sameer oak.
>
>
> On Friday, November 4, 2011 9:41:54 AM UTC+5:30, Ezequiel Bertti wrote:
>>
>> Hi,
>>
>> I just release a project on github with bootstrap from twitter v1.4 form
>> django-registration.
>>
>> Is a simple use of bootstrap just using template for render with css. No
>> python code need.
>>
>> Its is perfect sample for designers to know how to use bootstrap without
>> asking to programmer to do some fix in their code.
>>
>> https://github.com/ebertti/django-registration-bootstrap
>>
>> It is my first of many github public projects.
>>
>> --
>> Ezequiel Bertti
>> E-Mail: ebe...@gmail.com
>> From Brazil
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/hXQfJECymeUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
items = request.user. a11m1_user_itmes_set.all()

is equivalent to

items = A11M1_user_itmes.objects.filter(user=request.user)

`items` will contain all items A11M1_user_itmes related to currently
logged in user.

Now, if you want to get `content_object` for a particular item, do
something like following

i = items[0]

`i.content_object` will refer to original object used.

Please go through official documentation for GenericForeignKey once more.

Links:
1. 
https://docs.djangoproject.com/en/1.4/ref/contrib/contenttypes/#django.contrib.contenttypes.generic.GenericForeignKey

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 4:11 PM, Sarfraz ahmad <sarfrazdja...@gmail.com> wrote:
> i dont found any query related to this model bro
>
>
> On Wed, Jan 23, 2013 at 4:01 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>
>> If you want to get all `A11M1_user_items` objects then following query
>> should work
>>
>>
>> --
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad <sarfrazdja...@gmail.com>
>> wrote:
>> > i have the same model having one foreignkey to User and second to the
>> > ContentType
>> >
>> > class A11M1_user_itmes(models.Model):
>> > A11M1F1_user=models.ForeignKey(User)
>> > content_type = models.ForeignKey(ContentType)
>> > object_id = models.PositiveIntegerField()
>> > content_object = generic.GenericForeignKey('content_type',
>> > 'object_id')
>> > this is the code of ma model.. using this code i wanna get all
>> > objects
>> > related to current logged in user
>> >
>> >
>> > On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>> >>
>> >> So, you have a custom model like following
>> >>
>> >> class MyModel(models.Model):
>> >> ...
>> >> content_type = models.ForeignKey(ContentType)
>> >> ...
>> >>
>> >> And you want to run a query on MyModel which should return objects
>> >> from various apps related to currently logged in User.
>> >>
>> >> Is this what you want to achieve?
>> >>
>> >> Pankaj Singh
>> >> http://about.me/psjinx
>> >>
>> >>
>> >> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad
>> >> <sarfrazdja...@gmail.com>
>> >> wrote:
>> >> > thanx buddy bt i wish to do it in a manner that a model which has a
>> >> > foreign
>> >> > key to ContentType, when i make a query on this model it returns all
>> >> > the
>> >> > objects from various apps related to current logged in user
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh <ps.j...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> Hey Sarfraz,
>> >> >>
>> >> >> If you have an user object, then you can get all related objects
>> >> >> using
>> >> >> following code
>> >> >>
>> >> >> user = User.objects.get(username="psjinx")
>> >> >>
>> >> >> related_links = [rel.get_accessor_name() for rel in
>> >> >> user._meta.get_all_related_objects()]
>> >> >>
>> >> >> ## above code will give a list of attribute names for each related
>> >> >> object to an user
>> >> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>> >> >> 'recipient_set', 'customer']
>> >> >>
>> >> >> Now you can iterate over this list
>> >> >>
>> >> >> for link in related_links:
>> >> >> objects = getattr(user, link).all()
>> >> >> for object in objects:
>> >> >> ## do something with object
>> >> >>
>> >> >> FYI, getattr(user, link) is manager for that relate object.
>> >> >>
>> >> >>
>> >> >> Pankaj Singh
>> >> >> http://about.me/psjinx
>> >> >>
>> >> >>
>> >> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh <ps.j...@gmail.com>
>> >> >> wrote:
>> >> >> > Hey Sarfraz,
>> >> >> >
>> >> >> > You can use a

Re: download pdf in admin

2013-01-23 Thread Pankaj Singh
Hey Milan,

Uploaded files are available at `MEDIA_URL` which is generally set to
`/media`. So if you enable serving for media files, then your file should
be available at

http://127.0.0.1:8000/media/scany/2013/01/21/hrebci.pdf

Please have a look at official documentation for this,
https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-other-directories
.

--
Pankaj Singh
http://about.me/psjinx


On Tue, Jan 22, 2013 at 6:08 AM, grat <grats...@gmail.com> wrote:

> hi,
>
> i cannot download file upladed by admin.
>
> i have this model:
> class Smlouvy(models.Model):
> note= models.TextField(blank=True)
> pdf= models.FileField( upload_to =
> 'scany/%Y/%m/%d',blank=True,verbose_name="Pdf Filw")
>
> in Admin i upladed file, and file is in correct directory. But cannot
> download this file. I get this error:
>
> ...
> Page not found (404) Request Method: GETRequest URL:
> http://127.0.0.1:8000/scany/2013/01/21/hrebci.pdf
>
> Using the URLconf defined in maxmart.urls, Django tried these URL
> patterns, in this order:
>
>1. ^admin/
>
> The current URL, scany/2013/01/21/hrebci.pdf, didn't match any of these.
>
>
> Do you know, where is problem?
>
>
> Thanks Milan
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/pKPcvF3xW10J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
Sorry for last reply. I sent uncompleted email by mistake, while
looking at other laptop.

If you want to get all `A11M1_user_itmes ` objects then following
query should work

objects = request.user. a11m1_user_itmes_set.all()

You can use `content_object` attribute on each object in objects list
to get original object.

I used similar approach for creating a new feed similar to facebook.
Please have a look at related stackoverflow question,
http://stackoverflow.com/questions/2128886/django-way-for-building-a-news-feed-status-update-activity-stream.

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 4:01 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
> If you want to get all `A11M1_user_items` objects then following query
> should work
>
>
> --
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad <sarfrazdja...@gmail.com> 
> wrote:
>> i have the same model having one foreignkey to User and second to the
>> ContentType
>>
>> class A11M1_user_itmes(models.Model):
>> A11M1F1_user=models.ForeignKey(User)
>> content_type = models.ForeignKey(ContentType)
>> object_id = models.PositiveIntegerField()
>> content_object = generic.GenericForeignKey('content_type', 'object_id')
>> this is the code of ma model.. using this code i wanna get all objects
>> related to current logged in user
>>
>>
>> On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>>
>>> So, you have a custom model like following
>>>
>>> class MyModel(models.Model):
>>> ...
>>> content_type = models.ForeignKey(ContentType)
>>> ...
>>>
>>> And you want to run a query on MyModel which should return objects
>>> from various apps related to currently logged in User.
>>>
>>> Is this what you want to achieve?
>>>
>>> Pankaj Singh
>>> http://about.me/psjinx
>>>
>>>
>>> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad <sarfrazdja...@gmail.com>
>>> wrote:
>>> > thanx buddy bt i wish to do it in a manner that a model which has a
>>> > foreign
>>> > key to ContentType, when i make a query on this model it returns all the
>>> > objects from various apps related to current logged in user
>>> >
>>> >
>>> >
>>> >
>>> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>> >>
>>> >> Hey Sarfraz,
>>> >>
>>> >> If you have an user object, then you can get all related objects using
>>> >> following code
>>> >>
>>> >> user = User.objects.get(username="psjinx")
>>> >>
>>> >> related_links = [rel.get_accessor_name() for rel in
>>> >> user._meta.get_all_related_objects()]
>>> >>
>>> >> ## above code will give a list of attribute names for each related
>>> >> object to an user
>>> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>>> >> 'recipient_set', 'customer']
>>> >>
>>> >> Now you can iterate over this list
>>> >>
>>> >> for link in related_links:
>>> >> objects = getattr(user, link).all()
>>> >> for object in objects:
>>> >> ## do something with object
>>> >>
>>> >> FYI, getattr(user, link) is manager for that relate object.
>>> >>
>>> >>
>>> >> Pankaj Singh
>>> >> http://about.me/psjinx
>>> >>
>>> >>
>>> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh <ps.j...@gmail.com>
>>> >> wrote:
>>> >> > Hey Sarfraz,
>>> >> >
>>> >> > You can use any of following methods:
>>> >> >
>>> >> > User._meta.get_all_related_m2m_objects_with_model()
>>> >> > User._meta.get_all_related_objects()
>>> >> > User._meta.get_all_related_many_to_many_objects()
>>> >> > User._meta.get_all_related_objects_with_model()
>>> >> >
>>> >> > get_all_related_objects() is the one I guess you may want to use in
>>> >> > your
>>> >> > case.
>>> >> >
>>> >> > Pankaj Singh
>>> >> > http://about.me/psjinx
>>> >> >
>>> >> >
>>> >> > On We

Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
If you want to get all `A11M1_user_items` objects then following query
should work


--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad <sarfrazdja...@gmail.com> wrote:
> i have the same model having one foreignkey to User and second to the
> ContentType
>
> class A11M1_user_itmes(models.Model):
> A11M1F1_user=models.ForeignKey(User)
> content_type = models.ForeignKey(ContentType)
> object_id = models.PositiveIntegerField()
> content_object = generic.GenericForeignKey('content_type', 'object_id')
> this is the code of ma model.. using this code i wanna get all objects
> related to current logged in user
>
>
> On Wed, Jan 23, 2013 at 3:38 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>
>> So, you have a custom model like following
>>
>> class MyModel(models.Model):
>> ...
>> content_type = models.ForeignKey(ContentType)
>> ...
>>
>> And you want to run a query on MyModel which should return objects
>> from various apps related to currently logged in User.
>>
>> Is this what you want to achieve?
>>
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad <sarfrazdja...@gmail.com>
>> wrote:
>> > thanx buddy bt i wish to do it in a manner that a model which has a
>> > foreign
>> > key to ContentType, when i make a query on this model it returns all the
>> > objects from various apps related to current logged in user
>> >
>> >
>> >
>> >
>> > On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>> >>
>> >> Hey Sarfraz,
>> >>
>> >> If you have an user object, then you can get all related objects using
>> >> following code
>> >>
>> >> user = User.objects.get(username="psjinx")
>> >>
>> >> related_links = [rel.get_accessor_name() for rel in
>> >> user._meta.get_all_related_objects()]
>> >>
>> >> ## above code will give a list of attribute names for each related
>> >> object to an user
>> >> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>> >> 'recipient_set', 'customer']
>> >>
>> >> Now you can iterate over this list
>> >>
>> >> for link in related_links:
>> >> objects = getattr(user, link).all()
>> >> for object in objects:
>> >> ## do something with object
>> >>
>> >> FYI, getattr(user, link) is manager for that relate object.
>> >>
>> >>
>> >> Pankaj Singh
>> >> http://about.me/psjinx
>> >>
>> >>
>> >> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh <ps.j...@gmail.com>
>> >> wrote:
>> >> > Hey Sarfraz,
>> >> >
>> >> > You can use any of following methods:
>> >> >
>> >> > User._meta.get_all_related_m2m_objects_with_model()
>> >> > User._meta.get_all_related_objects()
>> >> > User._meta.get_all_related_many_to_many_objects()
>> >> > User._meta.get_all_related_objects_with_model()
>> >> >
>> >> > get_all_related_objects() is the one I guess you may want to use in
>> >> > your
>> >> > case.
>> >> >
>> >> > Pankaj Singh
>> >> > http://about.me/psjinx
>> >> >
>> >> >
>> >> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad
>> >> > <sarfrazdja...@gmail.com>
>> >> > wrote:
>> >> >> hello friends
>> >> >>   i have a project with 7 applications installed in
>> >> >> it
>> >> >> and i
>> >> >> want to get all the objects related to a particular user from all
>> >> >> the
>> >> >> applications of ma project. please tell me how can i get all
>> >> >> these
>> >> >> objects using ContentType framework
>> >> >>
>> >> >>
>> >> >> thank you all
>> >> >>
>> >> >> --
>> >> >> You received this message because you are subscribed to the Google
>> >> >> Groups
>> >> >> "Django users" group.
>> >> >> To view this discussion on the web visit
>> >> >> https://groups.google.

Re: Where can I put code that will get executed when page refreshes

2013-01-23 Thread Pankaj Singh
Hey,

You must be using a context variable to fill your `side_menu` block.

One reason for failure can be that, context variable is available in
template when `ntw.views.index` is called but not available when
'staff.views.index' is called.

--
Pankaj Singh
http://about.me/psjinx


On Tue, Jan 22, 2013 at 10:04 PM, frocco <faro...@gmail.com> wrote:
> I have a  index.html template that extends base.html
> In Index I has:
> {% block side_menu %}
> Content
> {% endblock %}
>
> I fill this block from a database table.
> This only works if I click on the home link.
> if I click any other link to view, the side-menu is not populated.
>
> url(r'^$', 'ntw.views.index', name='home'), works
> url(r'^staff/', 'staff.views.index'), does not work
>
> ntw.views.py has the code to query the database
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/tRmjXkGaeoEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Upload multiple files using Ajax

2013-01-23 Thread Pankaj Singh
You can use https://github.com/blueimp/jQuery-File-Upload.

You can use a view function similar to following. Here I have 3 models
- Project, Album and Flat

A Project can have multiple albums.
An Album can have multiple Flats
A Flat has an ImageField, caption as TextField and a ForeignKey to Album.

def upload_flat(request, project_slug, album_pk):
project = get_object_or_404(Project, slug=project_slug)
album = get_object_or_404(Album, pk=album_pk)
if request.method == 'GET':
flats = album.flat_set.all()
return render(request, "upload.html", {"project": project,
"album": album, "flats": flats})

if request.method == "POST":
form = FlatForm(request.POST, request.FILES)
if form.is_valid():
flat = form.save(commit=False)
flat.user = request.user
flat.album = album
flat.save()

data = {
"files":
[{
"url": flat.image.url,
"thumbnail_url": flat.thumbnail.url,
"name": flat.image.name,
"type": "image/jpeg",
"size": flat.image.size,
"delete_url": reverse("delete_flat", args=[flat.pk]),
"delete_type": "DELETE",
"description": flat.description
}]
}
return HttpResponse(simplejson.dumps(data))
return render(request, "upload.html", {})

--
Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 1:22 AM, Mengu <whalb...@gmail.com> wrote:
> i used jquery.form plugin back in the day. it worked great but it had
> issues with large files.
>
> check out http://malsup.com/jquery/form/progress3.html and
> http://malsup.com/jquery/form/
>
> On Jan 22, 6:05 pm, Andre Lopes <lopes80an...@gmail.com> wrote:
>> Hi,
>>
>> I need to develop a form to upload multiple files.
>>
>> I was thinking in using an Ajax uploader. I have google some options
>> but there are to many and I don't know which one to choose.
>>
>> Any recommendations about this subject?
>>
>> Best Regards,
>> André.
>
> --
> 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-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
So, you have a custom model like following

class MyModel(models.Model):
...
content_type = models.ForeignKey(ContentType)
...

And you want to run a query on MyModel which should return objects
from various apps related to currently logged in User.

Is this what you want to achieve?

Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 3:29 PM, Sarfraz ahmad <sarfrazdja...@gmail.com> wrote:
> thanx buddy bt i wish to do it in a manner that a model which has a foreign
> key to ContentType, when i make a query on this model it returns all the
> objects from various apps related to current logged in user
>
>
>
>
> On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>>
>> Hey Sarfraz,
>>
>> If you have an user object, then you can get all related objects using
>> following code
>>
>> user = User.objects.get(username="psjinx")
>>
>> related_links = [rel.get_accessor_name() for rel in
>> user._meta.get_all_related_objects()]
>>
>> ## above code will give a list of attribute names for each related
>> object to an user
>> ## e.g. ['logentry_set', 'api_key', 'userprofile_set',
>> 'recipient_set', 'customer']
>>
>> Now you can iterate over this list
>>
>> for link in related_links:
>> objects = getattr(user, link).all()
>> for object in objects:
>> ## do something with object
>>
>> FYI, getattr(user, link) is manager for that relate object.
>>
>>
>> Pankaj Singh
>> http://about.me/psjinx
>>
>>
>> On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>> > Hey Sarfraz,
>> >
>> > You can use any of following methods:
>> >
>> > User._meta.get_all_related_m2m_objects_with_model()
>> > User._meta.get_all_related_objects()
>> > User._meta.get_all_related_many_to_many_objects()
>> > User._meta.get_all_related_objects_with_model()
>> >
>> > get_all_related_objects() is the one I guess you may want to use in your
>> > case.
>> >
>> > Pankaj Singh
>> > http://about.me/psjinx
>> >
>> >
>> > On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad <sarfrazdja...@gmail.com>
>> > wrote:
>> >> hello friends
>> >>   i have a project with 7 applications installed in it
>> >> and i
>> >> want to get all the objects related to a particular user from all the
>> >> applications of ma project. please tell me how can i get all
>> >> these
>> >> objects using ContentType framework
>> >>
>> >>
>> >> thank you all
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To view this discussion on the web visit
>> >> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> 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-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> 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-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
Hey Sarfraz,

If you have an user object, then you can get all related objects using
following code

user = User.objects.get(username="psjinx")

related_links = [rel.get_accessor_name() for rel in
user._meta.get_all_related_objects()]

## above code will give a list of attribute names for each related
object to an user
## e.g. ['logentry_set', 'api_key', 'userprofile_set',
'recipient_set', 'customer']

Now you can iterate over this list

for link in related_links:
objects = getattr(user, link).all()
for object in objects:
## do something with object

FYI, getattr(user, link) is manager for that relate object.


Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 2:42 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
> Hey Sarfraz,
>
> You can use any of following methods:
>
> User._meta.get_all_related_m2m_objects_with_model()
> User._meta.get_all_related_objects()
> User._meta.get_all_related_many_to_many_objects()
> User._meta.get_all_related_objects_with_model()
>
> get_all_related_objects() is the one I guess you may want to use in your case.
>
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad <sarfrazdja...@gmail.com> 
> wrote:
>> hello friends
>>   i have a project with 7 applications installed in it and i
>> want to get all the objects related to a particular user from all the
>> applications of ma project. please tell me how can i get all these
>> objects using ContentType framework
>>
>>
>> thank you all
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to get all objects related to a particular user using django ContentType Framework

2013-01-23 Thread Pankaj Singh
Hey Sarfraz,

You can use any of following methods:

User._meta.get_all_related_m2m_objects_with_model()
User._meta.get_all_related_objects()
User._meta.get_all_related_many_to_many_objects()
User._meta.get_all_related_objects_with_model()

get_all_related_objects() is the one I guess you may want to use in your case.

Pankaj Singh
http://about.me/psjinx


On Wed, Jan 23, 2013 at 2:30 PM, Sarfraz ahmad <sarfrazdja...@gmail.com> wrote:
> hello friends
>   i have a project with 7 applications installed in it and i
> want to get all the objects related to a particular user from all the
> applications of ma project. please tell me how can i get all these
> objects using ContentType framework
>
>
> thank you all
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/tKRQQKC06BsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: looking for an app to view various github repositories within a django powered site

2013-01-21 Thread Pankaj Singh
Hi,

I could not any recent work similar to what you have described.

Charles Leifer tried to do some django+github[1] integration and his
work is available on github[2].

There are good implementations of Github Oauth as you can see it in
django-social-auth[3] and django-allauth[4].

There are many python libraries, e.g. github3.py[5],for Github
Developer API[6]. You can use any of these inside your django app.

You might be interested in django-git[7] as well. It's a gitweb
replacement written in Django.

Links
1. http://charlesleifer.com/blog/simple-integration-github-django-github/
2. https://github.com/frozenskys/django-github
3. https://github.com/omab/django-social-auth
4. https://github.com/pennersr/django-allauth
5. https://github.com/sigmavirus24/github3.py
6. http://developer.github.com/v3/libraries/#python
7. https://github.com/sethtrain/django-git

Pankaj Singh
http://about.me/psjinx


On Mon, Jan 21, 2013 at 10:29 PM, garagefan <monkeygar...@gmail.com> wrote:
> I'm looking to build a website to collaborate on some open source projects.
> I'd like to set up discussions based on git repositories, and maybe even
> allow folks to contribute/fork/submit issues, etc.
>
> I could handle this on my own, but its more of a side fun project for myself
> and I'd rather see if there is something already completed, or mostly
> completed.
>
> thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/oXLGdJjhi8EJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How do I prevent delete from table that has foreign key references

2013-01-20 Thread Pankaj Singh
> s/PREVENT/PROTECT/

My mistake.

Pankaj Singh
http://about.me/psjinx


On Mon, Jan 21, 2013 at 8:08 AM, Javier Guerra Giraldez
<jav...@guerrag.com> wrote:
> On Sun, Jan 20, 2013 at 2:21 PM, Pankaj Singh <ps.j...@gmail.com> wrote:
>> As per docs, on_delete=models.PREVENT, prevents deletion of the
>> referenced object by raising ProtectedError, a subclass of
>> django.db.IntegrityError.
>
>
> s/PREVENT/PROTECT/
>
> --
> Javier
>
> --
> 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-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How do I prevent delete from table that has foreign key references

2013-01-20 Thread Pankaj Singh
Hey Subodh,

If I your problem understood correctly, then `on_delete` option
available in ForeingKey field[1] should be helpful in this case.

As per docs, on_delete=models.PREVENT, prevents deletion of the
referenced object by raising ProtectedError, a subclass of
django.db.IntegrityError.

Links:
[1]: 
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete

Pankaj Singh
http://about.me/psjinx


On Mon, Jan 21, 2013 at 12:42 AM, Subodh Nijsure
<subodh.nijs...@gmail.com> wrote:
> Hi,
>
> Say I have model that comprises of Books and Authors. Where a book may have
> multiple authors and this has foreignkey in the books table.
>
> Now how do I prevent deletion of an author record while the there is record
> in books table that has pointer an author record (via foreign key).
>
> Do i need to do this via stored procedure/trigger on DB level or is there
> standard procedure to implement this in delete in django?
>
> Would appreciate any pointers.
>
> Regards,
> -Subodh
>
> --
> 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-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django 1.5 custom User model error. "Manager isn't available; User has been swapped"

2012-11-27 Thread Pankaj Singh
Hi,

You need to unregister `User` model from admin site before registering new one.

admin.site.unregister(User)
admin.site.register(CustomUser, UserAdmin)

Please have a look at http://stackoverflow.com/a/2270704/353550

Pankaj Singh
http://about.me/psjinx


On Mon, Nov 26, 2012 at 9:14 PM, Benoit Petit
<benoit.petit.i...@gmail.com> wrote:
> Hi,
>
> I extend the django user model as described in the dev doc. I wan't to keep
> most of the original User model features so I extend the AbstractUser class.
> I've defined in settings.py:
>
> AUTH_USER_MODEL = 'myapp.CustomUser'
>
> My user class:
>
> class CustomUser(AbstractUser):
>   custom_field = models.ForeignKey('OtherModel')
>   objects = UserManager()
>
> Everything seems to work fine but when I try to make it managed by the admin
> site:
>
> admin.site.register(CustomUser, UserAdmin)
>
> I get this error on the admin CustomUser creation page (after validation of
> the password confirmation form):
>
> AttributeError: Manager isn't available; User has been swapped for
> 'myapp.CustomUser'
>
> The point is that I need this model managed by the admin site in order to
> have the same creation process as with the original User model (two step
> process with password validation).
>
> Thanks for any reply
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/8VtQghtcMFgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Javascript in external file not working

2012-11-26 Thread Pankaj Singh
On Tue, Nov 27, 2012 at 4:34 AM, Loai Ghoraba  wrote:
> Hi all
>
> When I have a script like this:
>  window.onload=function f(){}  it is working fine. but when
> I create an external js file and put it within the static directory, and
> call the function like this
> 
>  window.onload=f 
>
> It is not working at all. (by the way the url is mapped correctly to the js
> file "I tested it via viewing the source of the web page")
>
> Any idea?

This appears to be a javascript issue, because your code should only
fail if window.load is fired before f is defined.

But you say that, url for js file works. Please use Firebug addon in
Firefox to see javascript errors.

-- Pankaj

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: imagefield problem .....

2011-06-13 Thread Pankaj Singh
yes even in get_image_url it will be

return os.path.join(settings.MEDIA_URL, 'news', 
self.image.name.split('/')[-1])

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/JBSPTQLVtWcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: __init__() got an unexpected keyword argument 'core'

2010-08-20 Thread Pankaj Singh
I am using django 1.2.1


-- 
-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
3rd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur
Website - http://www.IamPankaj.in 
Email - cont...@iampankaj.in , singh.pankaj.iitkg...@gmail.com
Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



__init__() got an unexpected keyword argument 'core'

2010-08-20 Thread Pankaj Singh
I am gettign this error but as per documentation
http://www.djangoproject.com/documentation/0.96/model-api/#core this should
not be a problem

http://code.google.com/p/django-openid-auth/source/browse/trunk/openid_auth/models.py

pan...@pankaj-laptop:~/django_projects/mysite$ ./manage.py syncdb
Traceback (most recent call last):
  File "./manage.py", line 13, in 
execute_manager(settings)
  File
"/home/pankaj/django_projects/mysite/django/core/management/__init__.py",
line 438, in execute_manager
utility.execute()
  File
"/home/pankaj/django_projects/mysite/django/core/management/__init__.py",
line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
line 217, in execute
self.validate()
  File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
line 245, in validate
num_errors = get_validation_errors(s, app)
  File
"/home/pankaj/django_projects/mysite/django/core/management/validation.py",
line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
line 146, in get_app_errors
self._populate()
  File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
line 61, in _populate
self.load_app(app_name, True)
  File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
line 78, in load_app
models = import_module('.models', app_name)
  File "/home/pankaj/django_projects/mysite/django/utils/importlib.py", line
35, in import_module
__import__(name)
  File "/home/pankaj/django_projects/mysite/openid_auth/models.py", line 10,
in 
class UserOpenID(models.Model):
  File "/home/pankaj/django_projects/mysite/openid_auth/models.py", line 14,
in UserOpenID
user = models.ForeignKey(User, core=True, related_name="openids")
  File
"/home/pankaj/django_projects/mysite/django/db/models/fields/related.py",
line 820, in __init__
Field.__init__(self, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'core'


-- 
-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
3rd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur
Website - http://www.IamPankaj.in 
Email - cont...@iampankaj.in , singh.pankaj.iitkg...@gmail.com
Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Value Error in Pyfacebook

2010-08-07 Thread Pankaj Singh
problem got solved

1292 if params.get('expires'):
1293 self.session_key_expires = int(params['expires'])

I've just changed it to:

1292 if params.get('expires'):
1293 try:
1294 self.session_key_expires = int(params['expires'])
1295 except ValueError:
1296 pass

It works this way, but it must be fixed in pyFacebook next version.

this is the solution

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Value Error in Pyfacebook

2010-08-07 Thread Pankaj Singh
Hi i m getting this error

***
Traceback (most recent call last):

 File "/usr/local/alwaysdata/python/
django/1.2.1/django/core/handlers/base.py", line 100, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File
"/usr/local/alwaysdata/python/django/1.2.1/django/utils/decorators.py", line
76, in _wrapped_view
   response = view_func(request, *args, **kwargs)

 File "", line 1, in 

 File "/home/pankajsingh/company_site/fbapp/facebook/djangofb/__init__.py",
line 94, in newview
   return view(request, *args, **kwargs)

 File "/home/pankajsingh/company_site/fbapp/views.py", line 23, in canvas
   user = User.objects.get_current()

 File "/home/pankajsingh/company_site/fbapp/models.py", line 13, in
get_current
   user, created = self.get_or_create(id=int(facebook.uid))

ValueError: invalid literal for int() with base 10: 'None'
***

need help to get out of this


-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
3rd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur

Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-registration custom fields

2010-05-31 Thread Pankaj Singh
Thanks my problem has been resolved :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-registration custom fields

2010-05-31 Thread Pankaj Singh
I am using django-profiles with django-registration as per tutorial from

http://praveensunsetpoint.wordpress.com/2009/04/21/django-registration-and-django-profile

But after the submitting the form I am getting this error

AttributeError at /accounts/register/

'RegistrationForm' object has no attribute 'save'

Please help me

#

def register(request,
success_url=None,form_class=RegistrationFormUniqueEmail,
profile_callback=None,
template_name='registration/registration_form.html',
extra_context=None):
pform_class = utils.get_profile_form()


if request.method == 'POST':
profileform = pform_class(data=request.POST, files=request.FILES)
form = form_class(data=request.POST, files=request.FILES)

if form.is_valid():
new_user = form.save()
profile_obj = profileform.save(commit=False)
profile_obj.user = new_user
profile_obj.save()

return HttpResponseRedirect('/accounts/register/complete/')

else:
form = form_class()
profileform = pform_class()

if extra_context is None:
extra_context = {}
context = RequestContext(request)

for key, value in extra_context.items():
context[key] = callable(value) and value() or value

return render_to_response(template_name,{'form':
form,'profileform':profileform,}, context_instance=context)



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-registration custom fields

2010-05-29 Thread Pankaj Singh
I tried extending RegistrationFormUniqueEmail

class CustomRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
first_name = forms.CharField(label=_('First name'),
max_length=30,required=True)
last_name = forms.CharField(label=_('Last name'), max_length=30,
required=True)
def save(self, profile_callback=None):
new_user = super(CustomRegistrationFormUniqueEmail,
self).save(profile_callback=profile_callback)
new_user.first_name = self.cleaned_data['first_name']
new_user.last_name = self.cleaned_data['last_name']
return new_user

then changing view

#   form = form_class(data=request.POST, files=request.FILES)
form = CustomRegistrationFormUniqueEmail(data=request.POST,
files=request.FILES)

but still I am seeing default view containg four fields only ..

help is needed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-registration custom fields

2010-05-29 Thread Pankaj Singh
Hi
I want to extend django-registration form by adding fields like

first name
last name
date of birth
country
languages you speak etc.

for my project ..

how should i proceed for this ..

-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
2nd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur

Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



password reset getting error - 'function' object is not iterable

2010-05-27 Thread Pankaj Singh
I am getting this error while accessing password reset page.I want to use
custom template for password reset page instead of standard django page.
how should I proceed.
**
TypeError at /accounts/password/reset/

'function' object is not iterable

 Request Method: GET  Request URL:
http://10.115.4.34:1234/accounts/password/reset/  Exception Type:
TypeError  Exception
Value:

'function' object is not iterable

 Exception Location: /usr/lib/pymodules/python2.6/django/core/urlresolvers.py
in resolve, line 123  Python Executable: /usr/bin/python  Python Version:
2.6.5
**
-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
2nd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur

Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Error was: cannot import name validators

2010-05-18 Thread Pankaj Singh
pan...@pankaj-laptop:~/django_projects/pankaj$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core import validators

Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name validators
>>>

*Validators is really missing .. don't know how to install .. help needed*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Error was: cannot import name validators

2010-05-17 Thread Pankaj Singh
I am getting this error .. did a lot of googe search but not able to find a
solution .. help please

ViewDoesNotExist at /register/

Could not import user_registration.views. Error was: cannot import
name validators

 Request Method: GET  Request URL: http://127.0.0.1:/register/  Exception
Type: ViewDoesNotExist  Exception Value:

Could not import user_registration.views. Error was: cannot import
name validators

 Exception Location: /usr/lib/pymodules/python2.6/django/core/urlresolvers.py
in _get_callback, line 134  Python Executable: /usr/bin/python

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Error: App with label forum could not be found. Are you sure your INSTALLED_APPS setting is correct?

2010-05-16 Thread Pankaj Singh
I am geetting thi error when using

./manage.py sqlall forum

On Sun, May 16, 2010 at 11:16 PM, Felippe Bueno <felippe.bu...@gmail.com>wrote:

> when are you getting this error ?
>
> On Sun, May 16, 2010 at 5:38 PM, Pankaj Singh <
> singh.pankaj.iitkg...@gmail.com> wrote:
>
>> Error: App with label forum could not be found. Are you sure your
>> INSTALLED_APPS setting is correct?
>>
>> how to get out of this ?
>>
>>
>> --
>> --
>> --
>> Thanking You,
>>
>> Pankaj Kumar Singh,
>> 2nd Year Undergraduate Student,
>> Department of Agricultural and Food Engineering,
>> Indian Institute of Technology,
>> Kharagpur
>>
>> Mobile - (+91) 8001231685
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
2nd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur

Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Error: App with label forum could not be found. Are you sure your INSTALLED_APPS setting is correct?

2010-05-16 Thread Pankaj Singh
Error: App with label forum could not be found. Are you sure your
INSTALLED_APPS setting is correct?

how to get out of this ?


-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
2nd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur

Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Not able to resolve this error

2010-04-15 Thread Pankaj Singh
Thanx

Problem resolved :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Not able to resolve this error

2010-04-15 Thread Pankaj Singh
 Page not found (404)  Request Method: GET  Request URL:
http://10.115.4.61:1234/weblog/2010/apr/14/how-it-functions/

Using the URLconf defined in django_project.urls, Django tried these URL
patterns, in this order:

   1. ^admin/
   2. ^weblog/$
   3.
   ^weblog/(?P\d{4})/(?P\w{3})/(?P\d{2})/(P?[-\w]+)/$

The current URL, weblog/2010/apr/14/how-it-functions/, didn't match any of
these.

You're seeing this error because you have DEBUG = True in your Django
settings file. Change that to False, and Django will display a standard 404
page.



please help
-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
2nd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur

Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: invalid literal for int() with base 10

2010-04-13 Thread Pankaj Singh
ok

i resolved ..

primary key was the problem

i was using name as pk instead of id

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



invalid literal for int() with base 10

2010-04-13 Thread Pankaj Singh
*I am unable to resolve this issue .. please help me*


ValueError at /pages/About/
invalid literal for int() with base 10: 'About'
Request Method: GET
Request URL: http://localhost:8000/pages/About/
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: 'About'
Exception Location:
/usr/lib/pymodules/python2.6/django/db/models/fields/__init__.py in
get_db_prep_value, line 361
Python Executable: /usr/bin/python
Python Version: 2.6.5
Python Path: ['/home/pankaj/bio_envision',
'/usr/local/lib/python2.6/dist-packages/html5lib-0.90-py2.6.egg',
'/usr/local/lib/python2.6/dist-packages/django_page_cms-1.1.2-py2.6.egg',
'/usr/local/lib/python2.6/dist-packages/django_staticfiles-0.2.0-py2.6.egg',
'/usr/local/lib/python2.6/dist-packages/django_authority-0.4-py2.6.egg',
'/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2',
'/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old',
'/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages/PIL',
'/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6',
'/usr/lib/python2.6/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.6/gtk-2.0',
'/usr/local/lib/python2.6/dist-packages']
Server time: Tue, 13 Apr 2010 21:33:23 -0500


*views.py*

# Create your views here.

from bio_envision.website.models import *
from django.shortcuts import *
from django.http import *
from django.template import *

def index(request):
pages = Page.objects.all()
return render_to_response('index.html', {'pages': pages},
context_instance=RequestContext(request))

def view_page(request, page_name):
try:
page = Page.objects.get(pk=page_name)
except Page.DoesNotExist:
return render_to_response("invalid_page.html")
content = page.content
pages = Page.objects.all()
return render_to_response("view.html",{"page_name" : page_name, "content" :
content, 'pages': pages,})
---
*urls.py*
---
from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root), #Lets us access the admin page
(r'^$', 'bio_envision.website.views.index'),
(r'^pages/(?P[^/]+)/$', 'bio_envision.website.views.view_page'),
(r'^stylesheets/(?P.*)$',
'django.views.static.serve',{'document_root':
'/home/pankaj/bio_envision/website/templates/stylesheets/'}),


)
--



-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
2nd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur

Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CMS based Website using Django

2010-04-09 Thread Pankaj Singh
Getting error during installation  please help

Installed
/usr/local/lib/python2.6/dist-packages/django_page_cms-1.1.2-py2.6.egg
Processing dependencies for django-page-cms==1.1.2
Searching for django-mptt>0.2.1
Reading http://pypi.python.org/simple/django-mptt/
Reading http://code.google.com/p/django-mptt/
No local packages or download links found for django-mptt>0.2.1
error: Could not find suitable distribution for
Requirement.parse('django-mptt>0.2.1')



thanks
Pankaj

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



CMS based Website using Django

2010-04-09 Thread Pankaj Singh
Hi, I am a student. I have designed CMS websites using PHP and MySQL . I
want to complete my new project using Django ( excited about it).
I wanted to know the basic steps that I should follow. I need to do design a
website for a new startup at IIT Kharagpur. I will use CMS because that
person ( for whom I will be working) does not know web designing.
I have read Django Tutorials from Internet.

-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
2nd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur

Mobile - (+91) 8001231685

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.