Re: How to create a app inside a app

2012-07-21 Thread Russell Keith-Magee
On Sat, Jul 21, 2012 at 8:46 PM, Melvyn Sopacua  wrote:
> On 21-7-2012 3:26, Russell Keith-Magee wrote:
>> On Sat, Jul 21, 2012 at 3:32 AM, Nicolas Ardison  
>> wrote:
>>> Hello, i was reading the Django documentation, and i have the following
>>> trouble that i'm not sure if django can solve it. I have a application
>>> called "userArea" and i want to extend that app with more app isolated from
>>> the "main" apps.
>>>
>>> [DjangoProject]
>>>
>>> [APP1]
>>>
>>> [subAPP1]
>>>
>>> [subAPP2]
>>>
>>> [APP2]
>>>
>>>
>>> Could i do something like this? anyone know where i can start reading about
>>> this.
>>
>> A Django app is just a Python module. That means you can nest them
>> however you like. As long as you provide a fully qualified path the
>> the leaf node of your nesting tree, you can use an app wherever it
>> occurs in your Python module namespace.
>>
>> However, you don't get any Django benefits out of nesting like this. A
>> Django app is a single module. Nesting a module inside another doesn't
>> mean that the Django app 'inherits' anything from its 'parent', or
>> anything like that. The only benefit would be organisational -- i.e.,
>> keeping all the code in a hierarchy so it's easier to find it later.
>
> Well, this isn't completely true. As I said in earlier mail, you need
> unique final part for INSTALLED_APPS.
> Secondly, you can't organize models as you wish, meaning you can't do:
> app/
> models/
>__init__.py
>mymodel.py

erm... Yes, you can. The Django test suite contains an explicit
example of how this can be done. See the modeltests/model_package
tests.

Pro tip: You need to look into the "app_label" Meta argument [1].

[1] 
https://docs.djangoproject.com/en/dev/ref/models/options/#django.db.models.Options.app_label

So - again -- you *don't* get any benefits from Django from nesting an
app inside another app. Yes, the last part of the app module name
needs to be unique in your project, but otherwise, it doesn't matter
how deeply you nest your app modules -- an app is an app.

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.



Re: sqlite to mysql loaddata not working (using natural keys)

2012-07-21 Thread Karen Tracey
On Fri, Jul 20, 2012 at 2:57 PM, dack  wrote:

> I'm trying to move django data from an sqlite database to a mysql
> database. I know I need to use natural keys, but it's still failing. Any
> ideas?
>
> Here's my procedure. The default database is sqlite, the mysql database is
> called "mysql" in settings.py.
>
> $*./manage.py dumpdata -a -n > data.json*
> $*./manage.py flush --database=mysql*
> You have requested a flush of the database.
> This will IRREVERSIBLY DESTROY all data currently in the 'django' database,
> and return each table to the state it was in after syncdb.
> Are you sure you want to do this?
>
> Type 'yes' to continue, or 'no' to cancel: yes
>
> You just installed Django's auth system, which means you don't have any
> superusers defined.
> Would you like to create one now? (yes/no): no
> Installed 0 object(s) from 0 fixture(s)
> *Note - if I examine the mysql database at this point, the tables all
> exist and contain 0 rows (as I expected)*
> $*./manage.py loaddata --database=mysql ./data.json*
> Problem installing fixture './data.json': Traceback (most recent call
> last):
>   File
> "/usr/local/lib/python2.6/site-packages/django/core/management/commands/loaddata.py",
> line 196, in handle
> obj.save(using=using)
>   File
> "/usr/local/lib/python2.6/site-packages/django/core/serializers/base.py",
> line 165, in save
> models.Model.save_base(self.object, using=using, raw=True)
>   File "/usr/local/lib/python2.6/site-packages/django/db/models/base.py",
> line 565, in save_base
> created=(not record_exists), raw=raw, using=using)
>   File
> "/usr/local/lib/python2.6/site-packages/django/dispatch/dispatcher.py",
> line 172, in send
> response = receiver(signal=self, sender=sender, **named)
>   File "/genpool0/db/foo/intranet/../intranet/userprofile/models.py", line
> 22, in create_user_profile
> UserProfile.objects.create(user=instance)
>

You've got app code running here that is forcing creation of a UserProfile
when the user is loaded. Likely these UserProfile objects are also being
loaded from the fixture, so the attempt to create them is generating the
"user_id" is not unique error.

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

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



Re: Extending a app with other app

2012-07-21 Thread Karen Tracey
On Fri, Jul 20, 2012 at 1:58 PM, Nicolas Ardison wrote:

> Does anybody knows how to create a "app" inside a "app"?


This request is unclear, perhaps if you put a few more words around this
describing what you actually want to do someone could help. It doesn't make
any sense in Django to say you want an app inside an app.

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

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



Re: How to present a calculated field in a admin edit form.

2012-07-21 Thread Karen Tracey
On Mon, Jul 16, 2012 at 3:45 AM, Erlend Dalen wrote:

> I'm using Django 1.0 (beta_1) and have the following issue:
> I have a method in a model that returns a calculated value and I would
> like this value to be displayed in the admin edit form related to that view.
> I have no problem showing the field in the list_display, but if I add it
> to fields in the fields property in the ModelAdmin, I get an error message
> saying that there is no such key.
>
> Is there an easy way of solving this?
>

You can do this with readonly_fields in admin:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields

You'll need to upgrade from that ancient level of Django though,
readonly_fields were introduced in 1.2.

Karen

-- 
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: Newbie -- issue with psycoppg2

2012-07-21 Thread Thomas Lockhart

On 12-07-21 3:57 AM, Quincy Kwende wrote:

create a database using PostgreSQL

Try googling "create a database using PostgreSQL"

The first hit is the chapter you want in the Postgres docs.

hth

   - Tom

--
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_add TabularInline ?

2012-07-21 Thread Nicolas Emiliani
Hi,

so.. I have a TabularInline admin view that displays '+ Add another' and I
would
like to remove it, like can_delete = False but for the add option. sadly
can_add
doesn't exist, so how do I achieve this ?

Thanks!

-- 
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

-- 
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 an error: FATAL: Peer authentication failed for user "test"

2012-07-21 Thread Sylar
Hello everyone-

So I'm completely new to Django and I'm using this tutorial:
http://www.programmersbook.com/page/21/Django-Beginner-Tutorial-Part-I/. 
For the past two days I have the exact same error(stuck at step 7.):

sudo python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 443, in execute_from_command_line
utility.execute()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 232, in execute
output = self.handle(*args, **options)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 371, in handle
return self.handle_noargs(**options)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py",
 
line 57, in handle_noargs
cursor = connection.cursor()
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", 
line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py",
 
line 177, in _cursor
self.connection = Database.connect(**conn_params)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, 
in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL:  Peer authentication failed for user 
"test"

I'm going insane, please help me!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/XGak6mjKr2QJ.
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:psycopg2.OperationalError: FATAL: Peer authentication failed for user "test"

2012-07-21 Thread Juraj Malenica
Hello-

So, I'm a total newbie in Django, and I'm using this tutorial:
http://www.programmersbook.com/page/21/Django-Beginner-Tutorial-Part-I/. I 
got stuck at the 7.th step.

My error is this(I'm a xubuntu user):
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 443, in execute_from_command_line
utility.execute()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 232, in execute
output = self.handle(*args, **options)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 371, in handle
return self.handle_noargs(**options)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py",
 
line 57, in handle_noargs
cursor = connection.cursor()
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", 
line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py",
 
line 177, in _cursor
self.connection = Database.connect(**conn_params)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, 
in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL:  Peer authentication failed for user 
"test"


I found this thread, but it didn't really help me. 
https://groups.google.com/forum/?fromgroups#!topic/django-users/kVpz4Xsmg_E

Please help!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ET-FJTa3Bz0J.
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.



Newbie -- issue with psycoppg2

2012-07-21 Thread Quincy Kwende

Hello,

I get the bug on the attached file. I don't know how to create a database 
using PostgreSQL. 

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

<>

Using PostgreSQL

2012-07-21 Thread Quincy Kwende
Hello,
I just install Python, Django and psycopg2 on Windows and I am trying to do 
the tutorials on the official documentation.

How do I create a database or how do I switch to the database's interactive 
prompt ?

I have been using git bash to install some features and start the server.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/OVyPlgvI9yoJ.
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: Pip type error.

2012-07-21 Thread Jauharul Fuady


On Sunday, 11 March 2012 15:17:59 UTC+7, John W. wrote:
>
> I know it's weird to reply to myself, but just in case that somebody has 
> the same problem. 
>
> It seems that the problem it is in the requirements.txt, i created it 
> using powershell and "pip.exe freeze > requirements.txt" command,
> which creates a file with a name that has nullbytes in it. 
> I was able to get around this problem by downloading a requirements.txt 
> from an example project on github and modifying it.
> That did the job and everything works nice.
>
>  
Thank you for posting it. It helps me.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YA6B_MXuw9YJ.
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: Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-07-21 Thread Javi Romero
I'm in :D

El sábado, 30 de junio de 2012 17:10:27 UTC+2, Cal Leeming [Simplicity 
Media Ltd] escribió:
>
> Hi all,
>
> As some of you know, I did a live webcast last year (July 2011) on our LLG 
> project, which explained how we overcome some of the problems associated 
> with large data processing.
>
> After reviewing the video, I found that the sound quality was very 
> poor, the slides weren't very well structured, and some of the information 
> is now out of date (at the time it was 40mil rows, now we're dealing with 
> 700+mil rows).
>
> Therefore, I'm considering doing another live webcast (except this time 
> it'll be recorded+posted the next day, the stream will be available in 
> 1080p, it'll be far better structured, and will only last 50 minutes).
>
> The topics I'd like to cover are:
>
> * Bulk data processing where bulk_insert() is still not viable (we went 
> from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still 
> using the ORM - no raw sql here!!)
> * Applying faux child/parent relationship when standard ORM is too 
> expensive (allows for ORM approach without the cost)
> * Applying faux ORM read-only structure to legacy applications (allows ORM 
> usage on schemas that weren't properly designed, and cannot be changed - 
> for example, vendor software with no source code).
> * New Relic is beautiful, but expensive. Hear more about our plans to make 
> an open source version.
> * Appropriate use cases for IAAS vs colo with SSDs.
> * Percona is amazing, some of the tips/tricks we've learned over.
>
> If you'd like to see this happen, please leave a reply in the thread - if 
> enough people want this, then we'll do public vote for the scheduled date.
>
> Cheers
>
> Cal
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UFoiTSkA3zEJ.
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: Set two fields to the same value

2012-07-21 Thread Melvyn Sopacua
On 12-7-2012 15:51, Jaroslav Dobrek wrote:

> Users may create Test objects in order to run their own tests. A test 
> always starts at some date time and it always ends at some date time. Each 
> test has a time which is increased until it equals the end time. When a 
> user creates a new test (and before he uses it) the field time should have 
> the same value as the field start_time.

(Assuming the time field should be stored in the database)

Simplest, but specific for temporal fields:
class Test(models.Model) :
start_time = models.DateTimeField(auto_now_add=True)
end_time = models.DateTimeField(auto_now_add=True)
time = models.DateTimeField(auto_now_add=True)

Generally working:
class Test(models.Model) :
first = models.CharField(max_length=10, default='first')
second = models.CharField(max_length=10)

def __init__(self, *args, **kwargs) :
first = kwargs.get('first', False)
if not first :
first = self.__class__.first.default
second = first
if not kwargs.get('second', False) :
kwargs['second'] = second
super(Test, self).__init__(*args, **kwargs)

For the admin, see

for an alternate solution.
-- 
Melvyn Sopacua


-- 
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 create a app inside a app

2012-07-21 Thread Melvyn Sopacua
On 21-7-2012 3:26, Russell Keith-Magee wrote:
> On Sat, Jul 21, 2012 at 3:32 AM, Nicolas Ardison  
> wrote:
>> Hello, i was reading the Django documentation, and i have the following
>> trouble that i'm not sure if django can solve it. I have a application
>> called "userArea" and i want to extend that app with more app isolated from
>> the "main" apps.
>>
>> [DjangoProject]
>>
>> [APP1]
>>
>> [subAPP1]
>>
>> [subAPP2]
>>
>> [APP2]
>>
>>
>> Could i do something like this? anyone know where i can start reading about
>> this.
> 
> A Django app is just a Python module. That means you can nest them
> however you like. As long as you provide a fully qualified path the
> the leaf node of your nesting tree, you can use an app wherever it
> occurs in your Python module namespace.
> 
> However, you don't get any Django benefits out of nesting like this. A
> Django app is a single module. Nesting a module inside another doesn't
> mean that the Django app 'inherits' anything from its 'parent', or
> anything like that. The only benefit would be organisational -- i.e.,
> keeping all the code in a hierarchy so it's easier to find it later.

Well, this isn't completely true. As I said in earlier mail, you need
unique final part for INSTALLED_APPS.
Secondly, you can't organize models as you wish, meaning you can't do:
app/
models/
   __init__.py
   mymodel.py

The model registry can't deal with it and lots of assumptions are done
in the code based on the fact that models are in a file called models.py
inside the application directory. I tried organizing models differently
like above and manually populating the application registry with them,
but I never could get it to work completely because of code like this:
./core/management/sql.py:
app_dir = os.path.normpath(os.path.join(os.path.dirname(
models.get_app(model._meta.app_label).__file__), 'sql'))

For this reason it was more beneficial to use sub applications when
models.py grew rather big as no additional code was needed to populate
the app registry and things just work out of the box at a small cost of
having to register multiple apps in INSTALLED_APPS.
-- 
Melvyn Sopacua


-- 
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: Passing a dict to default page_not_found view

2012-07-21 Thread Russell Keith-Magee
On Sat, Jul 21, 2012 at 7:44 PM, Masud Khokhar  wrote:
> Hi Russell,
>
> Many thanks for your reply. The template tag approach looks good and I will
> try to use this one.
>
> One further question. If I am using the @register.simple_tag decorator, can
> I create the view in the views.py file or do I have to create a templatetags
> directory and follow the full procedure of creating a tag?

Yes, you need to create a directory named templatetags, and put your
tag library in a module inside that directory. When Django looks
parses your template and find the {% load mytaglibrary %} declaration
(which is what tells it to load the tag) it looks for a directory
named templatetag in each of apps in your project. If you don't put
your tag in the right place, Django won't be able to find your custom
tag.

> Sorry if this sounds all basic but I am quite new to this.

No worries -- everyone has to start somewhere :-)

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.



Re: Passing a dict to default page_not_found view

2012-07-21 Thread Masud Khokhar
Hi Russell,

Many thanks for your reply. The template tag approach looks good and I will
try to use this one.

One further question. If I am using the @register.simple_tag decorator, can
I create the view in the views.py file or do I have to create a
templatetags directory and follow the full procedure of creating a tag?

Sorry if this sounds all basic but I am quite new to this.

Thanks a lot in advance.

Best wishes,
Masud

On 21 July 2012 08:52, Russell Keith-Magee  wrote:

> On Sat, Jul 21, 2012 at 10:09 AM, Masud Khokhar 
> wrote:
> > Hi all,
> >
> > I am using the default 404 view that Django uses. I have created a
> custom 404.html page in my templates directory which automatically gets
> loaded. Is it possible for this page to load a python dictionary or do I
> need to raise http404 myself for that?
> >
> > In essence, what I am trying to do is load a random message in the
> 404.html. There may be a simpler solution for that.
>
> There sure is: Use a template tag instead.
>
>
> https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#simple-tags
>
> If your custom template tag makes the random call, you don't need to
> put randomly selected text or a randomly selected value into the
> template context.
>
> The template context for the 404 page isn't something that's
> configurable by default, so if you *did* want to go down that path,
> you'd have to write your own 404 view, and set that as your 404
> handler. This isn't especially difficult to do, but the template tag
> approach will be simpler :-)
>
> 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.
>
>

-- 
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: Validation error with formwizard and formset

2012-07-21 Thread Rob
The validation error i got was due to a custom view i wrote, and had 
nothing todo my my template etc etc. I switched back to the default example 
view provided by the Django site, and everything works.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/PKfhYSifpAkJ.
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.



Validation error with formwizard and formset

2012-07-21 Thread Rob
I have a basic formwizard example from the Django 1.4 documentation:
https://docs.djangoproject.com/en/1.4/ref/contrib/formtools/form-wizard/

When I replace the forms with a modelform and a formset i keep getting 
validation errors: 
(ManagementForm data is missing or has been tampered with)

The documentation says:
WizardView supports 
*ModelForms*and 
*ModelFormSets*.
 
Additionally to 
initial_dict,
 
the as_view() method takes an instance_dict argument that should contain 
instances of ModelForm and ModelFormSet. Similarly to 
initial_dict,
 
these dictionary key values should be equal to the step number in the form 
list.

Could anybody provide me with an example? Does the validation error have 
something to do with the instance_dict?

Let say i have these forms:
class Address(models.Model):
street = models.CharField(max_length=20)

class AddressForm(ModelForm):
class Meta:
model = Address

class OrderForm(forms.Form):
Order = forms.ModelChoiceField(queryset=Article.objects.all())

OrderFormset = modelformset_factory(Order)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hCBZxvtz1HYJ.
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.



Child-friendly blogging app

2012-07-21 Thread Lie Ryan
Hi, I'm creating a website that allows registered users (which are not 
is_staff) to write journals (text, images, sound, video, and uploaded 
files), and write comments to other's journals. The journals and 
comments have to be moderated by a different class of users (the 
moderators) before they appear anywhere (not all moderators are 
is_staff). The content editor used must be very simple and easy to use 
because the users will be primarily children and teenagers (8-years and 
up), and not all moderators will be technically knowledgeable (they are 
teachers). Each user (children and moderator) are associated with a 
"circle" and can only view and post contents within their own "circle" 
(only is_staff user can publish content for site-wide publication). And 
since some "circles" do not want to participate in this blogging 
functionality, the whole journalling feature will be disabled for them.


Given these requirements, if you have any personal experiences with 
using the existing blogging/CMS apps, can you recommend some existing 
blog/CMS engine that will suit the requirement? Being easy to integrate 
with other apps is a big plus (e.g. features like Django-CMS's Placeholder).


Easy-to-use content editor is a must, we do not want children to need to 
learn markups or become confused when trying to use special characters, 
e.g. <, >, &, but we do want basic formatting (also, some of the older 
teenagers might know some funny stuffs like XSS, so good security is a 
big plus).


--
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: Passing a dict to default page_not_found view

2012-07-21 Thread Russell Keith-Magee
On Sat, Jul 21, 2012 at 10:09 AM, Masud Khokhar  wrote:
> Hi all,
>
> I am using the default 404 view that Django uses. I have created a custom 
> 404.html page in my templates directory which automatically gets loaded. Is 
> it possible for this page to load a python dictionary or do I need to raise 
> http404 myself for that?
>
> In essence, what I am trying to do is load a random message in the 404.html. 
> There may be a simpler solution for that.

There sure is: Use a template tag instead.

https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#simple-tags

If your custom template tag makes the random call, you don't need to
put randomly selected text or a randomly selected value into the
template context.

The template context for the 404 page isn't something that's
configurable by default, so if you *did* want to go down that path,
you'd have to write your own 404 view, and set that as your 404
handler. This isn't especially difficult to do, but the template tag
approach will be simpler :-)

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.