Re: Rendering a form based on partly determined model state

2009-05-21 Thread google torp

Hi, not on my computet so will keep it short. Try to google "django
form trick" the top result should be a blog post by colin grady.
Basically what you need to do is to override the init method.

~Jakob

On May 21, 8:44 pm, Joakim Hove  wrote:
> Hello,
>
> I have just started using Django - looks very promising!
>
> I am trying to implement  something resembling a web-based shop. A
> simplified overview of my situation is as follows:
>
> models.py
> ---
>
> class Country(models.Model)
>      name     = CharField(max_length  = 100)
>      currency = CharField(max_length  = 3)
>
> class Product(models.Model)
>       name   = CharField(max_length = 100)
>       price     = FloatField()
>       country = ForeignKey(Country , editable = False)
>
> class Transaction(models.Model)
>       country   = ForeignKey( Country , editable = False)
>       product  = ForeignKey( Product )
>       date        = DateField()
>
> views.py
> ---
>
> class NewTransaction(ModelForm):
>        class Meta:
>                 model = Transaction
>
> def newtransaction(request , country):
>        return render_to_response(...)
>
> ...
> Now, an important aspect of this shop is that it operates in several
> different countries, and the available product are different in
> different countries. The database can typically contain four Product
> objects:
>
>      ["Norwegian_Product1" , "Norwegian_Product2" ,
> "Swedish_Product1" , "Swedish_Product2"]
>
> Based on the url the customer used I know which country she is in, and
> whether I should present the Norwegian products or the Swedish
> product. This id comes as the second argument to the view function,
> but when rendering the NewTransaction form I do not understand how to
> limit the rendereing ov available product to only those available in
> the customers country?!
>
> Any tips greatly appreciated.
>
> Regards
>
> Joakim Hove
--~--~-~--~~~---~--~~
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: need help for using counter inside for loop

2009-05-20 Thread google torp

This is probably more a python issue than a Django issue. Also
I don't really know what it is you want to do, but you should
consider if you really need to make all these lists? Also when
dealing with dates or datetimes python can do a lot of string
conversion for you. If you want to do it the way you do it now
you should probably change the code a bit to make it more
readable, it does the same thing:

str_date_list=[]
for item in range(1,32):
str_date_list.append('%02i-05-09' % item)

I don't get why you should get an error on counter += 1
However you should get an error on
val_time2 = str_date_list[counter + 1]
when counter is  30, as you will get out of index. You dont
need to use counter though, you could just do
for counter in range(31):
But the problem will remain. As I don't know what you are
trying to do, I can't say how to best fix it, maybe you need
to add an extra item to your str_date_list: 01-06-09, that
you can assign to val_time2 the last time in your loop.

~Jakob

On 20 Maj, 09:37, laspal  wrote:
> Hi,
>
> Hi,
>
> my_date_list = ['01', '02',
> '03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31']
> str_date_list=[]
> for item in my_date_list:
>     str_date_list.append(item+'-'+'05' + '-' +'09')
>
> counter= 0
> i = iter(range(31))
> for item in i:
>     daily_user_status_list=[]
>     print counter
>     val_time1 = str_date_list[counter]
>     val_time2 = str_date_list[counter + 1]
>     counter =counter + 1
>
> I am getting code error while doing counter = counter + 1 Basically I
> need to different time from my str_date_list each time. but counter =
> counter +1 give me code error. Is there any other way of doing it.
>
> 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
-~--~~~~--~~--~--~---



Re: Variables between Form and views

2009-05-13 Thread google torp

Hi
It seems your problem with dlist_choice is caused by an incorrect
you of global vars. I've not used globals much myself, but I believe
that you don't import them, but instead in every function that needs
them do a global var_name.

the other traceback seems irrelevant, but the problem you that
you haven't defined/imported choice in
ChoiceField(choices = choice, ...)

~Jakob

On 13 Maj, 08:51, Yang  wrote:
> Hi guys,
>
> I am a beginner of Django, a problem has been unsolved for a long
> time, can you help me.
>
> I have a file forms.py:
>
> from django import forms
> from views import dllist_choice
> class DLForm(forms.Form):
>     distribution_list=forms.ChoiceField
> (choices=dllist_choice,widget=forms.Select(attrs={'size':'20'}))
>
> class GroupMemberForm(forms.Form):
>     Members = forms.ChoiceField(widget=forms.Select(attrs=
> {'size':'20'}))
>
> and views.py looks like:
> from django.shortcuts import render_to_response
> from django.contrib.sessions.models import Session
> from forms import DLForm, GroupMemberForm
> from adldap import adldap
> import ldap.dn
> options={
>     'account_suffix': '@exaple.org',
>     'base_dn'       : 'DC=example,DC=org',
>     'hostport'      : "ldap://bei-dc01.gameloft.org:3268";,
>     'ad_username'   : "CN=wanng lin,OU=User,DC=example,DC=org",
>     'ad_password'   : '',
>     'real_primarygroup' :True,
>     'use_ssl'           :True,
> #    'recursive_grups'   :True}
>
> ad = adldap(options)
> dllist_choice=()
>
> def get_dl_list(request):
>     global dllist_choice
>     choice = ad.list_managed_dl('wang.y...@example.com')
>     dllist_choice=choice
>     form1 = DLForm()
>     return render_to_response('dl_form.html', {'form': form1})
>
> ChoiceField.choices come from LDAP databases, can someone know how to
> pass dllist_choice in view to the form. I have tried to import as a
> variable, but  I got error:
>
> ImportError at /
>
> cannot import name dllist_choice
>
> Request Method:         GET
> Request URL:    http://poplar.bei.gameloft.org:8000/
> Exception Type:         ImportError
> Exception Value:
>
> cannot import name dllist_choice
>
> Exception Location:     /home/ychengfu/dl/../dl/forms.py in ,
> line 2
> Python Executable:      /usr/bin/python
> Python Version:         2.5.2
> Python Path:    ['/home/ychengfu/dl', '/usr/lib/python2.5', '/usr/lib/
> python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/
> python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/
> usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/
> Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/
> site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/usr/
> lib/python2.5/site-packages/gtk-2.0', '/var/lib/python-support/
> python2.5/gtk-2.0', '/usr/lib/python2.5/site-packages/wx-2.6-gtk2-
> unicode']
> Server time:    Wed, 13 May 2009 01:49:58 -0500
>
> Traceback Switch back to interactive view
> Environment:
>
> Request Method: GET
> Request URL:http://poplar.bei.gameloft.org:8000/
> Django Version: 1.0.2 final
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> Traceback:
> File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
> in get_response
>   77.                     request.path_info)
> File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py" in
> resolve
>   179.             for pattern in self.urlconf_module.urlpatterns:
> File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py" in
> _get_urlconf_module
>   198.             self._urlconf_module = __import__
> (self.urlconf_name, {}, {}, [''])
> File "/home/ychengfu/dl/../dl/urls.py" in 
>   6. from views import get_dl_list, show_users
> File "/home/ychengfu/dl/../dl/views.py" in 
>   3. from dl.forms import DLForm, GroupMemberForm
> File "/home/ychengfu/dl/../dl/forms.py" in 
>   7. class DLForm(forms.Form):
> File "/home/ychengfu/dl/../dl/forms.py" in DLForm
>   9.     distribution_list=forms.ChoiceField(choices = choice,
> widget=forms.Select(attrs={'size':'20'}))
>
> Exception Type: NameError at /
> Exception Value: name 'choice' is not defined
>
> Any comment will be appreciated.
--~--~-~--~~~---~--~~
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: change query for ModelChoiceField

2009-05-11 Thread google torp

This should fix it.

def __init__(self, something, *args, **kwargs):
super(ShippingMethodForm, self).__init__(*args, **kwargs)
self.fields["ship_method"].queryset =
ShippingMethod.objects.filter(something)

when you initiate the form, you do it like this:
form = ShippingMethodForm(something, request.POST)

~Jakob

On 11 Maj, 22:48, adrian  wrote:
> I want to create a form with a select box populated from a query that
> I pass from the view.
>
> For example:
>
> if country == 'Canada':
>             methods = ShippingMethod.objects.filter(
>                 delivery_time__lte=time_avail_hours,
>                 abbrev__contains='SC'
>             )
>         else:
>             methods = ShippingMethod.objects.filter(
>                 delivery_time__lte=time_avail_hours,
>                 abbrev__contains='SU'
>             )
>
>         formShip = ShippingMethodForm(initial={
>             'queryset': methods,
>         })
>
> My Form is defined as:
>
> class ShippingMethodForm(forms.Form):
>     ship_method = forms.ModelChoiceField
> (queryset=ShippingMethod.objects.none())
>     def __init__(self, *args, **kwargs):
>         super(ShippingMethodForm, self).__init__(*args, **kwargs)
>         self.fields["ship_method"].queryset =
> ShippingMethod.objects.filter(something)
>
> However the queryset I define in the view is not being used by
> ShippingMethodForm, without the __init__ method shown.   I don't know
> how to pass the "initial" argument to the init method.  What is the
> correct way to do this?
>
> 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
-~--~~~~--~~--~--~---



Re: ajax cascading select boxes

2009-05-11 Thread google torp

Using AJAX in python/django is not much different than any other
tech. You choose an url, maybe just your form url and then you make
your normal javascript function that will post data to the url. In
the
view you can check for is_ajax(). This will enable you to catch all
ajax
requests and serve json data, while rendering the form when a normal
request comes in. The post data is in request.POST. Then you just do
 normal python/django and return the states associated with the
region.
The javascript you can put in a .js file and just serve it on the
needed
page(s).

All of this is pretty well explained in the documentation, and there
shouldn't be anything our of the ordinary in this. If you have probles
with writing the javascript itself, you should probably try a
javascript list.
A good libary that makes making ajax and other javascripting easier
is jQuery: www.jquery.com You can take a look at that.

~Jakob

On 11 Maj, 09:17, newbie  wrote:
> First of all, thanks for the reply :)
>
> On May 11, 11:59 am, google torp  wrote:> So CustomUser 
> and UserDetails  is a model you made for your
> > users? If that is the case, you probably want to hook use a
> > modelform instead is it makes things a bit eaiser.
>
> yup. Those two were created by me for the sake of users.
>
> > Anyways in your view, the user just pops out of the blue. My guess
> > is that you need to do something like user = CustomUser(...).
>
> Yup. you are rite. its actually user = CustomUser
> (mobile=mobile,username=username,password=password,email=email,user_type=user_type1)
> I've lost it while formatting the text.
>
> > If your form is going to stay like it is now, only having 2 districts,
> > you
> > don't need AJAX, you can just make a javascript to onclick show the
> > districts. If you do want to make a javascript, you need to make a
> > view
> > for it, that you can post the state to. And then return some json that
> > you can act upon. The easiest thing is probably to make a dictionary
> > and then use simplejson to return it in json format. Just return it as
> > a
> > HttpRepsonse, as you just want the raw data. You can use the
> > request.is_ajax() to test if the request on the url is an ajax request
> > or some one trying to visit the page. That way you could use the
> > current
> > url as your ajax url if you want.
>
> It actually has a lot of states. Sorry for missing the details. It
> shoud
> actually connect to a database their and retrieve the list of states.
> I want to do something like you said, use the javascript onclick event
> and
> send the selection made by the user and based on the selection connect
> to
> the database and retrieve the states. But i dont know how to use
> javascript in a
> python view. Please help me through it.
>
>
>
> > ~Jakob
>
> > On 11 Maj, 08:36, newbie  wrote:
>
> > > Hi,
>
> > >               I'm a newbie to Django. I have a form which has some
> > > attributes to be filled by the user viz., name, age, address etc. I
> > > want to get the address of the user by just allowing him making the
> > > selections rather than letting him fill it. I'm planning to give him a
> > > select box for state and then another select box giving the district
> > > in the country (which will be dynamically generated accessing the
> > > databased based on the selection made by the user). I've written a
> > > form for this purpose. But I dont know how to dynamically create them.
> > > Please help me out. Below is my code.
>
> > > In view:
>
> > > def register(request):
> > >         flash="Please enter your information in order to register"
> > >         form=regis()
>
> > >         if request.method == 'POST':
> > >                 form=regis(request.POST)
>
> > >                 username=request.POST.get('username', False)
> > >                 password=request.POST.get('password', False)
> > >                 password2=request.POST.get('password2', False)
> > >                 email=request.POST.get('email', False)
> > >                 user_type1=request.POST.get('user_type', False)
> > >                 mobile=request.POST.get('mobile', False)
> > >                 state=request.POST.get('state', False)
> > >                 district=request.POST.get('district', False)
> > >                 pincode=request.POST.get('pincode', False)
> > >                 address=request.POST.get('address', False)
> > >

Re: ajax cascading select boxes

2009-05-10 Thread google torp

So CustomUser and UserDetails  is a model you made for your
users? If that is the case, you probably want to hook use a
modelform instead is it makes things a bit eaiser.

Anyways in your view, the user just pops out of the blue. My guess
is that you need to do something like user = CustomUser(...).
If your form is going to stay like it is now, only having 2 districts,
you
don't need AJAX, you can just make a javascript to onclick show the
districts. If you do want to make a javascript, you need to make a
view
for it, that you can post the state to. And then return some json that
you can act upon. The easiest thing is probably to make a dictionary
and then use simplejson to return it in json format. Just return it as
a
HttpRepsonse, as you just want the raw data. You can use the
request.is_ajax() to test if the request on the url is an ajax request
or some one trying to visit the page. That way you could use the
current
url as your ajax url if you want.

~Jakob

On 11 Maj, 08:36, newbie  wrote:
> Hi,
>
>               I'm a newbie to Django. I have a form which has some
> attributes to be filled by the user viz., name, age, address etc. I
> want to get the address of the user by just allowing him making the
> selections rather than letting him fill it. I'm planning to give him a
> select box for state and then another select box giving the district
> in the country (which will be dynamically generated accessing the
> databased based on the selection made by the user). I've written a
> form for this purpose. But I dont know how to dynamically create them.
> Please help me out. Below is my code.
>
> In view:
>
> def register(request):
>         flash="Please enter your information in order to register"
>         form=regis()
>
>         if request.method == 'POST':
>                 form=regis(request.POST)
>
>                 username=request.POST.get('username', False)
>                 password=request.POST.get('password', False)
>                 password2=request.POST.get('password2', False)
>                 email=request.POST.get('email', False)
>                 user_type1=request.POST.get('user_type', False)
>                 mobile=request.POST.get('mobile', False)
>                 state=request.POST.get('state', False)
>                 district=request.POST.get('district', False)
>                 pincode=request.POST.get('pincode', False)
>                 address=request.POST.get('address', False)
>                 if password==password2:       CustomUser
> (mobile=mobile,username=username,password=password,email=email,user_type=user_type1)
>                         user.is_staff= 0
>                         user.save()
>                         userdetails=UserDetails
> (state=state,district=district,pincode=pincode,address=address,user=user)
>                         userdetails.save()
>                         flash="Thank You for Registering"
>                         message="You can start using our serices"
>                         return  HttpResponseRedirect('/default/
> index/')
>
>         return render_to_response('registerfran.html',locals())
>
> in forms.py:
> class regis(forms.Form):
>         state=(('Andhra Pradesh','andhra'),
> ('Maharastra','maharastra'))
>         district=(('Krishna','krishna'),('Guntur','guntur'))
>         username=forms.CharField(required=True)
>         password=forms.CharField(widget=forms.PasswordInput())
>         password2=forms.CharField(widget=forms.PasswordInput())
>         email=forms.CharField(required=True)
>         user_type=forms.ChoiceField(choices=(('Normal','normal'),
> ('Corporate','corporate'),('Franchise','franchise'),
> ('HeadOffice','headoffice')),required=False)
>         mobile=forms.CharField(required=True)
>         state=forms.ChoiceField(choices=state,required=False)
>         district=forms.ChoiceField(choices=district,required=False)
>         pincode=forms.CharField(required=True)
>         address=forms.CharField(widget=forms.Textarea(),required=True)
--~--~-~--~~~---~--~~
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: MySQL issues

2009-04-27 Thread google torp

Hi.

I haven't used Django with mysql, but judging from your error
it sounds like you haven't created the database in mysql. Django
probably cannot create a db like it can when you use sqlite, as it's
only a file anwyays. So you need to use your mysql tool
phpmyadmin or whatever you use and create the db and then
you can run syncdb. If that doesn't fix the problem, you have a
lot more interesting problem.

~Jakob

On 27 Apr., 10:33, 83nini <83n...@gmail.com> wrote:
> Hi guys,
>
> I'm working on the tutorial onwww.djangobook.com.
> I've created a database using "manage.py starapp books" then i
> modified the "models.py" file to include classes where each class
> represents a column in the database. then i modified the "settings.py"
> file to include the following:
>
> DATABASE_ENGINE = 'mysql'
> DATABASE_NAME = 'books'
> DATABASE_USER = 'Lina'
> DATABASE_PASSWORD = 'somepassword'
> DATABASE_HOST = 'localhost'
> DATABASE_PORT = '3306'
>
> and:
>
> INSTALLED_APPS = (
>     #'django.contrib.admin',
>     'helloworld.books',
>     #'django.contrib.auth',
>     #'django.contrib.contenttypes',
>     #'django.contrib.sessions',
>     #'django.contrib.sites',
> )
>
> should i be good to go or what? why do i get the long long long error
> that ends with:
> _mysql_exceptions.OperationalError: (1049, "Unknown database 'books'")
>
> when i try to validate the database using "C:\path to django
> project folder...> python manage.py validate"
>
> I really need and appreciate your help.
>
> cheers,
> Lina
--~--~-~--~~~---~--~~
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 redirect to previous page

2009-04-21 Thread google torp



On Apr 21, 10:53 pm, Margie  wrote:
> Can anyone advise me on what is the best way in the views.py code to
> return an HttpResponse that simply returns the user to the previous
> page they were on?
>
> For example, let's say that multiple different pages have a button
> that executes some code in views.py, but is not intended to actually
> take the user to a new page.  So after executing that code, I just
> want to redisplay the previous page they were looking at.

It sounds like you don't want to leave the page while your code is
running
and then come back but just stay on the same page. A good option for
this would be AJAX using javascript. Another way would be to use the
same template. Users won't know what views function is run so more
than one can use the same template making it look like they are on the
same page.

> On a slightly more complicated note, say multiple different pages have
> a button that executes some code and then does redirect the user to
> page 'foo'.  Now when the user clicks a 'submit' button on page
> 'foo',  I would like to take them back to wherever they were before
> they got to page 'foo'.
>
It sounds like you want to have a link to a form that when the user
has
filled it out and submited you want to take them back to that page. I
would suggest that you send along to the view a variable containing
data where to send them back and use to redirect them to the right
place. I don't know if Django has an easier way to do it, but else
that
way is a pretty general way of doing it.

~Jakob
--~--~-~--~~~---~--~~
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: Search and urls

2009-04-21 Thread google torp

if you really wanted it like that, you could setup your url like this
(r'^search/q=(?P)', ...)
or you could just remove the q= for prettier urls and do:
(r'^search/(?P)', ...)

That will give you the variable "query" to your view, you have to
write it in your view function aswell.

read about urlconf and view variables:
http://docs.djangoproject.com/en/dev/topics/http/urls/

~Jakob


On 21 Apr., 14:25, Oto Brglez  wrote:
> Hi all you coders outthere!
>
> I want to search for data in my database. Thats all fine.
> I just need help with quetys in urls...
>
> I want to have link like this:
> /search/q=cars
> /search/q=car+red+blue
> /search/q=my+search+query
>
> The problem is that i don't know what to write inside urls.py.
> What should i write in urls so that its passed to view as plain text?
>
> Thanx for your responses and have a nice day!
> Oto Brglez
--~--~-~--~~~---~--~~
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: Setting dates

2009-04-18 Thread google torp

You can do do something like this:
date = date.today()
while date.day != 20:
date += timedelta(1)

~Jakob

On 18 Apr., 21:57, Alfonso  wrote:
> Hi,
>
> I'd like to set the default date of a datefield to be 'the 20th of the
> current month', if past that date the date should be set to the 20th
> of the following month.
>
> So if a record is created on 1st April the datefield would be 20th
> April 2009, if record is created on 21st April then the datefield
> would be 20th May 2009.
>
> Figuring a custom save method would do fine for this but not sure on
> the syntax re. datetime and relativedelta etc.
>
> Anyone got any ideas or code lying around that might help?
>
> 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: Dynamic Form - polls

2009-04-18 Thread google torp

Hi.
Normally, what you are doing would work, initializing the form
with request.POST. However the way you have constructed
your form, you need have a poll object as well. Not only that
but it should of cause be the poll that the post data is associated
to.
Then you could do it like this
form = PollForm(the_right_poll, request.POST)

~Jakob

On 18 Apr., 22:27, Adam Yee  wrote:
> I've been struggling with dynamically creating and validating forms.
> So far I've been able to create the forms using a ModelChoiceField.
>
> see below - models, forms, views, templatehttp://dpaste.com/hold/35292/
>
> After submitting the votes, in the if request.method=="POST" hook, I
> can't figure out how to properly fill the form with the request.POST
> data.  Right now I'm getting this error
>
> AttributeError at /mediapoll/do_the_poll/
> 'QueryDict' object has no attribute 'choice_set'
>
> I understand why this is happening, but I can't see if there is
> something subtle that I'm missing in creating the form, or how I'm
> populating the form with the post data.  I'm still fairly new to
> Django.  Help please, 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: Unittests

2009-04-17 Thread google torp

Well the docs use camel case for tests, so figured that was the
convention
in Django. But the there are also some other places where Django
doesn't
quite follow the rules, like using _ in some of the HTML it generates.
Maybe that part of the docs should be cleaned up, I always thought
camel
cases was a speciel naming convention for tests after reading the
docs.

~Jakob

On Apr 17, 10:29 pm, Alex Gaynor  wrote:
> On Fri, Apr 17, 2009 at 4:26 PM, google torp  wrote:
>
> > Hi.
> > You have named your test incorectly, so django won't see it as a test.
> > You need to name testCamelCaseName. Camel cases are probably not
> > required but that's the convention. Try renaming your test.
>
> > ~Jakob
>
> > On Apr 17, 9:04 pm, Daniel Joshua Worth 
> > wrote:
> > > If I run "./manage.py tests booking" it returns ok but says it ran 0
> > tests
> > > so I'm obviously not doing something right if it's not running the test
> > at
> > > all. I keep reading the docs but it's not coming to me what I messed up.
>
> Camel case really shouldn't be the convention, as PEP-8 clearly says to use
> names_with_underscores, but you're correct that the test name must begin
> with the word test.
>
> Alex
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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: Queries, how to get what i want?

2009-04-17 Thread google torp

Hi.
Glad it worked out. You can't use [0] when using get as it retrives
an object. You can use it when you use filter as it returns a
queryset instead. That was my point, but using exclude before
get is fine aswell.

~Jakob

On Apr 17, 8:13 am, zayatzz  wrote:
> Thanks
>
> using [0] after objects.get(something=something) gives an error
> though.
>
> But writing it like this:
>                 q = ContentType.objects.get_for_model(self)
>                 z = Trans.objects.exclude(keel=2).get(content_type__pk=q.id,
> object_id=self.id)
>                 t = z.name
>                 return t
>
> Worked just fine.
>
> Thanks again :)
>
> Alan.
>
> On Apr 17, 3:21 am, google torp  wrote:
>
> > Hi.
> > I think the problem is that get is being run before the exclude when
> > you still have two results and fails as it can only handle a single
> > result.
> > In this case you can't use get but should use filter().exclude()[0] to
> > get
> > the result.
>
> > On Apr 16, 10:01 pm, zayatzz  wrote:
>
> > > I need help with making queries. I keep 
> > > readinghttp://docs.djangoproject.com/en/dev/ref/models/querysets/http://docs...
>
> > > but neither of those pages has exactly what i want nor explains why i
> > > cant get what i want with existing queries.
>
> > > Ill first post existing models here:
>
> > > class Trans(models.Model):
> > >         keel = models.ForeignKey(lang)
> > >         content_type = models.ForeignKey(ContentType)
> > >         object_id = models.PositiveIntegerField()
> > >         content_object = generic.GenericForeignKey("content_type",
> > > "object_id")
> > >         name= models.CharField(max_length=500)
> > >         def __unicode__(self):
> > >                 return unicode(self.name)
>
> > > class Poll(models.Model):
> > >         name = generic.GenericRelation(Trans)
> > >         pub_date = models.DateTimeField('date published')
> > >         active = models.BooleanField()
> > >         def __unicode__(self):
> > >                 return unicode(self.name)
>
> > > What im trying to achieve with query is to retrieve the actual
> > > translation (from trans model) instead of poll name.
>
> > > I wrote model manager for it -
>
> > >         def tname(self):
> > >                 q = ContentType.objects.get_for_model(self)
> > >                 z = Trans.objects.get(content_type__pk=q.id,
> > > object_id=self.id).exclude(keel=2)
> > >                 t = z.name
> > >                 return t
>
> > > What i fail to understand is how this query can retrieve 2 objects not
> > > one, because i keep getting this error:
>
> > > Caught an exception while rendering: get() returned more than one
> > > Trans -- it returned 2! Lookup parameters were {'object_id': 1,
> > > 'content_type__pk': 11}
>
> > > Doesnt the exclude work?
>
> > > There is 2 translations for each poll. one with language 1 and one
> > > with language 2.
>
> > > This also gives me 2 results
> > > z = Trans.objects.filter(poll = self)
> > > q = z.get(keel = 1)
> > > t = q.name
>
> > > Error was :  Caught an exception while rendering: get() returned more
> > > than one Trans -- it returned 2! Lookup parameters were {'keel': 1}
>
> > > What i fail to understand is, that when i use enough filters to filter
> > > results down to 1 - then i cant get .name value from the result, but
> > > when i use get instead of filter i get too many results even though i
> > > use exclude or additional parameters like keel = 1.
>
> > > Please help me understand how queries are supposed to work and how can
> > > i get what i want.
>
> > > Alan.
--~--~-~--~~~---~--~~
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: Unittests

2009-04-17 Thread google torp

Hi.
You have named your test incorectly, so django won't see it as a test.
You need to name testCamelCaseName. Camel cases are probably not
required but that's the convention. Try renaming your test.

~Jakob

On Apr 17, 9:04 pm, Daniel Joshua Worth 
wrote:
> If I run "./manage.py tests booking" it returns ok but says it ran 0 tests
> so I'm obviously not doing something right if it's not running the test at
> all. I keep reading the docs but it's not coming to me what I messed up.
--~--~-~--~~~---~--~~
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: Queries, how to get what i want?

2009-04-16 Thread google torp

Hi.
I think the problem is that get is being run before the exclude when
you still have two results and fails as it can only handle a single
result.
In this case you can't use get but should use filter().exclude()[0] to
get
the result.

On Apr 16, 10:01 pm, zayatzz  wrote:
> I need help with making queries. I keep 
> readinghttp://docs.djangoproject.com/en/dev/ref/models/querysets/http://docs.djangoproject.com/en/dev/topics/db/queries/
>
> but neither of those pages has exactly what i want nor explains why i
> cant get what i want with existing queries.
>
> Ill first post existing models here:
>
> class Trans(models.Model):
>         keel = models.ForeignKey(lang)
>         content_type = models.ForeignKey(ContentType)
>         object_id = models.PositiveIntegerField()
>         content_object = generic.GenericForeignKey("content_type",
> "object_id")
>         name= models.CharField(max_length=500)
>         def __unicode__(self):
>                 return unicode(self.name)
>
> class Poll(models.Model):
>         name = generic.GenericRelation(Trans)
>         pub_date = models.DateTimeField('date published')
>         active = models.BooleanField()
>         def __unicode__(self):
>                 return unicode(self.name)
>
> What im trying to achieve with query is to retrieve the actual
> translation (from trans model) instead of poll name.
>
> I wrote model manager for it -
>
>         def tname(self):
>                 q = ContentType.objects.get_for_model(self)
>                 z = Trans.objects.get(content_type__pk=q.id,
> object_id=self.id).exclude(keel=2)
>                 t = z.name
>                 return t
>
> What i fail to understand is how this query can retrieve 2 objects not
> one, because i keep getting this error:
>
> Caught an exception while rendering: get() returned more than one
> Trans -- it returned 2! Lookup parameters were {'object_id': 1,
> 'content_type__pk': 11}
>
> Doesnt the exclude work?
>
> There is 2 translations for each poll. one with language 1 and one
> with language 2.
>
> This also gives me 2 results
> z = Trans.objects.filter(poll = self)
> q = z.get(keel = 1)
> t = q.name
>
> Error was :  Caught an exception while rendering: get() returned more
> than one Trans -- it returned 2! Lookup parameters were {'keel': 1}
>
> What i fail to understand is, that when i use enough filters to filter
> results down to 1 - then i cant get .name value from the result, but
> when i use get instead of filter i get too many results even though i
> use exclude or additional parameters like keel = 1.
>
> Please help me understand how queries are supposed to work and how can
> i get what i want.
>
> Alan.
--~--~-~--~~~---~--~~
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: can’t input @ sign on a Windows PC which I installed Portable Ubuntu -- which gives you linux on it

2009-04-15 Thread google torp

This group is for Django related subjects only, please help us keep
the posts on subject. I would suggest you asked this question in a
Portable Ubuntu group instead.

~Jakob

On 15 Apr., 20:58, bconnors  wrote:
> I have a Windows PC which I installed Portable Ubuntu -- which gives
> you linux on it. I’m trying to do
> Python manage.py syncdb so I can get Django working. Trouble is in
> Linux I’m not able to input @ sign
>
> 1       Tried  ascii representation of @ sign #64 and
> 2       Tried hex representation of @ sign 40
>
> I also tried 3 things that Ubuntu forum suggested:
>
> switched keyboard layout to "be" and keyboard model "pc105"
> ran « sudo dpkg-reconfigure -phigh xserver-xorg » and receive message
> that :
> xserver-xorg is not installed
> 4       tried switching to finnish keyboard
>
> 5       tried sudo apt-get install scim-bridge
>
> All 5 failed. Just want to be able to input @ sign.
--~--~-~--~~~---~--~~
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 querying database

2009-04-15 Thread google torp

The two ways are pretty much the same, one picks a random
number to use for a slice, the other picks a random element in
a queryset. I would go for whatever you think is the easiest
to understand, when browsing through the code.

Also, if you're not sure that atleast 3 elements will come from
the query you would need an if statement in the randrange
version aswell.

~Jakob

On 15 Apr., 17:54, Baxter  wrote:
> On Apr 15, 10:44 am, google torp  wrote:> What I meant 
> was that you could do it like this
>
> > import random
> > sa = Article.objects.filter(...).order_by('-id')
> > random_choice = sa[random.randrange(2, len(sa))]
>
> Thanks Jakob. Is there an advantage to doing it that way rather than
> what I came up with, using choice() rather than random?
--~--~-~--~~~---~--~~
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 querying database

2009-04-15 Thread google torp

What I meant was that you could do it like this

import random
sa = Article.objects.filter(...).order_by('-id')
random_choice = sa[random.randrange(2, len(sa))]

random.randrange will create a "random" number for you. Giving it
those arguments it can output a number of 2 (so the first wont be
selected) and number of articles -1 so there wont be in problem
getting a number that is too high.
This is just pure python functionality btw.

~Jakob

On 15 Apr., 16:54, Baxter  wrote:
> On Apr 15, 9:39 am, Baxter  wrote:
>
> > On Apr 15, 9:33 am, google torp  wrote:> Hi.
> > > You can just use the python random function, I believe it's in math,
> > > and generate a random number in range of the number of articles.
> > > You could do that before the slice even, and just get a random
> > > number with min value of 2 instead.
>
> > If I were smarter I'd understand what you're trying to tell me here.
>
> Well, it got me on the right track, I think. I'm not entirely sure
> what I've done here, so if it's stupid, someone please let me know:
>
> subcat_articles = Article.objects.filter(publication='Published',
> assigned_to=subcat).order_by('-id')[2:]
> if subcat_articles.count() > 0:
>                                 subcat.article = choice(subcat_articles)
--~--~-~--~~~---~--~~
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 querying database

2009-04-15 Thread google torp

Hi.
You can just use the python random function, I believe it's in math,
and generate a random number in range of the number of articles.
You could do that before the slice even, and just get a random
number with min value of 2 instead.

~Jakob

On 15 Apr., 16:23, "bax...@gretschpages.com" 
wrote:
> I'm hoping someone can help me get the info I'm trying to get. This is
> the structure:
>
> I have Categories
>     Each Category has one or more subcategory
>     Articles have a M2M relationship with subcategory so they can turn
> up in more than one category as needed.
>
> I'm trying to get one random article for each category, but NOT the
> two most recent articles.
>
> I'm trying this:
>
> articles = Article.objects.filter(publication='Published',
> assigned_to=subcat).order_by('-id')[2:]
> subcat.article = articles.order_by('?')[0]
>
> Which should get all the articles for the subcat except the two most
> recent ones, then select one random one from that list, except I'm
> running into "AssertionError: Cannot reorder a query once a slice has
> been taken."
>
> So, how can I do this?
--~--~-~--~~~---~--~~
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: code from database in template -> <br>

2009-04-15 Thread google torp

Just wanted to add, the danger is not if the data is coming
from the db, as all the data, more or less will come from the db.
The problem is if the user has made the input that was saved
to the db, like the username. Marking such content with the
safe tag would make it possible for evil minded users to destroy
your site.

~Jakob

On 15 Apr., 14:29, mag_dex  wrote:
> sorry:
>
> Description:{{  script.desc | safe }}
> 
>
> no need to put   {% autoescape off %} in this second statement.
>
> On Apr 15, 3:28 pm, mag_dex  wrote:
>
> > Thanks. I've been on that page but I just found
>
> >       {% autoescape off %}
> >       Description:{{  script.desc }} > td>
> >       {% endautoescape %}
>
> > Using 'safe' it goes like:
>
> >       {% autoescape off %}
> >       Description:{{  script.desc |
> > safe }}
> >       {% endautoescape %}
>
> > Data goes from the db (by but some stuff) so there is not risk.
>
> > Thanks again.
>
> > Wishes,
>
> > M.
>
> > On Apr 15, 2:15 pm, google torp  wrote:
>
> > > Hi
> > > There is a page for all the django template 
> > > tags:http://docs.djangoproject.com/en/dev/ref/templates/builtins/
>
> > > Your problem is the auto escape, you can use "|safe" to mark something
> > > safe and it wont be escaped. Doing this for user submitted data is a
> > > bad idea though, so make sure you don't make your site vulnerable for
> > > attacks before use.
>
> > > ~Jakob
>
> > > On 15 Apr., 12:52, mag_dex  wrote:
>
> > > > Hey,
>
> > > > I've gotten a following problem. I have stored some pieces of html
> > > > code in the database.
> > > > If the django renders html code it  is changed to <br>  ;(
> > > > I guess there is easy one to change behaviour of rendering but I can't
> > > > find it.
>
> > > > Any ideas?
>
> > > > M.
--~--~-~--~~~---~--~~
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: code from database in template -> <br>

2009-04-15 Thread google torp

Hi
There is a page for all the django template tags:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/

Your problem is the auto escape, you can use "|safe" to mark something
safe and it wont be escaped. Doing this for user submitted data is a
bad idea though, so make sure you don't make your site vulnerable for
attacks before use.

~Jakob

On 15 Apr., 12:52, mag_dex  wrote:
> Hey,
>
> I've gotten a following problem. I have stored some pieces of html
> code in the database.
> If the django renders html code it  is changed to 
 ;( > I guess there is easy one to change behaviour of rendering but I can't > find it. > > Any ideas? > > M. --~--~-~--~~~---~--~~ 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: Different approach?

2009-04-15 Thread google torp

Hi.

As I'm not sure exactly what your goals with this site is, I'll be
guessing a
bit here. Using the admin to create customers ect, can be a solution,
but
having access to the admin also means having access to a whole bunch
of
stuff that you can mess with. You could instead make some views that
will
display some modelforms that you can use to create what you need.
Maybe
you also some some views that will display customers based per city
postal code, city areas or whatever suits best. You could also add
order
tracking, so you can see what pizza's are selling most and see if
repeat
customers are buying the same (kind of) pizzas. All of these would
also
require views. There are lots of possibilities to extend. Also using
the admin
as the main part of the site should only be done, if the site is only
used by
very few trusted people.

~Jakob

On 15 Apr., 05:40, Mariano Sokal  wrote:
> Well, i'm also new :)
>
> I've been using django for a couple of days trying to learn while developing
> a Pizza Delivery Software... (yes, I got bored doing blogs) and since it is
> not a traditional website where one has an admin area and a
> regular-user-live-site area, I feel that almost every functionality that I
> want for my app can be accomplished just by using admin.
>
> Ok, as I told you, I am new... but I need to add customers, add addresses,
> add orders... and after doing all the models and registering the admin
> models I feel that I'm almost done with the application. Is that the way you
> do an application where there's no public website but is more like a
> point-of-sale?
>
> Regards,
> Mariano
--~--~-~--~~~---~--~~
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: serving static files

2009-04-13 Thread google torp

Hi.

You misunderstood the docs a bit, I c/p'ed the url-conf bit here:

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/path/to/media'}),

The problem here that is also causing the error is that the file name
should be
a variable and not hardcoded for every file, so instead of default.css
you should
instead have (?P.*). This is part of the argument that serve
will take, which
it uses to find the right file to serve. That is why the error is
saying:
erve() takes at least 2 non-keyword arguments (1 given)
the 2nd arguement that it expect is the document root.

Hope this clear things up for you

~Jakob

On 13 Apr., 13:58, amit sethi  wrote:
> Hi , i am new to django and i am trying to serve my css file .
> I followed the instruction to serve  static files in development server and
> made a seperate /media directory
> I copied my css file into it
>
> and changed the url pattern to include:
> (r'^site_media/default.css$', 'django.views.static.serve',
>         {'document_root': '/home/amit/analytics/media', 'show_indexes': 
> True}),
>
> now i get the error
> serve() takes at least 2 non-keyword arguments (1 given)
> i am new to web development please help
> --
> A-M-I-T S|S
--~--~-~--~~~---~--~~
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: Use Python to parse HTML and integrating said script into Django

2009-04-12 Thread google torp

Hi.

It sounds like you need to change your code structure a bit to really
take advantage of Django and the possibilities it offer. If you just
want
to get your stuff working with Django and then nothing more, I guess
you could keep it like it is, but else re factoring would be a good
idea.

The way django works, you want to keep the logic separated from the
presentation. So basically that means, that you should keep the Python
code separated from your HTML. In Django terms, we use the view
to make the logic, where we can if needed, import helper functions.
When all the data has been calculated, we pass it to a template, a
html file where we with some Django code can insert data dynamically.

It sounds like you need to grasp these things, before you really get
going.

about writing views: http://docs.djangoproject.com/en/dev/topics/http/views/
about the template language 
http://docs.djangoproject.com/en/dev/topics/templates/
about render_to_response: 
http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response

Render to response is  common way of passing data to a template for
display.
Which was what your initial question was about. But I would recommend
that
you strip the html from your Python code and instead put the html in
your template
instead. That would be a more clean and Djangoish way of doing it.

~Jakob

On 13 Apr., 07:24, Tonne  wrote:
> Hi
>
> I'm not too sure how to ask this correctly (not an experienced
> developer so my vocab is not very accurate), but I'll try.
>
> I have created a Python script (collection of functions) that
> generates a calendar of sorts, really just a long list of dates from a
> 4 year date range. It also parses the HTML, as I couldn't work out how
> to do this with the limited logic available the templating language.
>
> My question are:
>
> Is it possible to use a "freeform" python within the Django framework,
> and yet let it receive arguments from the model?
>
> I was intially thinking of making a custom view, but then I have all
> this parsed HTML and am not sure how to get it into a template.
>
> Or should I be looking at making a custom tag?
>
> If not the above, do you have any other pointers on how to go about
> this?
>
> 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
-~--~~~~--~~--~--~---



Re: Details

2009-04-09 Thread google torp

Hi.

I'm guessing a bit here, not sure if it actually will make any
difference, but
try to delete the $ in the include so it'll become:
(r'^', include('p2.front.urls')),
$ marks the end of the url, so maybe that is giving you the problem.

~Jakob

On 9 Apr., 11:55, zayatzz  wrote:
> I think it has:
>
> My project urlconf is
>
> urlpatterns = patterns('',
>         (r'^$', include('p2.front.urls')),
>         #(r'^lang/(?P\d+)/$', 'p2.front.views.changelang'),
>         (r'^admin/(.*)', admin.site.root),
> )
>
> And front urlconf is:
> urlpatterns = patterns('p2.front.views',
>         (r'^$', 'index'),
>         (r'^lang/(?P\d+)/$', 'changelang'),
> )
>
> The thing that i cant figure out is that when i go to 127.0.0.1:8000/
> the index page opens, and that too does come from front urlconf that
> is included in project urlconf.
> And when i uncomment the line in project urlconf, then it all starts
> working.
>
> Alan.
>
> On Apr 9, 11:14 am, "johan.uhIe" 
> potsdam.de> wrote:
> > When you have a look at the error and at your urlsconf.py, you might
> > see that the error does not include your urlconf.py, which it actually
> > should, so the problem must be, that Django is not using your urlconf.
> > Have you included the urlconf in your projects urls.py?
>
> > Could be something like this:
>
> > urlpatterns = patterns('',
> > # other stuff
> > (r'^$', include('front.urls')),
> > )
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---