Re: Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-08 Thread Oleg Lomaka
You have started from the beginning. Take a look at my very first reply in
this thread. Remove 'areacode' and 'number' fields from your MemberAdmin.
Let them be available from PhoneInline and AddressInline. You will be see
them on the same admin page, just in other visual block where inline forms
display.

Sure, if you don't like such things, you are always up to extend admin
template for exactly this view and output anything you like.

On Sun, May 8, 2011 at 7:19 AM, Eiji Kobayashi wrote:

> Hi Oleg,
>
> Thanks for your patience. I'm pretty sure I DID miss something like
> you said. Here's my admin.py, with the modifications you suggested:
>
> # admin.py
> from django.contrib import admin
> from django.contrib.auth.models import User
> from models import Member, Address, Phone
>
> class PhoneInline(admin.StackedInline):
>  model = Phone
>  can_delete = True
>  extra = 0
>   fields = ( 'areacode', 'number')
>
> class AddressInline(admin.StackedInline):
>  model = Address
>  can_delete = True
>  extra = 0
>   fields = ( 'addresstype', 'address', 'city', 'state', 'postal_code')
>
> class MemberAdmin(admin.ModelAdmin):
>  inlines = [ PhoneInline, AddressInline ]
>  fieldsets = (
>(None, {
>'fields': ( 'first_name', 'middle_name', 'last_name',
> 'areacode', 'number' )
>})
>)
>
> admin.site.register(Member, MemberAdmin)
>
> The actual error I get is:
>
> ImproperlyConfigured at /admin/
> 'MemberAdmin.fieldsets[0][1]['fields']' refers to field 'areacode'
> that is missing from the form.
>
> When I add the all_phones function in the models.py and define the
> list_display like you suggested, I get this error:
>
> TemplateSyntaxError at /admin/account/member/
> Caught OperationalError while rendering: (1054, "Unknown column
> 'account_phone.areacode' in 'field list'")
>
> There must be a simpler way to just edit the primary model and its
> related models in the admin, no?
> Thanks!
>
> Eiji
>
>
>
>

-- 
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: Loading project to alwaysdata

2011-05-08 Thread werefrog

Hello,

Does this help you?  http://wiki.alwaysdata.com/wiki/Deploying_a_Django_App

Regards

--
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 Bigener

2011-05-08 Thread Anish Chapagain
Hi there,

do find the ebook "sama django in 24 hr" this is what i have gone through,
it looks simple and easy..then you can move to ecommerce platform.

for any help,work be in touch.

regard's
anish

On Sun, May 8, 2011 at 12:58 AM, hersh  wrote:

> Hi to all,
>
> I am new. I want to apply Django to develop an E-commerce project. I
> am looking for a good reference to start. I 'd like to add that I have
> to do the project in less than one month. I need a quick reference to
> understand the basics of Django and start my project. If there are
> some sample project it could be really helpful. Let describe myself: I
> am quit familiar with programming. I have done lots of programming in
> C/C++. But I am beginner in Python and have heard of Django yesterday.
>
> Please guide me and help me find the way. If you have any TUTORIALS
> and REFERENCES
>
> Thanks in advance
> / Rahim
>
> --
> 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.
>
>


-- 
With Regard's
--
Anish Chapagain
67, Evesham Road
Stratford
E15 4AL
London
Mob:07826009563
E-mail: anishchapag...@gmail.com
http://www.pussycatlondon.com
http://www.mysticnepal.com
http://www.nepaliworld.net

-- 
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.



Django on FreeHostingCloud.com

2011-05-08 Thread Ryan Osborn
I recently came across FreeHostingCloud.com and wanted to see if it is 
possible to deploy django on it since it provides unlimited bandwidth, disk 
space and databases and also allows the use of python through fastcgi.

I have been following the guide in the documentation here:
http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache

I have uploaded the following .htaccess file to the public_html folder:

AddHandler fastcgi-script .fcgiRewriteEngine OnRewriteCond %{REQUEST_FILENAME} 
!-fRewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]

and then created the following mysite.fcgi file, also in the public_html folder 
and gave it 755 permissions in order to make it executable:

import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home//python/")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

I then uploaded django, flup and my project "mysite" to the python folder 
mentioned in the mysite.fcgi so that they should be on the python path.  
However, whenever I try to access the page, it always just shows the contents 
of the mysite.fcgi file instead of the django page.

I was wondering if anyone had any experience in using django on 
FreeHostingCloud or if anyone could spot anything I may have overlooked.

Thanks,

Ryan 

-- 
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: Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-08 Thread Eiji Kobayashi
On Sun, May 8, 2011 at 12:00 AM, Oleg Lomaka  wrote:

> You have started from the beginning. Take a look at my very first reply in
> this thread. Remove 'areacode' and 'number' fields from your MemberAdmin.
> Let them be available from PhoneInline and AddressInline. You will be see
> them on the same admin page, just in other visual block where inline forms
> display.
>
> Sure, if you don't like such things, you are always up to extend admin
> template for exactly this view and output anything you like.
>
>
>
Yes, maybe that'll be a good way to learn to grasp the concept of django.
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.



using reverse to find the index-page of an app?

2011-05-08 Thread Thomas Weholt
I've read 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-admin-urls,
but cannot for the life of me find a way to use reverse to get the url
of the index page for my app.

Say my app is called "polls" ( for some strange reason ) and I want to
redirect to the app_index for that app, using:

def someview(request):
return redirect(reverse('admin:polls_index'))

doesn't work. I want to redirect to the page you get to when clicking
on the app-header in the index of the admin, not one of the models.

This is probably easy as pie, but I'm not getting it. Sorry.

-- 
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 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.



Instantiate a model using a string (or a dict)??

2011-05-08 Thread Eiji Kobayashi
Hi!

Sorry. Another question, please.

Is it possible to create a model instance using a string parameter?

Example, I would like to be able to do something like:

param = "username='admin', email='x...@xyz.com', password='xyz123'"
new_user = User(param)

Of course this won't work. But is there a similar method? I don't want to
hard type every single fieldname (and the corresponding value) for every
field I'd like to have when instantiating a record for a model.

Anyone?

Eiji

-- 
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: Instantiate a model using a string (or a dict)??

2011-05-08 Thread Shawn Milochik

You can do it with a dictionary. Just pass it using **kwargs.

--
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.



Djangodomain hosting

2011-05-08 Thread Daniel de la Cuesta
Hi,

Any body is using DjangoDomain hosting?

Their servers are down since yesterday and they don't responde to any
support ticket.

Any idea?

Thank you.

-- 
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.



book count per author for filtered book list

2011-05-08 Thread Владислав Максимов
 

Hi! Short question. I have two models:

class Author(models.Model):
name = models.CharField(max_length=250)

class Book(models.Model):
title = models.CharField(max_length=250)
author = models.ManyToManyField(Author)

One view:

def filter_books(request):
book_list = Book.objects.filter(...)

How can I display in template next content:

Authors in selected books:
Author1: book_count
Author2: book_count
...


http://stackoverflow.com/q/5927251/604789

-- 
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: using reverse to find the index-page of an app?

2011-05-08 Thread Karen Tracey
On Sun, May 8, 2011 at 6:42 AM, Thomas Weholt wrote:

> I've read
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-admin-urls
> ,
> but cannot for the life of me find a way to use reverse to get the url
> of the index page for my app.
>
>
The index page for an app has the url name 'app_list' with argument app
name, for example:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.urlresolvers import reverse
>>> reverse('admin:app_list', args=('polls',))
'/admin/polls/'
>>>

Karen
-- 
http://tracey.org/kmt/

-- 
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: my models are remembering old fields that I have since deleted

2011-05-08 Thread Leo
I know this probably seems like an orthogonal answer to your question,
and also that you're just trying to get something going quickly, but
it's really worth setting up South (http://south.aeracode.org/) for
any meaningful Django project.

Unfortunately, after the fact South can't help you with your current
problem, but using South will make it so that going forward your
database changes can be applied and rolled back along with your code
changes.

Googling a little for "Django migrations" or "Django South migrations"
will let you understand what South does and why having code-based
migrations can really relieve stress!

P.S.  For your problem-of-the-moment, if you're using MySQL and can
find the tool "MySQL Adminstrator" it's trivial to delete the columns
manually.  If you're using another SQL database you can probably find
a similar tool or do this at the SQL command prompt.  However, as the
other responders said, it's safer to drop and recreate the table... or
to use South.

-- 
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: Makemessages Multiline

2011-05-08 Thread momo2k
Well, dos2unix solved

-- 
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: UML to Django - online generation service

2011-05-08 Thread gusheng
yeah...that's useful
and...thx :)

On 5月8日, 上午2时50分, Javier Guerra Giraldez  wrote:
> On Sat, May 7, 2011 at 11:21 AM, Juan Hernandez  wrote:
> > django-extensions does something similar
>
> second that
>
> typically i start developing an app by drafting the models.  i keep a
> window with the output of django-extensions updated automatically
> every time i save.  makes it so easy to keep the big picture on sight
>
> of course, it's not UML
>
> --
> 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.



Re: Loading project to alwaysdata

2011-05-08 Thread ruler501
I do not understand how ssh works or how to use it. Like I said I
don't know much more than the code

On May 8, 3:39 am, werefrog  wrote:
> Hello,
>
> Does this help you?  http://wiki.alwaysdata.com/wiki/Deploying_a_Django_App
>
> Regards

-- 
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: Loading project to alwaysdata

2011-05-08 Thread ruler501
I do not understand how ssh works or how to use it. Like I said I
don't know much more than the code

On May 8, 3:39 am, werefrog  wrote:
> Hello,
>
> Does this help you?  http://wiki.alwaysdata.com/wiki/Deploying_a_Django_App
>
> Regards

-- 
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: ajax select box

2011-05-08 Thread pankaj sharma
but i dont know about jquery or ajax, can i get any example from any
site , can u provide any link which has such code written

On May 7, 12:10 pm, Shawn Milochik  wrote:
> You'll need to write JavaScript.
>
> Specifically:
>
>      Write a function that uses AJAX to pass the state to a Django view
> and receive the city list, then populate the city drop-down.
>
>      Bind that function to the change event of your state drop-down box.
>
> This isn't a Django question, though. If you have trouble doing that try
> a JavaScript mailing list.
>
> I recommend using jQuery's .ajax() function for this.
>
> Shawn

-- 
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.



filter in python

2011-05-08 Thread pankaj sharma
hello ..


i am having a database of college  which have a name city state
branches etc...
so

class College(models.Model):

   name = models.CharField(max_length=250)

   city = models.ForeignKey(City)

   branch1 = models.BooleanField(default=False, blank=True)
   branch2 = models.BooleanField(default=False, blank=True)
   branch3 = models.BooleanField(default=False, blank=True)
   branch4 = models.BooleanField(default=False, blank=True)


now i want to provide user that they can search colleges from
branches..
so i am giving them a select box where they can select the city and
branches
suppose i get two queries Qcity and Qbranch
so i will filter all the colleges having city = Qcity and
Branches=Qbranch
so please tell me how to filter

i have filtered city but how to add one another filter for branch {as
it is bolleanfield}
college_list = College.objects.filter(city__title__icontains=Qcity)

-- 
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: Djangodomain hosting

2011-05-08 Thread creecode
Hello Daniel,

Sorry no.  But I can confirm that the domain (website at least) appears to 
be down.

Toodle-l..
creecode

-- 
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: book count per author for filtered book list

2011-05-08 Thread Oleg Lomaka
I would do this via intermediate model,

class Author(models.Model):
name = models.CharField(max_length=250)
class Book(models.Model):
title = models.CharField(max_length=250)
author = models.ManyToManyField(Author, through="BookAuthor")
class BookAuthor(models.Model):
author = models.ForeignKey(Author)
book = models.ForeignKey(Book)

def filter_books(request):
book_list = Book.objects.filter(...)


BookAuthor.objects.filter(book__in=book_list).values('author').annotate(books_num=models.Count('author'))

You'll get a list of dicts with authors' PKs and book_num int.






On Sun, May 8, 2011 at 4:37 PM, Владислав Максимов
wrote:

> Hi! Short question. I have two models:
>
> class Author(models.Model):
> name = models.CharField(max_length=250)
>
> class Book(models.Model):
> title = models.CharField(max_length=250)
> author = models.ManyToManyField(Author)
>
> One view:
>
> def filter_books(request):
> book_list = Book.objects.filter(...)
>
> How can I display in template next content:
>
> Authors in selected books:
> Author1: book_count
> Author2: book_count
> ...
>
>
> http://stackoverflow.com/q/5927251/604789
>
> --
> 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: Instantiate a model using a string (or a dict)??

2011-05-08 Thread Oleg Lomaka
To extend Shawn's answer on your example :)

params = {'username': 'admin', 'email': 'x...@xyz.com', 'password': 'xyz123'}
# then
new_user = User(**params)
new_user.save()
# or
User.objects.create(**params)

On Sun, May 8, 2011 at 1:44 PM, Eiji Kobayashi wrote:

> Hi!
>
> Sorry. Another question, please.
>
> Is it possible to create a model instance using a string parameter?
>
> Example, I would like to be able to do something like:
>
> param = "username='admin', email='x...@xyz.com', password='xyz123'"
> new_user = User(param)
>
> Of course this won't work. But is there a similar method? I don't want to
> hard type every single fieldname (and the corresponding value) for every
> field I'd like to have when instantiating a record for a model.
>
> Anyone?
>
> Eiji
>
> --
> 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: filter in python

2011-05-08 Thread Amanjeev Sethi
Is it possible for you to use Django Haystack for search?

http://haystacksearch.org/

-- 
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: Djangodomain hosting

2011-05-08 Thread Amanjeev Sethi
On Sun, May 8, 2011 at 6:55 AM, Daniel de la Cuesta wrote:

> and they don't responde to any
> support ticket.
>

Boy! that is bad. At least they should respond with something.


-- 
AJ

-- 
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: filter in python

2011-05-08 Thread pankaj sharma
can i do it without using haystak actually i just want to add one more
filter ..

On May 8, 11:18 am, Amanjeev Sethi  wrote:
> Is it possible for you to use Django Haystack for search?
>
> http://haystacksearch.org/

-- 
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: ajax select box

2011-05-08 Thread Ogi Vranesic
Hallo 

You can use Dajax(ice) to solve your issue.
First Dajax and Dajaxice must be installed.
In your select box for countries add event 'onchange' i.e.:
onchange="Dajaxice.ajax.getCitiesByCountry('Dajax.process', {'name':this.name, 
'value':this.value})">
According to this example you must have the file ajax.py and the function 
getCitiesByCountry must be registered in settings.py like:
DAJAXICE_FUNCTIONS = (
'ajax.getCitiesByCountry',
)

Afterwards define the function getCitiesByCountry in ajax module
where you can generate options for cities using python and replace them 
automatically in html.

If something is not clear google for Dajax, Dajaxice, dajax.json()

Greetings
Ogi

On Sonntag 08 Mai 2011 06:46:54 pm you wrote:
> but i dont know about jquery or ajax, can i get any example from any
> site , can u provide any link which has such code written
> 
> On May 7, 12:10 pm, Shawn Milochik  wrote:
> > You'll need to write JavaScript.
> >
> > Specifically:
> >
> >  Write a function that uses AJAX to pass the state to a Django view
> > and receive the city list, then populate the city drop-down.
> >
> >  Bind that function to the change event of your state drop-down box.
> >
> > This isn't a Django question, though. If you have trouble doing that try
> > a JavaScript mailing list.
> >
> > I recommend using jQuery's .ajax() function for this.
> >
> > Shawn
> 

-- 
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.



Inserting csrf-token in a form generated by a templatetag?

2011-05-08 Thread Thomas Weholt
I've got a templatetag generating a form, but trying to add a
csrf-token failes. What's the correct way to add a csrf-token to a
form generated in plain html in a templatetag?

-- 
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 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.



curl pages behind login_required

2011-05-08 Thread CarlFK
I am trying to curl pages that require being logged in via django's
default auth.  I don't care if the actual login is done with curl,
python, firefox or whatever is easiest.

This only works sometimes, so I am missing something:

install https://addons.mozilla.org/en-us/firefox/addon/export-cookies/
./manage.py runserver
browse FF to http://localhost:8080/admin/
log in
FF tools/export cookies/cookeis.txt
$ grep localhost cookies.txt
localhost   FALSE   /   FALSE   1306094671  sessionid
754305fdac240f1ab68371b1f860eaa0
localhost   FALSE   /   FALSE   1336334661  csrftoken
4fa9c0c4f6cb537df8389fb63df61f3b

$ curl -s --cookie sessionid=754305fdac240f1ab68371b1f860eaa0
http://localhost:8080/admin/ | grep "Log out"
 Log out

good - you only get "Log out" if you are logged in.  So that works.

When I try it with the production site (log in, save cookes, grep
hostname use that session id...), I get the login form html, meaning
it isn't seeing me as logged in.

-- 
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.



Django filefield

2011-05-08 Thread Pulkit Mehrotra
I want to create a system by which i can upload files to my database .This 
database will be a set of question papers .These question papers can be 
downloaded by students for their own use and evaluation.How to create it 
.What is the use of django filefield.Please provide any links for it .

thank you,

-- 
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 filefield

2011-05-08 Thread pankaj sharma
http://docs.djangoproject.com/en/dev/ref/models/fields/


may be this can help u.
Regards:
Pankaj

On May 8, 1:32 pm, Pulkit Mehrotra  wrote:
> I want to create a system by which i can upload files to my database .This
> database will be a set of question papers .These question papers can be
> downloaded by students for their own use and evaluation.How to create it
> .What is the use of django filefield.Please provide any links for it .
>
> thank you,

-- 
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: curl pages behind login_required

2011-05-08 Thread Shawn Milochik
Do a Google search on using cookies in curl.
On May 8, 2011 4:17 PM, "CarlFK"  wrote:
> I am trying to curl pages that require being logged in via django's
> default auth. I don't care if the actual login is done with curl,
> python, firefox or whatever is easiest.
>
> This only works sometimes, so I am missing something:
>
> install https://addons.mozilla.org/en-us/firefox/addon/export-cookies/
> ./manage.py runserver
> browse FF to http://localhost:8080/admin/
> log in
> FF tools/export cookies/cookeis.txt
> $ grep localhost cookies.txt
> localhost FALSE / FALSE 1306094671 sessionid
> 754305fdac240f1ab68371b1f860eaa0
> localhost FALSE / FALSE 1336334661 csrftoken
> 4fa9c0c4f6cb537df8389fb63df61f3b
>
> $ curl -s --cookie sessionid=754305fdac240f1ab68371b1f860eaa0
> http://localhost:8080/admin/ | grep "Log out"
> Log out
>
> good - you only get "Log out" if you are logged in. So that works.
>
> When I try it with the production site (log in, save cookes, grep
> hostname use that session id...), I get the login form html, meaning
> it isn't seeing me as logged in.
>
> --
> 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: curl pages behind login_required

2011-05-08 Thread Shawn Milochik
And just to be clear, I wasn't saying go away. I think you can authenticate
completely in curl. If not you can in wget.

-- 
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.



Loading initial data with a post_syncdb hook?

2011-05-08 Thread Adam Seering
Hi,
I have some Python code that generates initial data for some of my 
tables; I currently call that code from a post_syncdb hook.  In Django 1.3, it 
looks like Django now calls TRUNCATE (or an equivalent non-PostgreSQL-ism) on 
all tables after running syncdb and all of its post- hooks.  I know I could use 
fixtures, but it's much more readable for us to use Python code for this 
initial data.  (The data being generated is somewhat complex and denormalized 
for various reasons that probably won't be changed just for the sake of this 
issue..., but there are nice clean simple Python functions to create each 
entry.)  Is there a good way to do so in the brave new Django 1.3 world?

Thanks,
Adam


-- 
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: curl pages behind login_required

2011-05-08 Thread Jacob Kaplan-Moss
On Sun, May 8, 2011 at 3:17 PM, CarlFK  wrote:
> I am trying to curl pages that require being logged in via django's
> default auth.  I don't care if the actual login is done with curl,
> python, firefox or whatever is easiest.

Are you wedded to curl for the download? If it were me, I'd use
something like Mechanize (http://wwwsearch.sourceforge.net/mechanize/)
which can handle logging in, storing cookies, and doing the download.

Jacob

-- 
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: Loading initial data with a post_syncdb hook?

2011-05-08 Thread Jacob Kaplan-Moss
On Sun, May 8, 2011 at 4:25 PM, Adam Seering  wrote:
> I have some Python code that generates initial data for some of my tables; I
> currently call that code from a post_syncdb hook. In Django 1.3, it looks like
> Django now calls TRUNCATE (or an equivalent non-PostgreSQL-ism) on all tables
> after running syncdb and all of its post- hooks.

That... doesn't sound right. Here's all the SQL syncdb executes (for a
simple app with one table); notice the distinct lack of any TRUNCATE
statement.

Are you perhaps talking about doing this during testing? If so, you're
looking for unittest's setUp method:
http://docs.python.org/library/unittest.html#unittest.TestCase.setUp.

Jacob

-- 
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: Problem in Configuring the database

2011-05-08 Thread Malcolm Box
On 7 May 2011 16:44, rahul raj  wrote:

> After this i wanted to install database.. as mentioned in documentation, i
> did install mysql using YaST in OpenSUSE.. when i typed "mysql" in terminal
> it showed an error -- " Can't connect to local
>  MySQL server through socket '/var/run/mysql/mysql.sock' (2)") "
>
>
Almost certainly Mysql isn't running.  Try 'ps aux | grep mysql' and see if
there's anything listed (except for the grep command).

If there's nothing, then 'sudo /etc/init.d/mysqld start' will probably get
you going.

Malcolm


>
>

-- 
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: Instantiate a model using a string (or a dict)??

2011-05-08 Thread Eiji Kobayashi
Wow. Thank you all so much, esp. sensei Oleg!

Eiji

On Sun, May 8, 2011 at 10:11 AM, Oleg Lomaka  wrote:

> To extend Shawn's answer on your example :)
>
> params = {'username': 'admin', 'email': 'x...@xyz.com', 'password':
> 'xyz123'}
> # then
> new_user = User(**params)
> new_user.save()
> # or
> User.objects.create(**params)
>
> On Sun, May 8, 2011 at 1:44 PM, Eiji Kobayashi wrote:
>
>> Hi!
>>
>> Sorry. Another question, please.
>>
>> Is it possible to create a model instance using a string parameter?
>>
>> Example, I would like to be able to do something like:
>>
>> param = "username='admin', email='x...@xyz.com', password='xyz123'"
>> new_user = User(param)
>>
>> Of course this won't work. But is there a similar method? I don't want to
>> hard type every single fieldname (and the corresponding value) for every
>> field I'd like to have when instantiating a record for a model.
>>
>> Anyone?
>>
>> Eiji
>>
>> --
>> 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: Loading initial data with a post_syncdb hook?

2011-05-08 Thread Adam Seering


On May 8, 7:16 pm, Jacob Kaplan-Moss  wrote:
> On Sun, May 8, 2011 at 4:25 PM, Adam Seering  wrote:
> > I have some Python code that generatesinitialdatafor some of my tables; I
> > currently call that code from a post_syncdb hook. In Django 1.3, it looks 
> > like
> > Django now calls TRUNCATE (or an equivalent non-PostgreSQL-ism) on all 
> > tables
> > after running syncdb and all of itspost- hooks.
>
> That... doesn't sound right. Here's all the SQL syncdb executes (for a
> simple app with one table); notice the distinct lack of any TRUNCATE
> statement.
>
> Are you perhaps talking about doing this during testing? If so, you're
> looking for unittest's setUp 
> method:http://docs.python.org/library/unittest.html#unittest.TestCase.setUp.

Oh, sorry, yeah; let me clarify:

Our code has initial database data that it needs in general to operate
as intended, during tests or otherwise.  Mostly (though not
exclusively) to do with a plugins system; scanning a subdirectory for
matching .py files and detecting the features that they export is a
little expensive, particularly in the critical path of page-rendering;
much faster to do it once in advance.  The TRUNCATE is during tests,
though.

If we were to use TestCase.setUp, I would need to modify each of our
test classes to call each of our post_syncdb data-set-up hooks.  This
seems inelegant somehow; someone's going to forget one, and it's
redundant work (and so slower tests) because most of our tests aren't
TransactionTestCases and so don't need to re-create all of the data.

I could monkeypatch TestCase, and possibly even patch some hooks into
django.core.management.flush.Command.handle_noargs or
django.db.backends.*.DatabaseOperations.sql_flush to know when data
has been flushed so that I don't have to restore it unnecessarily.
That feels complicated and fragile, though; I'm not a fan if I can
avoid it...

If the appropriate signals existed in the test framework, I could hook
them and do something mildly creative and achieve the same effect as
the above using public API's and no monkeypatching.  Unfortunately, it
looks like they don't exist just yet; I just gave Trac #14319 a gentle
poke along those lines.

All of these seem way too complicated, though.  Am I missing the
forest for the trees?; is there a simpler solution here?

Thanks,
Adam


(Incidentally, sorry if this is a duplicate; my original reply,
identical text, doesn't show up on groups.google.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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Loading initial data with a post_syncdb hook?

2011-05-08 Thread Karen Tracey
On Sun, May 8, 2011 at 10:13 PM, Adam Seering  wrote:

> (Incidentally, sorry if this is a duplicate; my original reply,
> identical text, doesn't show up on groups.google.com...)
>

I don't know why, but google groups decided your original message might be
spam so held it. When it makes that decision for anyone other than a new
user, it doesn't bother to send a note to moderators until a few days later.
It's a great feechur of google groups. I have removed the copy that was held
for moderation so as to avoid the duplication.

The change you have noticed is documented in the 1.3
backwards-incompatibility list:
http://docs.djangoproject.com/en/1.3/releases/1.3/#use-of-custom-sql-to-load-initial-data-in-tests

Of the alternatives you list, using setUp seems like the correct approach.
I'm a little confused by your worry both that you're inevitably going to
forget to put a call somewhere where it is needed and simultaneous statement
that it's going to be causing duplicate work in a lot of places where it
isn't really needed, though. It seems like you ought to be able to figure
out where it is needed and put it there (possibly helped by tests that fail
due to it not being there).

Karen
-- 
http://tracey.org/kmt/

-- 
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: Loading initial data with a post_syncdb hook?

2011-05-08 Thread Adam Seering


On May 8, 10:53 pm, Karen Tracey  wrote:
> On Sun, May 8, 2011 at 10:13 PM, Adam Seering  wrote:
> > (Incidentally, sorry if this is a duplicate; my original reply,
> > identical text, doesn't show up on groups.google.com...)
>
> I don't know why, but google groups decided your original message might be
> spam so held it. When it makes that decision for anyone other than a new
> user, it doesn't bother to send a note to moderators until a few days later.
> It's a great feechur of google groups. I have removed the copy that was held
> for moderation so as to avoid the duplication.

Ah, thanks!

>
> The change you have noticed is documented in the 1.3
> backwards-incompatibility 
> list:http://docs.djangoproject.com/en/1.3/releases/1.3/#use-of-custom-sql-...

Actually, that's a different issue:  I'm not using the custom-SQL
loader, I'm using Python code with the post_syncdb hook.  This one
isn't in the backwards-compatibility page as far as I can tell.

(Was that comment intended to cover this case as well?  Maybe a typo
somewhere?)

>
> Of the alternatives you list, using setUp seems like the correct approach.
> I'm a little confused by your worry both that you're inevitably going to
> forget to put a call somewhere where it is needed and simultaneous statement
> that it's going to be causing duplicate work in a lot of places where it
> isn't really needed, though. It seems like you ought to be able to figure
> out where it is needed and put it there (possibly helped by tests that fail
> due to it not being there).

Hm; I'm not entirely sure why you're confused, it's certainly
something that'll be a bunch of work for us...  Perhaps you're
assuming that the set of tests are reasonably static, so that it's
possible to go through and do this once?  Let me take a shot at
clarifying; let me know if this helps:

Right now, we're working on adding tests, and on encouraging
developers to write tests for new parts of the code, new apps/code
that are being developed, etc.  Right now, as I understand it with
Django's current behavior and our post_syncdb hook setup, we want to
re-load the data in three cases:  (1) The current test is the first
test, (2) all prior tests are TestCase (as opposed to
TransactionTestCase) instances, or (3) we are a TransactionTestCase
instance.  So I can't look at any given test to tell you whether the
data has to be loaded or not; I need to know what test(s) have run
before it.  And this will change if we add new tests, and the result
may cause breakage not in the current code but in other pre-existing
tests, making it a pain to track down for anyone who doesn't know this
particular quirk.

We could just load it every time, but that would slow down our test
runs more than I'd like.  Also, it would involve adding the same one
line to every setUp() method, and remembering to add it to new tests,
etc.  Which I guess isn't the most onerous thing, but, I mean, it's
repeating the same line of code over and over again; is that not work
duplication?


What I personally wish that Django did in this case would be to trust
the data that syncdb puts into the database; do the necessary
bookkeeping to restore it to its initial state at the end of each test
as needed.  If I thought it would be accepted, I'd submit a patch.
But if it were that simple, I assume someone would have done it that
way at the start; I don't know enough about this project to understand
the reasoning behind the TRUNCATE here in any case...  Hopefully
that'll do a better job framing of what I'd like to accomplish with
our code, though.


Thanks,
Adam

-- 
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: filter in python

2011-05-08 Thread Jani Tiainen
On Sun, 2011-05-08 at 09:59 -0700, pankaj sharma wrote:
> hello ..
> 
> 
> i am having a database of college  which have a name city state
> branches etc...
> so
> 
> class College(models.Model):
> 
>name = models.CharField(max_length=250)
> 
>city = models.ForeignKey(City)
> 
>branch1 = models.BooleanField(default=False, blank=True)
>branch2 = models.BooleanField(default=False, blank=True)
>branch3 = models.BooleanField(default=False, blank=True)
>branch4 = models.BooleanField(default=False, blank=True)
> 
> 
> now i want to provide user that they can search colleges from
> branches..
> so i am giving them a select box where they can select the city and
> branches
> suppose i get two queries Qcity and Qbranch
> so i will filter all the colleges having city = Qcity and
> Branches=Qbranch
> so please tell me how to filter
> 
> i have filtered city but how to add one another filter for branch {as
> it is bolleanfield}
> college_list = College.objects.filter(city__title__icontains=Qcity)
> 

In case of branch1:
college_list = College.objects.filter(city__title__icontains=Qcity,
branch1=True)

if you want to search multiple branches:

branches_query = Q(branch1=True) | Q(branch2=True)
college_list = College.objects.filter(branches_query,
city__title__icontains=Qcity)

Though since you have boolean field that will always be either true or
false, you can construct:

branches_query=Q(branch1=branch1_form_field_value) |
Q(branch2=branch2_form_field_value) | ...

-- 

Jani Tiainen



-- 
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: Inserting csrf-token in a form generated by a templatetag?

2011-05-08 Thread Michal Petrucha
On Sun, May 08, 2011 at 10:13:23PM +0200, Thomas Weholt wrote:
> I've got a templatetag generating a form, but trying to add a
> csrf-token failes. What's the correct way to add a csrf-token to a
> form generated in plain html in a templatetag?
Basically, inside the template tag you'll have to resolve the context
variable 'csrf_token' using django.template.Variable.resolve() and
then include an  with its value.

Michal Petrucha


signature.asc
Description: Digital signature