Re: cannot login to admin site using admin credentials

2011-02-07 Thread xpanta
I have tried this already. I still can't login.

:-(



On 7 Φεβ, 15:48, Chris Lawlor  wrote:
> Try running 'python manage.py createsuperuser' on your production
> server to create a new superuser account. You should have full
> privileges to log in to the admin and make changes using this account.
>
> On Feb 7, 8:15 am, xpanta  wrote:
>
> > Hi,
>
> > it seems that my problem is a bit complicated. I have tried much but
> > to no avail. So, please help me!
>
> > Some time ago I migrated to postgresql from mysql. I don't know if I
> > did something wrong. Anyway, my webapp works "almost" flawlessly.
>
> > Since then I never needed to login using admin rights (either using
> > the admin panel or my web site). Some weeks ago I tried and I noticed
> > that I can't login (to both admin site and web page) using admin
> > credentials.
>
> > I have tried dozens of various tricks but I still can't login.
>
> > I tried adding user.set_password()  to my views.py in order to replace
> > admin password with a new simpler one ('123') but nothing. I even
> > registered a new user from my web page and changed its fields directly
> > in the DB (is_staff, is_active, is_superuser) to 'True'. This let me
> > login to the admin site but gave me no permission to change anything.
> > I even tried to create various admin users with the help of django
> > shell but none of them gives me a login. Interestingly whenever I do
> > something to change admin password, I always see a different hashed
> > password value in my DB. This means that all my approaches succeed in
> > changing the admin password. However I can't login.
>
> > Normal users work fine. Problem appears only when the user is an
> > administrator.
>
> > Any help would be greatly 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.



Slow performance with Django when connected to Oracle

2011-02-07 Thread dw314159
Django gurus:

Hello, I am experiencing very slow performance with Django when
connected to an Oracle database. The exact same Django application
runs far faster with PostgreSQL and SQLite, with the same source data
loaded into each database. Looking at the information embedded in
“connection.queries” after making an Oracle query through Django, it
appears that the queries themselves run very quickly (runtimes are
comparable to those measured with PostgreSQL and SQLite), but the
whole turnaround time for a query in Oracle far exceeds the reported
query time.

I’ve tried the built-in Oracle backend engine and django-oraclepool
0.7; neither improve performance. (With django-oraclepool, I also gave
sufficient time for the connections to pool before taking
measurements). Using cx_Oracle outside of Django on the same
workstation to connect to the same Oracle database, the query
turnaround time is very quick.

Is this problem connected to the fact that Django is reported to drop
the database connection between queries, and therefore must reconnect
to Oracle every time a query is executed? Or is there a Django
configuration option that must be specified to make the best use of
Oracle?

We are using Python 2.7, Django 1.2.1, Oracle 11, and Apache HTTP
Server 2.2.17.

Any help would be greatly appreciated.  Thanks!

DW

-- 
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: manytomany help

2011-02-07 Thread ivan sugiarto
You must delete those tables and run sync db again..

On 8 Feb 2011 11:32, "Bobby Roberts"  wrote:

I've got two models:

class a (models.Model):
   id = models.AutoField (primary_key=True)
   name = models.CharField (max_length=50, blank=False,
db_index=True)
class aAdmin(admin.ModelAdmin):
   list_display = ('name',)
   search_fields = ['name']
admin.site.register(a,aAdmin)


class b(models.Model):
   id = models.AutoField (primary_key=True)
   name = models.CharField (max_length=50, blank=False,
db_index=True)
   CommunicationsStatus = models.CharField
(max_length=50,blank=False, db_index=True)
   active = models.IntegerField(blank=False,
choices=active_choices)
   order = models.IntegerField(blank=True, default=0)
   usedby = models.ManyToManyField('a')
class bAdmin(admin.ModelAdmin):
   list_display =
('name','active','order','CommunicationsStatus',)
   search_fields = ['name']
admin.site.register(b,bAdmin)



Note the usedby field in model b.  when i goto/admin and into that
model, I get the following error:

(1146, "Table 'AppSettings_b_usedby' doesn't exist")


Any idea what the heck that means?  It looks like it's trying to
create a table or something.  when i syncdb there's no action taken on
the database.

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



manytomany help

2011-02-07 Thread Bobby Roberts
I've got two models:

class a (models.Model):
id = models.AutoField (primary_key=True)
name = models.CharField (max_length=50, blank=False,
db_index=True)
class aAdmin(admin.ModelAdmin):
list_display = ('name',)
search_fields = ['name']
admin.site.register(a,aAdmin)


class b(models.Model):
id = models.AutoField (primary_key=True)
name = models.CharField (max_length=50, blank=False,
db_index=True)
CommunicationsStatus = models.CharField
(max_length=50,blank=False, db_index=True)
active = models.IntegerField(blank=False,
choices=active_choices)
order = models.IntegerField(blank=True, default=0)
usedby = models.ManyToManyField('a')
class bAdmin(admin.ModelAdmin):
list_display =
('name','active','order','CommunicationsStatus',)
search_fields = ['name']
admin.site.register(b,bAdmin)



Note the usedby field in model b.  when i goto/admin and into that
model, I get the following error:

(1146, "Table 'AppSettings_b_usedby' doesn't exist")


Any idea what the heck that means?  It looks like it's trying to
create a table or something.  when i syncdb there's no action taken on
the database.

-- 
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: cleaned_data not behaving how I expect it to. (newbie confusion)

2011-02-07 Thread Ben Dembroski
My apologies to the list.

I just noticed the commas at the end of the lines in the views.py
file.

Once I got rid of those, all was much better.



On Feb 7, 11:33 pm, Ben Dembroski  wrote:
> Hi all.
>
> Another silly question.  I'm hoping someone here can explain something
> about the way form validation and processing is working in the
> following example of User Registration:
>
> From forms.py
>
> class RegistrationForm(forms.Form):
>     username = forms.CharField(label=u'Username', max_length=30)
>     email = forms.EmailField(label=u'Email')
>     password1 = forms.CharField(label=u'Password',
> widget=forms.PasswordInput())
>     password2 = forms.CharField(label=u'Repeat Password',
> widget=forms.PasswordInput())
>     fname = forms.CharField(label=u'First Name', max_length=30)
>     lname = forms.CharField(label=u'Last Name', max_length=30)
>
>     def clean_password2(self):
>         if 'password1' in self.cleaned_data:
>             password1 = self.cleaned_data['password1']
>             password2 = self.cleaned_data['password2']
>             if password1 == password2:
>                 return password2
>             else:
>                 raise forms.ValidationError('Passwords do not match.')
>
>     def clean_username(self):
>         username = self.cleaned_data['username']
>         if not re.search(r'^\w+$', username):
>             raise forms.ValidationError('Username can only contain '
>                                         'alphanumeric characters and
> the underscore')
>
>         try:
>             User.objects.get(username=username)
>         except User.DoesNotExist:
>             return username
>         raise forms.ValidationError('Username is already taken.')
>
> The relevant bit of views.py:
>
> form = RegistrationForm(request.POST)
>                 if form.is_valid():
>                         user = User.objects.create_user(
>                                 username=form.cleaned_data['username'],
>                                 password=form.cleaned_data['password1'],
>                                 email=form.cleaned_data['email'],
>                         )
>                         user.first_name=form.cleaned_data['fname'],
>                         user.last_name=form.cleaned_data['lname'],
>                         user.save()
>                         return HttpResponseRedirect('/select')
>
> When I test use the form, and enter a username, password, email, first
> and last name, it creates a user.  However, the saved values for the
> first and last name aren't what I expected:
>
> From manage.py shell:
>
> >>> User.objects.all()
>
> [, , , ]>>> peep = 
> User.objects.get(username='nexttest')
> >>> peep.first_name
> u"(u'next',)"
> >>> peep.last_name
> u"(u'test',)"
> >>> peep.username
> u'nexttest'
> >>> peep.email
>
> u'nextt...@doo.com'
>
>
>
> As you can see, the values for the first_name and last_name are
> unicode strings that represent a tuple?  The other values seem to be
> just fine.
>
> Any explanation on why this is happening?  Or pointers on where to
> look? I've re-read the documentation on forms, the usual googling,
> etc.
>
> This is using version 1.2
>
> Many thanks!
> Ben

-- 
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: Questions about documentation management

2011-02-07 Thread Russell Keith-Magee
On Tue, Feb 8, 2011 at 5:50 AM, Aryeh Leib Taurog  wrote:
> On Feb 7, 10:29 pm, anastasia  wrote:
>
> Disclaimer: I'm not really responsible for django documentation, but
> have poked at it a bit, and am somewhat familiar with the platforms.

For the record, I *am* responsible for Django's documentation, and
most of the answers provided by Aryeh are correct. A couple of minor
clarifications:

>> - What did you like about your platform? What are its weaknesses?
>
> * growing in popularity and is used by many projects (See 
> http://readthedocs.org/)
> * python based
> * can output many different formats including html, windows chm, latex/
> pdf

I would also add: Easily writable and readable by humans without
extensive tool support. It's a very lightweight markup format, and the
source is almost as readable as the final product.

>> - Do you use any form of auto-generated API documentation? If so, how
>> to you manage integration with more narrative text such as tutorials,
>> examples, etc?
>
> I don't believe that django does, but sphinx is capable of this.
> See the matplotlib documentation, for example.  I believe the api docs
> are auto-generated.
>
> http://matplotlib.sourceforge.net/api/index.html

Django doesn't have autogenerated API docs -- mostly (IMHO) because
this is a feature of Python itself -- anything that could be
automatically generated could also be determined using the interactive
prompt.

>> - Are developers involved in writing the documentation, or is that
>> left to technical writers?
>
> Seems to me the developers do it.

Correct, although:

 * We have a couple of committers whose sole responsibility is to
maintain the documentation

 * Several of our core committers, including our two BDFLs have formal
training in the arts; Adrian is a Journalism major, and Jacob is an
American Literature major. We also have a Philosophy major and three
doctorates in our team. Overall, the "developers" are a literate
bunch, not just a bunch of hackers forced to write some docs.

>> - Do you support community input/editing of documentation? Why or why
>> not?
>
> Seems to me that documentation is treated same as code.  Those who
> have commit rights commit; the rest of us submit patches.

Correct -- as for the reasoning behind this: our experience has been
that wikis become a wasteland. Good documentation, like good design,
isn't something that can be arrived at by committee, or by consensus
-- it requires strong decision making and editorial 'taste' to build a
coherent and useful body of documentation.

However, we are exploring some ways to make it easier for people to
contribute suggestions and modifications to the documentation.

Yours,
Russ Magee %-)

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



cleaned_data not behaving how I expect it to. (newbie confusion)

2011-02-07 Thread Ben Dembroski
Hi all.

Another silly question.  I'm hoping someone here can explain something
about the way form validation and processing is working in the
following example of User Registration:

>From forms.py

class RegistrationForm(forms.Form):
username = forms.CharField(label=u'Username', max_length=30)
email = forms.EmailField(label=u'Email')
password1 = forms.CharField(label=u'Password',
widget=forms.PasswordInput())
password2 = forms.CharField(label=u'Repeat Password',
widget=forms.PasswordInput())
fname = forms.CharField(label=u'First Name', max_length=30)
lname = forms.CharField(label=u'Last Name', max_length=30)

def clean_password2(self):
if 'password1' in self.cleaned_data:
password1 = self.cleaned_data['password1']
password2 = self.cleaned_data['password2']
if password1 == password2:
return password2
else:
raise forms.ValidationError('Passwords do not match.')

def clean_username(self):
username = self.cleaned_data['username']
if not re.search(r'^\w+$', username):
raise forms.ValidationError('Username can only contain '
'alphanumeric characters and
the underscore')

try:
User.objects.get(username=username)
except User.DoesNotExist:
return username
raise forms.ValidationError('Username is already taken.')

The relevant bit of views.py:

form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'],
email=form.cleaned_data['email'],
)
user.first_name=form.cleaned_data['fname'],
user.last_name=form.cleaned_data['lname'],
user.save()
return HttpResponseRedirect('/select')

When I test use the form, and enter a username, password, email, first
and last name, it creates a user.  However, the saved values for the
first and last name aren't what I expected:

>From manage.py shell:

>>> User.objects.all()
[, , , ]
>>> peep = User.objects.get(username='nexttest')
>>> peep.first_name
u"(u'next',)"
>>> peep.last_name
u"(u'test',)"
>>> peep.username
u'nexttest'
>>> peep.email
u'nextt...@doo.com'
>>>

As you can see, the values for the first_name and last_name are
unicode strings that represent a tuple?  The other values seem to be
just fine.

Any explanation on why this is happening?  Or pointers on where to
look? I've re-read the documentation on forms, the usual googling,
etc.

This is using version 1.2

Many thanks!
Ben

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



Simple chat function

2011-02-07 Thread Ethan Yandow
Does anyone know of a way of creating a simple chat client using
Django and Openfire between different Openfire users?  Anything would
be great :)  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: read-only Form.as_* views

2011-02-07 Thread Ian Stokes-Rees


On 2/7/11 5:29 PM, Ian Stokes-Rees wrote:
> This sounds good.  Form Preview could be useful, but right now I just
> want to be able to use Generic Views (DetailView.as_view()) to render
> the default context object using "as_table()", but I'm failing to do that.
>
> {{ object.as_table }} returns nothing, whereas, {{ object.name }} etc.
> works just fine.  I don't understand why object.as_table wouldn't
> work.  Below are some code fragments.

I think I can answer my own question: as_table() is a method of
ModelForm objects, not Model objects.  So I tried pointing DetailView at
WSMRTaskForm, but now I get the exception:

type object 'WSMRTaskForm' has no attribute '_default_manager'


Frustrating!  Any suggestions?  It doesn't seem unreasonable to want the
DetailView to be able to render the "default" tabular view of the Model
created by:

class WSMRTaskForm(ModelForm):
class Meta:
model = WSMRTask

Thanks,

Ian

-- 
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: read-only Form.as_* views

2011-02-07 Thread Ian Stokes-Rees
This sounds good.  Form Preview could be useful, but right now I just want 
to be able to use Generic Views (DetailView.as_view()) to render the default 
context object using "as_table()", but I'm failing to do that.

{{ object.as_table }} returns nothing, whereas, {{ object.name }} etc. works 
just fine.  I don't understand why object.as_table wouldn't work.  Below are 
some code fragments.

Cheers,

Ian

urls.py:
(r'task/(?P\d+)/?$'  , DetailView.as_view(model=WSMRTask)),

to

templates/wsmr/wsmrtask_detail.html:


{{ object.as_table }}



-- 
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: incrementing counter of an cached data

2011-02-07 Thread Michel Thadeu Sabchuk
You can hit the counter through ajax and still keep the cache of the
entire page. This is useful if you have a cache through nginx +
memcached.

Regards,

On 7 fev, 20:15, "Henrik Genssen"  wrote:
> are you using middleware or a decorator for caching your view?
> if you are using a decorator like @cache_page from 
> django.views.decorators.cache you can add simply a second decorator befor the 
> caching one, where you count your hits...
> if you are using a middleware, you have to write your own cache middleware 
> (copy the existing and add you counter)
>
> regards
>
> Hinnack
>
> >reply to message:
> >date: 07.02.2011 22:53:10
> >from: "ozgur yilmaz" 
> >to: django-users@googlegroups.com
> >subject: Re: incrementing counter of an cached data
>
> >No suggest?
>
> >2011/2/7 ozgur yilmaz 
>
> >> Hi,
>
> >> I'm using file caching. But need to increment a field for storing product
> >> hits. Is there an optimal 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 
> >athttp://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.



Testing in a project with multiple databases

2011-02-07 Thread Stathis
Hello everyone,

I have set up a project with multiple database connections (default
and legacy). I use models for the default database, but the legacy db
is not managed by models. I issue raw sql to query the legacy
database. Django-nose and south are  used.

I am facing multiple problems:

- When I run the tests two test databases are created (which is fine).
Nevertheless, django system tables (auth etc) are created in the test
legacy database (which is something I want to avoid). What is more, a
south script which uses the models is also run against the test legacy
database causing a failure.

- I am looking for a way to create the structure of the test legacy
database before testing. I want to do this by raw sql as the legacy
databased is not managed by models. Is there any way to do that?

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: Re: incrementing counter of an cached data

2011-02-07 Thread Henrik Genssen
are you using middleware or a decorator for caching your view?
if you are using a decorator like @cache_page from 
django.views.decorators.cache you can add simply a second decorator befor the 
caching one, where you count your hits...
if you are using a middleware, you have to write your own cache middleware 
(copy the existing and add you counter)

regards

Hinnack

>reply to message:
>date: 07.02.2011 22:53:10
>from: "ozgur yilmaz" 
>to: django-users@googlegroups.com
>subject: Re: incrementing counter of an cached data
>
>No suggest?
>
>2011/2/7 ozgur yilmaz 
>
>> Hi,
>>
>> I'm using file caching. But need to increment a field for storing product
>> hits. Is there an optimal 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.
>

-- 
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: incrementing counter of an cached data

2011-02-07 Thread ozgur yilmaz
No suggest?

2011/2/7 ozgur yilmaz 

> Hi,
>
> I'm using file caching. But need to increment a field for storing product
> hits. Is there an optimal 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: Database synchronization with sometimes-connected mobile client

2011-02-07 Thread Eric Chamberlain
We had to work through similar issues with our iPhone and iPad applications.

We wanted to decouple the server development from the iOS applications and 
decided to not try and mirror the device and server database schemas, we pass 
objects back and forth and let each implementation store the underlying object 
however it needs to (CoreData or SQL).  

Our object tracking is loosely based on Active Directory's multi-master 
replication model.  We track objects by UUID and last modified timestamp.  The 
device(s) can then pull/push all the moves/adds/changes since the last sync.



On Feb 5, 2011, at 5:02 AM, Greg Humphreys wrote:

> Hi everyone. I've developed a django website of medium complexity
> (about 50,000 lines of python), and the company I work for is now
> asking for a subset of the functionality to be available on an iPad.
> 
> I'm familiar with iPad development, so I'm not worried about that, but
> all the research I've done on keeping the databases synchronized has
> basically boiled down to "it's hard, good luck" :)
> 
> I want people to be able to make updates, deletes, and additions to
> the database on an iPad, and then later synchronize these changes with
> the web server (sort of like omnifocus), while also getting any new
> changes that have been made on the server side.   This is important
> because the users won't always be connected to the internet.
> 
> Every solution I've sketched out has my head spinning trying to figure
> out how to handle foreign keys properly, what to do if the sync dies
> partway through, and so forth. The server database will always be
> considered sacrosanct, so if two people edit the same object, the
> server version should always win (I'd just present the iPad user with
> a list of things that he "lost" on). This includes situations like the
> iPad user deleting an object that had been updated on the server since
> the last sync, etc.
> 
> Has anyone on this list ever tackled annoying like this?  All my
> django objects keep track of creation and modification time. I have
> lots of foreign keys and many to many relationships. One very simple
> thing that needs to happen just to get started would be that the
> pre_delete signal would need to copy / flag entries so that deletions
> could later be handled in synchronization. The iPad must keep deleted
> objects (or at least their pks) around until the next sync, and the
> server needs to keep the pks somewhere so it can tell remote clients
> about the deletions later. And it just gets more complex from there!
> 
> Another situation is if the iPad users creates a new object, and then
> uses foreign keys to refer to it, the synchronization might change the
> pk of the new object (since a new object with the same pk might have
> been created on the server), so if that happens all those foreign keys
> need to be fixed up on the iPad, and those implicit changes uploaded
> to the server as well. Then if the app dies in the middle of that
> process, it seems very very easy for one (or both!) of my quite large
> databases to get in some inconsistent state that would be nearly
> impossible to repair.
> 
> One of the things I'd like to avoid is having to make every single
> many to many relationship have to use a custom "through" class just
> for synchronization, since that makes the admin interface less nice
> without adding any real functionality to the web users.
> 
> Am I screwed?  Should I dust off my old silberschatz database book, or
> is this easier than I think?

--
Eric Chamberlain, Founder
RF.com - http://RF.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: Questions about documentation management

2011-02-07 Thread Aryeh Leib Taurog
On Feb 7, 10:29 pm, anastasia  wrote:

Disclaimer: I'm not really responsible for django documentation, but
have poked at it a bit, and am somewhat familiar with the platforms.

> - What platform does Django use for its documentation? (e.g. a wiki?
> DocBook?)

Sphinx
http://sphinx.pocoo.org/

Based on reStructured text, a very extensible lightweight markup
http://docutils.sourceforge.net/rst.html

> - What did you like about your platform? What are its weaknesses?

* growing in popularity and is used by many projects (See 
http://readthedocs.org/)
* python based
* can output many different formats including html, windows chm, latex/
pdf

> - How easy or hard it is to customize the look and feel of the
> interface with your platform? i.e. style, layout, navigation, etc.

relatively easy

> - Do you use any form of auto-generated API documentation? If so, how
> to you manage integration with more narrative text such as tutorials,
> examples, etc?

I don't believe that django does, but sphinx is capable of this.
See the matplotlib documentation, for example.  I believe the api docs
are auto-generated.

http://matplotlib.sourceforge.net/api/index.html

> - How do you manage versioning of your documentation (i.e.
> documentation specific to a particular version of Processing)?

Since the source is plain text, they are kept in django svn

> - Are developers involved in writing the documentation, or is that
> left to technical writers?

Seems to me the developers do it.

> - Do you support community input/editing of documentation? Why or why
> not?

Seems to me that documentation is treated same as code.  Those who
have commit rights commit; the rest of us submit patches.

-- 
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: Sorting list view on based on field from joined table

2011-02-07 Thread Aryeh Leib Taurog
On Feb 7, 10:50 pm, SimpleDimple  wrote:
> I am new to django and building a school system but am experience
> developer otherwise having firm grip over rails, php, .net and java.
>
> I can see the list and do sorting & search but only based on the
> fields which are in the same table... what if I want to sort on or
> search on field which is in another table ? something like
>
> select class.* from class, session
>    where class.session_id = session.id
>    order by session.starting_date

Class.objects.order_by(session__starting_date)

see docs for order_by method of QuerySet
http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by

-- 
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: Including apps for inherited models in INSTALLED_APPS

2011-02-07 Thread Shawn Milochik
Perhaps some deeper background will help:

http://docs.djangoproject.com/en/1.2/ref/contrib/contenttypes/

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.



Re: read-only Form.as_* views

2011-02-07 Thread Aryeh Leib Taurog
On Feb 7, 10:57 pm, Ian Stokes-Rees 
wrote:
> I love the fact that I can quickly and easily get a "view" of my objects in
> Django, but is there any current way to get "read-only" views of objects
> where fields are not editable?  I want to be able to display the "forms"
> once they are completed but with the fields displayed just as table entries
> or textareas which can't be edited.  In other words, no  or 
> tags.

Read-only forms/fields are a popular topic, but not supported in
django.  To display data, simply put the data object (i.e. a model
instance) itself in a template context and render it.

Perhaps this would be of use to you:
http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-preview/

Aryeh Leib

-- 
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: Including apps for inherited models in INSTALLED_APPS

2011-02-07 Thread Ian Stokes-Rees


On 2/7/11 3:50 PM, Shawn Milochik wrote:
> Because when the model isn't abstract, the fields
> in the base model aren't created for the subclass -- the subclass has
> a foreign key to an instance of the base model.
> That last bit should explain why you need to have the base app in
> installed apps.

Not really -- it explains why adding it makes things work, but it
doesn't explain why I *have* to include it.  "syncdb" is smart enough to
figure out that DerivedModel(BaseModel) has django.db.models.Model
*somewhere* in its super-class ancestry, so I don't see why it can't
also be smart enough to then figure out that "BaseModel" needs to be
included for ORM automatically.

Ian

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



incrementing counter of an cached data

2011-02-07 Thread ozgur yilmaz
Hi,

I'm using file caching. But need to increment a field for storing product
hits. Is there an optimal 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: Setting session variable at the time of login

2011-02-07 Thread Shawn Milochik
1. You'll have to create your own login view. You can look at Django's
view and just copy it. You can use the built-in authentication and
template and everything, plus whatever else you want to do.

2. Here's how you do that:
http://docs.djangoproject.com/en/1.2/topics/auth/#storing-additional-information-about-users

-- 
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: default header template file

2011-02-07 Thread Shawn Milochik
This will help you a lot:

https://github.com/robhudson/django-debug-toolbar

It shows you the templates being used and a bunch of other stuff.

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.



Re: Filtering List based on a custom dropdown

2011-02-07 Thread SimpleDimple
I can live w/o AJAX for now to keep it simple.

What I am not clear is on how to do the postback from javascript ?  I
mean on what URL and pass on which variables ? and thru GET or POST or
shall i do form.submit()  ??


On Feb 8, 1:45 am, Joel Goldstick  wrote:
> On Mon, Feb 7, 2011 at 3:38 PM, SimpleDimple wrote:
>
>
>
> > I am new to django and building a school system but am experience
> > developer otherwise having firm grip over rails, php, .net and java.
>
> > I have student table and in list I can see list of all students/
> > records in student table(pasted below is my code)
>
> > what I want here is a custom dropdown listing the classes in school
> > from class table, and when you select/change the class the list of
> > students should get filtered accordinglycan someone please give me
> > hints or guide me a bit ?
>
> > class StudentAdmin(admin.ModelAdmin):
> >    fields        = ['xclass', 'name', 'reg_no' , 'roll_no' ]
> >    list_display  = ['xclass', 'name', 'reg_no' , 'roll_no' ]
> >    list_filter   = ['name', 'reg_no' , 'roll_no' ]
> >    search_fields = ['name', 'reg_no' , 'roll_no' ]
>
> >    form          =  StudentForm
>
> >    def queryset(self, request):
> >        school_id = request.session['school_id']
> >        qs = self.model._default_manager.filter(school=school_id)
> >        return qs
>
> >    def save_model(self, request, obj, form, change):
> >        school_id = request.session['school_id']
> >        school = School.objects.get(id=school_id)
> >        obj.school = school
> >        obj.save()
>
> > --
> > 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.
>
> This topic has come up recently under different specifics.  When you change
> your filter (by selecting a specific class) you need to requery with that
> condition.  This can be done by submitting the form to get a new dataset, or
> by using AJAX style to have the data retrieved on the fly to repopulate your
> form.
>
> --
> Joel Goldstick

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



read-only Form.as_* views

2011-02-07 Thread Ian Stokes-Rees
I love the fact that I can quickly and easily get a "view" of my objects in 
Django, but is there any current way to get "read-only" views of objects 
where fields are not editable?  I want to be able to display the "forms" 
once they are completed but with the fields displayed just as table entries 
or textareas which can't be edited.  In other words, no  or  
tags.

TIA.  Ian Stokes-Rees

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



default header template file

2011-02-07 Thread SimpleDimple
I am new to django and building a school system but am experience
developer otherwise having firm grip over rails, php, .net and java.

When I login, I can see the username of user logged-in in the
header... I want to add more info from sessions there, so I am
wondering which template file is it for header ?

-- 
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: Including apps for inherited models in INSTALLED_APPS

2011-02-07 Thread Shawn Milochik
On Mon, Feb 7, 2011 at 3:43 PM, Ian Stokes-Rees
 wrote:
> On 2/7/11 3:38 PM, Shawn Milochik wrote:
>> Is your base model abstract? If it is not, then the ORM will want to
>> create it in the database.
>
> No, it isn't abstract.  It has a particular content model and methods
> associated with it.  When you say the ORM will "want" to create it in
> the DB, do you mean:
>
> 1. It should figure this out on its own and create the base model table; or
> 2. The ORM needs this so it must be listed in INSTALLED_APPS to have the
> relevant table created in the DB.
>


It's definitely #2. Because when the model isn't abstract, the fields
in the base model aren't created for the subclass -- the subclass has
a foreign key to an instance of the base model.
That last bit should explain why you need to have the base app in
installed apps.

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.



Sorting list view on based on field from joined table

2011-02-07 Thread SimpleDimple
I am new to django and building a school system but am experience
developer otherwise having firm grip over rails, php, .net and java.

I can see the list and do sorting & search but only based on the
fields which are in the same table... what if I want to sort on or
search on field which is in another table ? something like

select class.* from class, session
   where class.session_id = session.id
   order by session.starting_date

-- 
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: Filtering List based on a custom dropdown

2011-02-07 Thread Joel Goldstick
On Mon, Feb 7, 2011 at 3:38 PM, SimpleDimple wrote:

> I am new to django and building a school system but am experience
> developer otherwise having firm grip over rails, php, .net and java.
>
> I have student table and in list I can see list of all students/
> records in student table(pasted below is my code)
>
> what I want here is a custom dropdown listing the classes in school
> from class table, and when you select/change the class the list of
> students should get filtered accordinglycan someone please give me
> hints or guide me a bit ?
>
>
>
> class StudentAdmin(admin.ModelAdmin):
>fields= ['xclass', 'name', 'reg_no' , 'roll_no' ]
>list_display  = ['xclass', 'name', 'reg_no' , 'roll_no' ]
>list_filter   = ['name', 'reg_no' , 'roll_no' ]
>search_fields = ['name', 'reg_no' , 'roll_no' ]
>
>form  =  StudentForm
>
>def queryset(self, request):
>school_id = request.session['school_id']
>qs = self.model._default_manager.filter(school=school_id)
>return qs
>
>def save_model(self, request, obj, form, change):
>school_id = request.session['school_id']
>school = School.objects.get(id=school_id)
>obj.school = school
>obj.save()
>
>
> --
> 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.
>
>
This topic has come up recently under different specifics.  When you change
your filter (by selecting a specific class) you need to requery with that
condition.  This can be done by submitting the form to get a new dataset, or
by using AJAX style to have the data retrieved on the fly to repopulate your
form.

-- 
Joel Goldstick

-- 
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: Including apps for inherited models in INSTALLED_APPS

2011-02-07 Thread Ian Stokes-Rees
On 2/7/11 3:38 PM, Shawn Milochik wrote:
> Is your base model abstract? If it is not, then the ORM will want to
> create it in the database.

No, it isn't abstract.  It has a particular content model and methods
associated with it.  When you say the ORM will "want" to create it in
the DB, do you mean:

1. It should figure this out on its own and create the base model table; or
2. The ORM needs this so it must be listed in INSTALLED_APPS to have the
relevant table created in the DB.

Right now it looks like the situation is 2., but I'm wondering if there
is a good reason why it can't be 1.

Thanks,

Ian

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



Setting session variable at the time of login

2011-02-07 Thread SimpleDimple
I am new to django and building a school system but am experience
developer otherwise having firm grip over rails, php, .net and java.

1) I am using django admin, I want to set a variable at the time of
user login... the user login is coming from django code so I have no
idea how to capture "after login" eventplease help.

2) Also is it easy to add/control/manage more fields to django's auto
generated user profile ? or what is best practice here ?

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



Filtering List based on a custom dropdown

2011-02-07 Thread SimpleDimple
I am new to django and building a school system but am experience
developer otherwise having firm grip over rails, php, .net and java.

I have student table and in list I can see list of all students/
records in student table(pasted below is my code)

what I want here is a custom dropdown listing the classes in school
from class table, and when you select/change the class the list of
students should get filtered accordinglycan someone please give me
hints or guide me a bit ?



class StudentAdmin(admin.ModelAdmin):
fields= ['xclass', 'name', 'reg_no' , 'roll_no' ]
list_display  = ['xclass', 'name', 'reg_no' , 'roll_no' ]
list_filter   = ['name', 'reg_no' , 'roll_no' ]
search_fields = ['name', 'reg_no' , 'roll_no' ]

form  =  StudentForm

def queryset(self, request):
school_id = request.session['school_id']
qs = self.model._default_manager.filter(school=school_id)
return qs

def save_model(self, request, obj, form, change):
school_id = request.session['school_id']
school = School.objects.get(id=school_id)
obj.school = school
obj.save()


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



Questions about documentation management

2011-02-07 Thread anastasia
Hello,

My name is Anastasia Cheetham. I'm a developer with and the
documentation lead for the Fluid Project (http://fluidproject.org).
We're beginning the process of restructuring and redesigning the
documentation for our Infusion framework. Part of that process will
include migrating to a new platform for the creation and distribution
of documentation, and we're interested in learning about the
experiences of other open source projects, including Django. I'm
hoping that someone might have time to share some thoughts about how
you team manages documentation. For example:

- What platform does Django use for its documentation? (e.g. a wiki?
DocBook?)

- What did you like about your platform? What are its weaknesses?

- How easy or hard it is to customize the look and feel of the
interface with your platform? i.e. style, layout, navigation, etc.

- Do you use any form of auto-generated API documentation? If so, how
to you manage integration with more narrative text such as tutorials,
examples, etc?

- How do you manage versioning of your documentation (i.e.
documentation specific to a particular version of Processing)?

- Are developers involved in writing the documentation, or is that
left to technical writers?

- Do you support community input/editing of documentation? Why or why
not?


I thank you very much for your time, and for any thoughts you can
share.

--
Anastasia Cheetham Inclusive Design Research Centre
acheet...@ocad.caInclusive Design Institute
   OCAD University

-- 
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: Including apps for inherited models in INSTALLED_APPS

2011-02-07 Thread Shawn Milochik
Is your base model abstract? If it is not, then the ORM will want to
create it in the database.

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.



Getting value from session in ModelForm

2011-02-07 Thread SimpleDimple
I am new to Django and building a school system but am an experienced
developer otherwise having firm grip over rails, .net, php & java.

I have the following class where on teacher add/edit form, I am trying
to filter values in class drop down based on school.  The value of
school_id is saved in session but as you can see below pulling value
from session fails in ModelForm, can someone please guide me on how to
get the value from session here ?


class TeacherForm(ModelForm):
def __init__(self, *args, **kwargs):
super(TeacherForm, self).__init__(*args, **kwargs)

xclass = self.fields['xclass'].widget

choices = []

#school_id = request.session['school_id'] # since this
fails, I have hard coded the value 2 in line below for now
school_id = 2
xclasses = Class.objects.filter(school=school_id)
for c in xclasses:
choices.append((c.id,c.name))
xclass.choices = choices

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



Including apps for inherited models in INSTALLED_APPS

2011-02-07 Thread Ian Stokes-Rees
Does it make sense that inherited models also need their apps included in 
INSTALLED_APPS?  Right now if I have:

base/models.py:

class MyBaseModel(django.db.models.Model):
   stuff

and then elsewhere:

derived/models.py:

class MyDerivedModel(base.MyBaseModel):
   stuff

I need to include both "derived" and "base" in my INSTALLED_APPS list in 
settings.py, otherwise the table for the MyBaseModel content is never 
created.  It seems to me that "syncdb" should be able to "see" that 
MyDerivedModel has MyBaseModel as a super class in the chain to 
django.db.models.Model and consequently create the necessary tables for 
MyBaseModel.

Or have I just misunderstood why it was necessary for me to include "base" 
in order to get the tables created properly by "manage.py syncdb"?

TIA, Ian Stokes-Rees

-- 
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: Is there a way to know which user changed a particular model through the admin site?

2011-02-07 Thread Shawn Milochik
Go to http://docs.djangoproject.com/ and type 'admin user' in the search box.

The first result is a FAQ containing this question and answer.

-- 
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: 'module' object has no attribute 'Form'

2011-02-07 Thread Shawn Milochik
The problem is your "star" import from localflavor, which contains a
'forms' module.

Just import what you need from localflavor.

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.



Re: Is there any way to get the ip address of the user in the post_save signal?

2011-02-07 Thread Cal Leeming [Simplicity Media Ltd]
Hey,

In previous projects, we have addresses this issue by making the HTTP
Request object available globally.  I have placed the code you need to do
this here: http://djangosnippets.org/snippets/2352/

Please note, this method is
slightly frowned upon in the community, but sometimes rules have to be bent
a little :)

Hope this helps.

<3

On Mon, Feb 7, 2011 at 1:43 PM, Stodge  wrote:

> Is there any way to get the ip address of the user in the post_save signal?
> 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.
>

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



Error when editing Inline OneToOneField

2011-02-07 Thread Pascal Germroth
Hi,

using SVN revision 15440 I get some weird behaviour:


Part of my model looks like this:

-
from django.contrib.gis.db import models

class Address(models.Model):
  uuid = UuidField(primary_key=True)
  readable = models.CharField(max_length=200)
  geo = models.GeometryField()

  def save(self, *args, **kwargs):
self.readable, self.geo = geocode(self.readable)
super(Address, self).save(*args, **kwargs)

class Corporation(models.Model):
  uuid = UuidField(primary_key=True)
  name = models.CharField(max_length=200)

class Branch(models.Model):
  uuid = UuidField(primary_key=True)
  address = models.OneToOneField(Address)
  corporation = models.ForeignKey(Corporation)
-

In the admin interface I use

-
class AddressAdmin(admin.ModelAdmin):
  readonly_fields = ('geo',)
admin.site.register(Address, AddressAdmin)

class BranchInline(admin.StackedInline):
  model = Branch
  fields = ('address',)

class CorporationAdmin(admin.ModelAdmin):
  inlines = [BranchInline]
  fields = ('name',)

admin.site.register(Corporation, CorporationAdmin)


Now for the weird part:

Add a corporation via admin interface, click save, works as expected.
Open the corporation again, in the inlined branch, add a new address,
click save, works as expected.

Then: open that corporation a third time, no matter what you do (delete
a branch, add another, change anything) clicking save returns this error:

MultiValueDictKeyError at
/admin/base/corporation/2b97beda-6893-426c-8229-ddf001394d36/
"Key 'branches-0-uuid' not found in "


I'm worried about the mention of branches.uuid -- this shows up
nowherein the generated form (only a select 'branches-0-address' with
the uuids of available addresses).

Playing around with fk_name on the inline admin brought me nothing but
error messages…

This only seems to concern the InlineModelAdmin. When I use seperate
ModelAdmin-s, everything works.


Where should I look for the bug? Might it be my custom UUID-field? (but
it seems to work…)



Cheers,

-- 
Pascal Germroth

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



'module' object has no attribute 'Form'

2011-02-07 Thread shireknight
I created a form in forms.py with this code:

===
from django import forms
from django.forms import widgets
from django.contrib.localflavor.us import *
import datetime

class InquiryForm(forms.Form):
===

Exception Value:

'module' object has no attribute 'Form'

Exception Location:   /path/to/my/project/inquiry/forms.py in
, line 6

I tried importing in the shell and I got this output. So it seems to
import the file:

===
In [1]: from django import forms
In [2]: forms.Form
Out[2]: 
===

I'm stumped.


-- 
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 with date and decimal changes between 1.1.1 and 1.2.4

2011-02-07 Thread Ramiro Morales
On Mon, Feb 7, 2011 at 2:13 PM, Jop  wrote:
> Hallo,
>
> I am upgrading a Django project from 1.1.1 to 1.2.4. Unfortunately I'm
> running into some trouble concerning date and decimal formatting in
> 1.2.4. What I'm looking for is to match the original situation as we
> need the dates to be the same for xml feeds etc and the point for
> javascript. I know I can use a template filter on all the dates in the
> templates, but this is a lot of work and has the risk of missing
> something somewhere. What I'm looking for is a confirguration setting
> which fixes this problem.
>
> Original situation (1.1.1)
> - Dates: 21-12-2010
> - Decimals are point separated.
>
> New situation (1.2.4 with: I10N=False and LANGUAGE_CODE = 'nl'):
> - Dates: maart 1, 2012
> - Decimals are point separated
>

I think this option is the one that should work and isn't in 1.2.4. You have the
following two choices:

 - Go back to 1.2.3
 - or use a checkout of the 1.2.X maintenance branch at revision
[1]15405 or newer.
   The fix for this temporal regression in 1.2.4 will be included in a
future 1.2.5

> Other new situation (1.2.4 with: I10N=True and LANGUAGE_CODE = 'nl'):
> - Dates: 1 maart 2012
> - Decimals are comma separated


Regards,
-- 
Ramiro Morales

1. http://code.djangoproject.com/changeset/15405

-- 
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 with date and decimal changes between 1.1.1 and 1.2.4

2011-02-07 Thread creecode
Hello Job

On Feb 7, 9:13 am, Jop  wrote:

> I am upgrading a Django project from 1.1.1 to 1.2.4. Unfortunately I'm
> running into some trouble concerning date and decimal formatting in
> 1.2.4.

I don't have an answer but have you looked at the localization file
for nl to see if something has changed between the two versions?  If
so you could modify that to fix the problem short term but of course
that would get overwritten with the next update.  That might be OK if
it is a bug in the localization and it's fixed in the update you
download.

I'm not up on all the localization stuff but perhaps you can modify
the localization file and then put it outside of the normal django
directory and have your install use that file.  Take a look at <
http://docs.djangoproject.com/en/1.2/topics/i18n/ >.

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.



problem with date and decimal changes between 1.1.1 and 1.2.4

2011-02-07 Thread Jop
Hallo,

I am upgrading a Django project from 1.1.1 to 1.2.4. Unfortunately I'm
running into some trouble concerning date and decimal formatting in
1.2.4. What I'm looking for is to match the original situation as we
need the dates to be the same for xml feeds etc and the point for
javascript. I know I can use a template filter on all the dates in the
templates, but this is a lot of work and has the risk of missing
something somewhere. What I'm looking for is a confirguration setting
which fixes this problem.

Original situation (1.1.1)
- Dates: 21-12-2010
- Decimals are point separated.

New situation (1.2.4 with: I10N=False and LANGUAGE_CODE = 'nl'):
- Dates: maart 1, 2012
- Decimals are point separated

Other new situation (1.2.4 with: I10N=True and LANGUAGE_CODE = 'nl'):
- Dates: 1 maart 2012
- Decimals are comma separated

When I try on the pythonprompt the locale.getdefaultlocale() returns
('en_US', 'UTF8').

Thanx for your help / time!

-- 
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 URL Detail

2011-02-07 Thread Amit

Hello,
In my Django application (basically handover to me), I am hitting the
Web-Server with some http request which bring me data. I would come to
know about the complete URL;

  http://domain_name/address

In order to get problem thoroughly one should visit:

http://stackoverflow.com/questions/4921331/django-url-detail



Please get me rid of this.
Thanks in advance!


Amit.

-- 
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 can I show a list of values in a text input field?

2011-02-07 Thread Nate Reed
Bill, thanks for your reply.  I considered rendering the form
manually, and that would be a fine solution.  I ended up creating a
custom widget (MultiValueTextWidget) that joins the input values.  I
don't know if this is the best solution, but it solves the problem of
rendering the values as a single input field:

class MultiValueTextWidget(TextInput):
def _get_value(self, value):
return " ".join(value)

def _format_value(self, value):
if self.is_localized:
return formats.localize_input(self._get_value(value))
return self._get_value(value)

Overriding __str__ (or was it __unicode__?  I don't have the code in
front of me) results in user-friendly values being rendered instead of
object id's.

My form has a clean method which splits the values and validates them,
and the view handles splitting the input and setting the many-to-many
relation.

I realize this is an unconventional way to render many-to-many
relations in a form, but in this particular case that's how I wanted
to allow the user to see and edit the values.

Thanks,
Nate

On Mon, Feb 7, 2011 at 10:08 AM, Bill Freeman  wrote:
> On Sun, Feb 6, 2011 at 4:25 PM, Nate Reed  wrote:
>> I posted this question on StackOverflow, too.  I have defined a Model
>> with a ManyToManyField, and I want the field to show the values joined
>> by spaces, for example:
>>
>> 
>>
>> I have defined the form to use CharField to represent the multiple values:
>>
>> class MyForm(ModelForm):
>>    foo = CharField(label='Foo')
>>    class Meta:
>>        model = MyModel
>>
>> Instead of showing the values separated by spaces, the input field
>> shows this instead:
>>
>> [u'val1', u'val2', u'val3']
>>
>> How can I override this behavior?  My understanding is that widgets
>> are responsible for rendering the input.  Is there an example of a
>> custom widget that does something like this?
>>
>> Nate
>>
>
> You have a related problem in terms of what you want to have happen
> when the form is submitted.  The string that you get needs to be
> converted to objects (or their id's) before you can save them to the
> DB, and a representation of the id probably isn't what you're expecting
> to show in the field.
>
> CharField is mostly suitable for submitting a character string, typically
> stored in the DB as a character string.  Relation fields are more amenable
> to a (multi-)select field or radio buttons (check boxes for multiple valued
> fields).
>
> You could create a custom form field, if this scheme is truly what you
> wish.
>
> You can also render the desired input within your form by hand, instead
> of expecting the from object's as_p(), etc. to render it for you.  You will
> then also need to check the submitted value in the POST or GET data,
> since the form object doesn't know about it.  The template language is
> strong enough to render what you want if you pass the related object
> manager to the template, but it is a bit hairy for a template, so I'd
> suggest having your view function calculate the desire value string
> for the input, and pass that instead.  When you parse the posted
> value, you will still need to look up the objects somehow from the
> submitted value.
>
> Bill
>
> --
> 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: Is there any way to get the ip address of the user in the post_save signal?

2011-02-07 Thread creecode


On Feb 7, 6:38 am, Joel Goldstick  wrote:

> can you use the http request object:
>
> http://docs.djangoproject.com/en/dev/ref/request-response/#quick-over...

I think the problem there is that the HttpRequest object isn't
available by default to the post_save signal.

Some of the ways you might get access to the ip...

Add an ip field to your model and then when processing the POST in
your view attach the ip to your instance then save.  I used this
method myself for a discussion model that tracks the ip of the poster.

If you don't want to store the ip you might try ( untested )
attaching the ip as an attribute to the model instance similar to
above and see if the attribute survives to the post_save signal.

You could also try something similar to the above with the
instance save method but then you wouldn't be handling it at
post_save.

You could also create your own signal system for use when
processing the POST in your view that handles your ip address needs.

It all depends on what you want to do with the ip address.  If you let
us know more about what of your situation we might be able to give
your more ideas.

Toodle-loo
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: How can I show a list of values in a text input field?

2011-02-07 Thread Bill Freeman
On Sun, Feb 6, 2011 at 4:25 PM, Nate Reed  wrote:
> I posted this question on StackOverflow, too.  I have defined a Model
> with a ManyToManyField, and I want the field to show the values joined
> by spaces, for example:
>
> 
>
> I have defined the form to use CharField to represent the multiple values:
>
> class MyForm(ModelForm):
>    foo = CharField(label='Foo')
>    class Meta:
>        model = MyModel
>
> Instead of showing the values separated by spaces, the input field
> shows this instead:
>
> [u'val1', u'val2', u'val3']
>
> How can I override this behavior?  My understanding is that widgets
> are responsible for rendering the input.  Is there an example of a
> custom widget that does something like this?
>
> Nate
>

You have a related problem in terms of what you want to have happen
when the form is submitted.  The string that you get needs to be
converted to objects (or their id's) before you can save them to the
DB, and a representation of the id probably isn't what you're expecting
to show in the field.

CharField is mostly suitable for submitting a character string, typically
stored in the DB as a character string.  Relation fields are more amenable
to a (multi-)select field or radio buttons (check boxes for multiple valued
fields).

You could create a custom form field, if this scheme is truly what you
wish.

You can also render the desired input within your form by hand, instead
of expecting the from object's as_p(), etc. to render it for you.  You will
then also need to check the submitted value in the POST or GET data,
since the form object doesn't know about it.  The template language is
strong enough to render what you want if you pass the related object
manager to the template, but it is a bit hairy for a template, so I'd
suggest having your view function calculate the desire value string
for the input, and pass that instead.  When you parse the posted
value, you will still need to look up the objects somehow from the
submitted value.

Bill

-- 
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: Amazing work

2011-02-07 Thread Jon J
Cal,

You are so right. I've always taken it as a rule of thumb that the
bigger a corporation is, the bigger and bloated their software is.
It's gotten to the point where I won't touch jobs with a ten foot pole
whose companies are built upon Microsoft products.

On Sun, Feb 6, 2011 at 1:54 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Interesting. See, when I compared Zope to Django, I found Django's extensive
> documentation and feature set to be perfect for prototyping, and then
> optimizing bottlenecks at a later date, either via C extensions, raw SQL
> replacement etc. However, as 'cliché' as this may sound, most large
> enterprises tend to steer towards the most complicated, most bloated, most
> difficult to use "technologies" there are around. Take Microsoft CRM, Java
> and *anything* RHEL based as a clear example (others may disagree, this is
> just my opinion as I'm a hard headed debian/python guy ;p)
> (the above is just my
>
> On Sun, Feb 6, 2011 at 1:21 PM, Mike Seidle  wrote:
>>
>> On Thursday, February 03, 2011 08:02:43 pm Cal Leeming [Simplicity Media
>> Ltd]
>> wrote:
>> > May I ask, how well did you get along with Zope? From what I can tell,
>> > Django is suited for SME, where as Zope is the kinda thing that banks
>> > would
>> > be using etc.
>>
>> Cal -
>>
>> I just used Django to write a credit card processing application (as in
>> internet gateway w/API for third party sites).  Zope would have simply
>> been
>> way to heavy to handle the transaction load, and frankly, most financial
>> applications fit the RDBMS model much better than the object database
>> model.
>>
>> On the SME/Enterprise statement: Just because a software package is not
>> complicated does not mean that it does not fit in the enterprise space.
>>  I've
>> found that often the more simple a tool is the *better it fits* in large
>> organizations.
>>
>> Mike
>>
>> --
>> 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: Is there any way to get the ip address of the user in the post_save signal?

2011-02-07 Thread Joel Goldstick
On Mon, Feb 7, 2011 at 8:43 AM, Stodge  wrote:

> Is there any way to get the ip address of the user in the post_save signal?
> 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.
>

can you use the http request object:

http://docs.djangoproject.com/en/dev/ref/request-response/#quick-overview

-- 
Joel Goldstick

-- 
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: cannot login to admin site using admin credentials

2011-02-07 Thread Chris Lawlor
Try running 'python manage.py createsuperuser' on your production
server to create a new superuser account. You should have full
privileges to log in to the admin and make changes using this account.

On Feb 7, 8:15 am, xpanta  wrote:
> Hi,
>
> it seems that my problem is a bit complicated. I have tried much but
> to no avail. So, please help me!
>
> Some time ago I migrated to postgresql from mysql. I don't know if I
> did something wrong. Anyway, my webapp works "almost" flawlessly.
>
> Since then I never needed to login using admin rights (either using
> the admin panel or my web site). Some weeks ago I tried and I noticed
> that I can't login (to both admin site and web page) using admin
> credentials.
>
> I have tried dozens of various tricks but I still can't login.
>
> I tried adding user.set_password()  to my views.py in order to replace
> admin password with a new simpler one ('123') but nothing. I even
> registered a new user from my web page and changed its fields directly
> in the DB (is_staff, is_active, is_superuser) to 'True'. This let me
> login to the admin site but gave me no permission to change anything.
> I even tried to create various admin users with the help of django
> shell but none of them gives me a login. Interestingly whenever I do
> something to change admin password, I always see a different hashed
> password value in my DB. This means that all my approaches succeed in
> changing the admin password. However I can't login.
>
> Normal users work fine. Problem appears only when the user is an
> administrator.
>
> Any help would be greatly 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.



Is there any way to get the ip address of the user in the post_save signal?

2011-02-07 Thread Stodge
Is there any way to get the ip address of the user in the post_save signal? 
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: How to know if is a update or insert??

2011-02-07 Thread andmart
Marc,

I found a reference in docs.

http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#modeladmin-methods


On Feb 6, 2:00 pm, Marc Aymerich  wrote:
> On Sun, Feb 6, 2011 at 2:53 PM, andmart  wrote:
> > In a insert or in a update, the pk is already filled in
> > ModelAdmin.save_model.
>
> > The creation of object in database is in ModelForm.save.
>
> > So, I think it's not the way to handle it.
>
> > I notivced googling there is a boolean parameter named change and I'm
> > using it.
>
> Hi andmart,
> Do you have more information about this boolean parameter? do you have
> the link to the website where you find it?
> what you comment seems quite useful :)
>
> --
> Marc

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



Is there a way to know which user changed a particular model through the admin site?

2011-02-07 Thread Stodge
I need to know who changed a particular model through the admin site so I 
can create a log entry. The post_save signal has no knowledge of the user 
that changed the model and overriding the model's save method won't tell me 
the user either. Is there a way to know which user changed a particular 
model through the admin site? 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: How to define each model in its own file

2011-02-07 Thread Alendit
Hi,

as far as i know you also have to define the app_label as Meta
parameter like this

class Meta:
app_label = "your_app_name"

Regards,

Alendit.

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



cannot login to admin site using admin credentials

2011-02-07 Thread xpanta
Hi,

it seems that my problem is a bit complicated. I have tried much but
to no avail. So, please help me!

Some time ago I migrated to postgresql from mysql. I don't know if I
did something wrong. Anyway, my webapp works "almost" flawlessly.

Since then I never needed to login using admin rights (either using
the admin panel or my web site). Some weeks ago I tried and I noticed
that I can't login (to both admin site and web page) using admin
credentials.

I have tried dozens of various tricks but I still can't login.

I tried adding user.set_password()  to my views.py in order to replace
admin password with a new simpler one ('123') but nothing. I even
registered a new user from my web page and changed its fields directly
in the DB (is_staff, is_active, is_superuser) to 'True'. This let me
login to the admin site but gave me no permission to change anything.
I even tried to create various admin users with the help of django
shell but none of them gives me a login. Interestingly whenever I do
something to change admin password, I always see a different hashed
password value in my DB. This means that all my approaches succeed in
changing the admin password. However I can't login.

Normal users work fine. Problem appears only when the user is an
administrator.

Any help would be greatly 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.



BDD test scenario localisation

2011-02-07 Thread Sultan Imanhodjaev
Hello,

I was wondering if there any way to localise BDD test according to
project requirement is there any issue?




Sultan

-- 
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 define each model in its own file

2011-02-07 Thread Sultan Imanhodjaev
It is also possible to import you models from *models/** from within *
models.py* file.

On Sun, Feb 6, 2011 at 8:02 PM, Mark (Nosrednakram)
wrote:

> If there isn't anything in your models/__init__.py nothing will get
> loaded.  You might try somthing like the following in your models/
> __init__.py:
>
> from app.models import modelname
> from app.models import anothermodelname
>
> Where modlenames are actually individual files with model definitions.
>
> Sorry not in a position to test but believe this should work.
>
> Mark
>
> On Feb 6, 5:39 am, "h@ck5t0ck"  wrote:
> > Hi Guys,
> > Am very new to django and am working on a relatively large web
> > application which includes over 15 models.
> > Now I want to define each model in its own file and store them in a
> > folder called models, so I first created the folder "models" and
> > created a file "__init__.py" in that folder and defined each model in
> > a separate file but its not working.
> > Any help on 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.
>
>


-- 
Kind regards,
Sultan Imanhodjaev

-- 
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: population of *.html fields from Django

2011-02-07 Thread Sam Lai
On 7 February 2011 03:34, gintare  wrote:
> I would like to use only plain html field names
> Reading them is not a problem with request in views.
> How to populate html document back ?
>
>
> I have *.html with lines:
>
>
>   textarea>
>  
>  
>
> #in views.py
> item = request.POST.get('cbnWw','')
> #do smth with item
> #now i would like to return item back to html.
> #Normally i should use {{ }} for variable output.
> #IS IT POSSIBLE TO USE HTML SYNTAX  and populate textarea and
> checkboxes
>
>  return render_to_response('x.html',{ 'LangFROMt', 'EN'}, 
>
>
> ?

Nope, because Django's templating system doesn't know anything about
the template's structure/syntax. The templating system can be used for
more than just HTML (e.g. JSON, XML, CSV etc.).

What's wrong with using the {{ }} templating syntax? The alternative
you're suggesting makes things very confusing - the template will be
getting values from two different places, and what happens if there is
more than one form in the template with the same field name?

> regards,
> gintare
>
> --
> 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.