Where admin classes should be registered ?

2012-06-27 Thread Alireza Savand
Hi
Common way to create [model|admin] classes is implement and create them in 
[models|admin].py file.
But as standard non-django way is to create a python package named admin 
for AdminClass es and  create a file for each admin class.
But i couldn't find any standard way to register those admin classes, i 
mean should i register them in admin/__init__.py or register each class in 
it own file then import them at admin/__init__.py ?
Sometimes when i register all of them at admin/__init__.py it's happening 
that classes will initialed multiple times and i don't know the reason.
I'm just looking for common or standard way to do it.

Thanks.

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

2012-06-27 Thread Michael Waterfall
When running Django with Gunicorn with multiple processes/workers I'm 
getting a deadlock issue with some of my manual MySQL database transactions.

DatabaseError(1205, 'Lock wait timeout exceeded; try restarting 
transaction')

My setup uses multiple databases, and my function needs to be passed the 
database to use when it's called. For this reason, I can't use the standard 
[Django transaction 
decorators](https://docs.djangoproject.com/en/1.4/topics/db/transactions/) 
as the db needs to be hard-coded as an argument. I've inspected the 
decorator code to look at how transactions are managed, and my function 
looks like this:

from django.db import connections

def process(self, db, data):

# Takeover transaction management
connections[db].enter_transaction_management(True)
connections[db].managed(True)

# Process
try:
# do things with my_objects...
for obj in my_objects:
obj.save(using=db)
connections[db].commit()
except Exception as e:
connections[db].rollback()
finally:
connections[db].leave_transaction_management()

Can anyone spot what may be going wrong here?

-- 
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/-/o4j00SlcSNwJ.
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't get date formatting right

2012-06-27 Thread Benedict Verheyen
Hi,

I'm still struggling with getting dates formatted correctly without formatting 
them myself.
I went over all docs again, still, I must be doing something wrong.

I want to use the built in Django system that formats the date according to the 
locale.
I try this on a Debian Linux Squeeze, locale output is this:
# locale
LANG=nl_BE.UTF-8
LANGUAGE=
LC_CTYPE="nl_BE.UTF-8"
LC_NUMERIC="nl_BE.UTF-8"
LC_TIME="nl_BE.UTF-8"
LC_COLLATE="nl_BE.UTF-8"
LC_MONETARY="nl_BE.UTF-8"
LC_MESSAGES="nl_BE.UTF-8"
LC_PAPER="nl_BE.UTF-8"
LC_NAME="nl_BE.UTF-8"
LC_ADDRESS="nl_BE.UTF-8"
LC_TELEPHONE="nl_BE.UTF-8"
LC_MEASUREMENT="nl_BE.UTF-8"
LC_IDENTIFICATION="nl_BE.UTF-8"
LC_ALL=

I want to use Belgian/Dutch date formatting. I plan to use 3 languages for the 
time being yet
the translation files aren't there yet.
Next, my settings.py
...
TIME_ZONE = 'Europe/Brussels'
ugettext = lambda s: s
LANGUAGES = (
('nl', ugettext('Dutch')),
('fr', ugettext('French')),
('en', ugettext('English')),
)
DEFAULT_LANGUAGE = 1
LANGUAGE_CODE = "nl_BE"
USE_I18N = True
USE_L10N = True
USE_TZ = True
...

In my template, i load I18N and L10N

{% load i18n %}
{% load l10n %}

and I even specifically say to localize the date in my template:
{{form.day_of_birth|localize}}

The form class used to display the info:

class MyForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
class Meta:
model = MyTest
fields = ('name', 'day_of_birth')
# Added this line to try and force the localization
day_of_birth = forms.DateTimeField(localize=True)

Yet, I only see a date like this 2012-04-01 and not like 01/04/2011.
Also, I can't enter a date like 01/04/2011 but it does accept 2012-04-01

What am I doing wrong. I used to solve this in the past by filtering the date 
with a tag
but I really want to do it right and make use of the built-in features.

Can anybody shed some light on this please?

Cheers,
Benedict

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



Re: Can't get date formatting right

2012-06-27 Thread Benedict Verheyen
On 27/06/2012 10:42, Benedict Verheyen wrote:
> Hi,
> 
> I'm still struggling with getting dates formatted correctly without 
> formatting them myself.
> I went over all docs again, still, I must be doing something wrong.
> 
> I want to use the built in Django system that formats the date according to 
> the locale.
> I try this on a Debian Linux Squeeze, locale output is this:
> # locale
> LANG=nl_BE.UTF-8
> LANGUAGE=
> LC_CTYPE="nl_BE.UTF-8"
> LC_NUMERIC="nl_BE.UTF-8"
> LC_TIME="nl_BE.UTF-8"
> LC_COLLATE="nl_BE.UTF-8"
> LC_MONETARY="nl_BE.UTF-8"
> LC_MESSAGES="nl_BE.UTF-8"
> LC_PAPER="nl_BE.UTF-8"
> LC_NAME="nl_BE.UTF-8"
> LC_ADDRESS="nl_BE.UTF-8"
> LC_TELEPHONE="nl_BE.UTF-8"
> LC_MEASUREMENT="nl_BE.UTF-8"
> LC_IDENTIFICATION="nl_BE.UTF-8"
> LC_ALL=
> 
> I want to use Belgian/Dutch date formatting. I plan to use 3 languages for 
> the time being yet
> the translation files aren't there yet.
> Next, my settings.py
> ...
> TIME_ZONE = 'Europe/Brussels'
> ugettext = lambda s: s
> LANGUAGES = (
> ('nl', ugettext('Dutch')),
> ('fr', ugettext('French')),
> ('en', ugettext('English')),
> )
> DEFAULT_LANGUAGE = 1
> LANGUAGE_CODE = "nl_BE"
> USE_I18N = True
> USE_L10N = True
> USE_TZ = True
> ...
> 
> In my template, i load I18N and L10N
> 
> {% load i18n %}
> {% load l10n %}
> 
> and I even specifically say to localize the date in my template:
> {{form.day_of_birth|localize}}
> 
> The form class used to display the info:
> 
> class MyForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
> super(MyForm, self).__init__(*args, **kwargs)
> class Meta:
> model = MyTest
> fields = ('name', 'day_of_birth')
> # Added this line to try and force the localization
> day_of_birth = forms.DateTimeField(localize=True)
> 
> Yet, I only see a date like this 2012-04-01 and not like 01/04/2011.
> Also, I can't enter a date like 01/04/2011 but it does accept 2012-04-01
> 
> What am I doing wrong. I used to solve this in the past by filtering the date 
> with a tag
> but I really want to do it right and make use of the built-in features.
> 
> Can anybody shed some light on this please?
> 
> Cheers,
> Benedict
> 

I found a bug where there was a reference too 
translation.activate(settings.LANGUAGE_CODE)
I tried this as the first line of code in the view, and then my date is 
formatted correcly
and a date of format dd/mm/yy is accepted.
Is it necessary to add the translation line or is there another way?
Also, what if the language changes, will that line still work as it gets the 
language code
from the settings, and not the currently active code.

Cheers,
Benedict

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



Using subclass of RegexValidator for form field

2012-06-27 Thread Darren Spruell
Django 1.3.1
Python 2.7.1

I'm attempting to subclass RegexValidator in my app's validators.py to
supply specific 'regex' and 'message' attributes and finding that the
field validation I'm attempting does not work. I figure I don't quite
understand how to subclass this validator correctly, or else how to
implement it as a callable for the 'validators' parameter:


# app_name/validators.py
from django.core.validators import RegexValidator

class PayloadValidator(RegexValidator):
regex = 'x'
message = u'Valid payload strings contain the letter "x"'


# app_name/models.py
from app_name import validators

class Configuration(models.Model):
payload = models.CharField(max_length=64, help_text="Text string
to match in health check signature",
validators=[validators.PayloadValidator])
...


But when I submit the form, the Configuration instance validates and
saves if I enter 'abc' as a value.

The following use of URLValidator in my models appears to work
correctly, and I had figured I used these validators in the same
manner:

reference_url = models.URLField(verbose_name="reference URL",
blank=True, help_text="(Optional) Reference URL",
validators=[URLValidator])


Here, entering "foo" into the field for reference_url outputs a
validation error on the form if I enter "foo".

What am I missing? Thanks.

-- 
Darren Spruell
phatbuck...@gmail.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: Can't get date formatting right

2012-06-27 Thread Benedict Verheyen
On 27/06/2012 11:07, Benedict Verheyen wrote:

>>
> 
> I found a bug where there was a reference too 
> translation.activate(settings.LANGUAGE_CODE)
> I tried this as the first line of code in the view, and then my date is 
> formatted correcly
> and a date of format dd/mm/yy is accepted.
> Is it necessary to add the translation line or is there another way?
> Also, what if the language changes, will that line still work as it gets the 
> language code
> from the settings, and not the currently active code.
> 
> Cheers,
> Benedict
> 


I added this to the view to test some more

check_for_language("nl")
activate("nl")

and then the dates are formatted correctly and they accept the input as they 
should.
By checking LANGUAGE_CODE in my template, I can even make the jquery datepicker 
do the right thing.

Still, how come that this doesn't work before I activate the language myself?
I specified a DEFAULT_LANGUAGE and LANGUAGE_CODE in my settings, yet it only 
accepts the
belgian/dutch dates after I activate the language manually.

Isn't the default language as specified in the settings activated by default?

Regards,
Benedict

-- 
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: admin page doesn't auto-refresh

2012-06-27 Thread Matt Schinckel
I've found that this is a fairly common situation. For instance, Location 
has an FK to Company,
and then ManyToMany to StaffMember. But, only StaffMembers that have their 
FK set to
the same Company should be selectable in their inline.

This need not just be a ManyToMany thing, either. The Manager of a Location 
should also
be a StaffMember, but may only be one who is associated with the same 
Company.

This is one example: another, perhaps more common one, is Country & 
State/Province.

The available choices for a State/Province depend upon which Country is 
selected.

For the OP: the only way to do this requires JavaScript on the client end, 
and creating
views to return the limited set of objects you wish to be able to select 
from. When your
user changes Country, for instance, you then fetch the available list of 
States for that
country, and use that to populate the State field options.

I have an example (of exactly this) in my fork of django-countries: 
https://bitbucket.org/schinckel/django-countries/src

Specifically, have a look at the JS: 
https://bitbucket.org/schinckel/django-countries/src/0482ff867b4c/django_countries/static/countries/js/update_provinces_select.js

It's not especially well documented, and the JS only works for country 
field being 
called country, and province field being called province, but it might be a 
nice start for you
to see how to do it.


Matt.

-- 
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/-/qIbITxaVnUcJ.
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: Where admin classes should be registered ?

2012-06-27 Thread Matt Schinckel
I generally register admin models where I define them, and then just import 
that
file in admin/__init__.py

If you are getting multiple registration errors, it may be that your app 
appears
twice in sys.path (perhaps as app, and project.app?).

That's generally a Bad Thing(tm).

Matt.

-- 
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/-/VXzngj1e75sJ.
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: Getting tuple of (sql, params) from the ORM.

2012-06-27 Thread David Novakovic
Fantastic, that's exactly what I need.. thanks Jeremy!

Yep, my first -users post :)

On Tuesday, June 26, 2012 9:05:35 PM UTC+2, jdunck wrote:
>
> On Tue, Jun 26, 2012 at 11:40 AM, David Novakovic 
>  wrote: 
> > Hey all, 
> > 
> > Is it possible to get a tuple of (sql, params) from an ORM queryset? 
>
> Yep: 
>
> sql, params = qs.query.get_compiler('default').as_sql() 
>
> (Fancy meeting you here. :)) 
>

-- 
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/-/iESbzAMkqN0J.
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: Where admin classes should be registered ?

2012-06-27 Thread Alireza Savand
As your approach, at admin/__init__.py i have to

from myapp.admin.ouradmin import *

That means import all of the classes inside that files.

On Wed, Jun 27, 2012 at 2:54 PM, Matt Schinckel  wrote:

> I generally register admin models where I define them, and then just
> import that
> file in admin/__init__.py
>
> If you are getting multiple registration errors, it may be that your app
> appears
> twice in sys.path (perhaps as app, and project.app?).
>
> That's generally a Bad Thing(tm).
>
> Matt.
>
> --
> 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/-/VXzngj1e75sJ.
>
> 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: interpretting urls

2012-06-27 Thread bruno desthuilliers


On Tuesday, June 26, 2012 6:52:06 PM UTC+2, Sam007 wrote:
>
> Hi,
>
> I am bit confused about what exactly do these urls imply in the url.py
>
>
This is all documented here : 
https://docs.djangoproject.com/en/dev/topics/http/urls/

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



Re: Django 1.4 Why does the create project command create 2 identical folders

2012-06-27 Thread Joey Espinosa
They're actually both considered your project. One just holds everything,
and the other has global settings. Here is the official explanation:

https://docs.djangoproject.com/en/1.4/releases/1.4/#updated-default-project-layout-and-manage-py

Relevant text:

> *Django 1.4 ships with an updated default project layout and manage.py file
> for the 
> startproject
>  management
> command. *

*These fix some issues with the previous manage.py handling of Python
> import paths that caused double imports, trouble *

*moving from development to deployment, and other difficult-to-debug path
> issues. *

--
Joey "JoeLinux" Espinosa*
*





On Wed, Jun 27, 2012 at 2:09 AM, Sergiy Khohlov  wrote:

> first one name of the project second  one name of the application. You
> had executed both command
>
> 2012/6/27 Python_Junkie :
> > When one creates a project with django-admin.py why is a second my site
> > folder created?
> >
> > Mysite
> > Mysite
> > polls
> >
> > Thanks in advance.
> >
> > What is its function/value in this new version
> >
> > --
> > 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/-/wSdsYgVkNGAJ.
> > 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.



ManyToManyField is this right?

2012-06-27 Thread David Wagner
I'm a self taught programmer who hasn't done much of anything for years so 
please forgive me if this question is naive. I have a hard time sometimes 
understanding some of the lingo used by trained programmers.

With that said, I'm having trouble wrapping my brain around the ManyToMany 
and Many-To-One and OneToOne concepts. I'm trying to create a multi-select 
option for a user profile in which a user can have multiple attributes of a 
certain kind. Right now I'm just working on the model. This is what I have, 
is it right?

# Different licenses for instructors to select from
class Licenses(models.Model):
nra = models.BooleanField()
ccl = models.BooleanField()

# User Profile Model
class UserProfile(models.Model):
user = models.OneToOneField(User)

 #...

licensed_instructor = models.ManyToManyField(Licenses)

-- 
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/-/7dOg4S9_dPAJ.
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: Where admin classes should be registered ?

2012-06-27 Thread Daniel Roseman
On Wednesday, 27 June 2012 08:54:07 UTC+1, Alireza Savand wrote:
>
> Hi
> Common way to create [model|admin] classes is implement and create them in 
> [models|admin].py file.
> But as standard non-django way is to create a python package named admin 
> for AdminClass es and  create a file for each admin class.
> But i couldn't find any standard way to register those admin classes, i 
> mean should i register them in admin/__init__.py or register each class in 
> it own file then import them at admin/__init__.py ?
> Sometimes when i register all of them at admin/__init__.py it's happening 
> that classes will initialed multiple times and i don't know the reason.
> I'm just looking for common or standard way to do it.
>
> Thanks.
>

There is absolutely a standard way to do this, which is fully documented.

Define all your ModelAdmin classes in an admin.py inside each app. Register 
the classes in that file (usually together at the end). In your main 
urls.py, call `admin.autodiscover()`, which imports all the admin.py files 
which causes them to be registered.

If you do anything else, you may well run into multiple registration 
problems. Don't. Follow the standard.
--
DR.

-- 
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/-/h2g8jTwkmrAJ.
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: ManyToManyField is this right?

2012-06-27 Thread Javier Guerra Giraldez
On Wed, Jun 27, 2012 at 8:57 AM, David Wagner  wrote:
> With that said, I'm having trouble wrapping my brain around the ManyToMany
> and Many-To-One and OneToOne concepts. I'm trying to create a multi-select
> option for a user profile in which a user can have multiple attributes of a
> certain kind. Right now I'm just working on the model. This is what I have,
> is it right?

these terms are used mainly in the relational database design.  as you
might know, you can't have real arrays or structures on traditional
SQL databases, so you use those three types of 'links'.

the simplest is the 'many to one', you have one 'parent' table and a
'child' one with a field (called the "foreign key" field) where each
record keeps a copy of the primary key of a 'parent' record.  a common
example is to have 'group' and 'member' tables.  each 'member' record
has a field (sometimes called 'group_id') that tells which to which
group it belongs.  with a non-unique index on that field, it's easy to
pick all members of each group.

a slight variation is the 'one to one'.  here, the index on the
foreign key field is a 'unique' index, that forbids two records with
the same value, effectively making it impossible for a 'parent' record
to have more than one 'child'.  sometimes instead of defining a
specific foreign key field, you assign the same primary key value to
related records.

the last one is the 'many to many'.  for example, you can have users
that belong to more than one group; and of course each group has many
users.  for this, you have to define a 'link table' where each record
has two foreign key fields, one for each linked table.  sometimes the
primary key of the link table is just the composite index of these two
foreign keys.  also there can be a second composite index with the
same foreign keys in the opposite order.  Also you can choose to add
some extra fields to the link table to express some properties of the
link itself.

In Django, you handle this just by declaring fields of the appropriate
type; Django takes care of declaring the indexes, link table if
needed, and a 'reverse relationship'.  that last feature is the one
that makes the 'members' pseudo array to magically appear in 'group'
objects.

hope this helps with the theory and makes the Django docs easier to read.

-- 
Javier

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



Re: ManyToManyField is this right?

2012-06-27 Thread Thomas Lockhart

On 12-06-27 6:57 AM, David Wagner wrote:
I'm a self taught programmer who hasn't done much of anything for 
years so please forgive me if this question is naive. I have a hard 
time sometimes understanding some of the lingo used by trained 
programmers.


With that said, I'm having trouble wrapping my brain around the 
ManyToMany and Many-To-One and OneToOne concepts. I'm trying to create 
a multi-select option for a user profile in which a user can have 
multiple attributes of a certain kind. Right now I'm just working on 
the model. This is what I have, is it right?


# Different licenses for instructors to select from
class Licenses(models.Model):
nra = models.BooleanField()
ccl = models.BooleanField()
I am not familiar with the licenses you are referring to. But if "nra" 
and "ccl" are each a kind of license rather than attributes for each 
kind of license (google implies this involves gun licensing??!!) you 
will want a separate record for each license type. Something like


class Licenses(models.Model):
name = models.CharField(_("Name"), max_length=20)

then populate the license table with an entry for each license type 
"nra" and "ccl".


The "many to many" relationship you are modeling would have multiple 
license entries for multiple users and this is done by having multiple 
entries for each model rather than stacking multiple choices into a 
single model.



# User Profile Model
class UserProfile(models.Model):
user = models.OneToOneField(User)

 #...

licensed_instructor = models.ManyToManyField(Licenses)
You may want to name this field "licenses" rather than 
"licensed_instructor" for convenience and by convention.


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.



Re: ManyToManyField is this right?

2012-06-27 Thread j_syk
One to One is the right type for linking a user to a profile in the Django 
world. However I think you may be mixed up on the many to many. 
How you have it setup would lead to a User being connected to multiple 
License objects, each with a nra and ccl attribute. If I didn't realize 
what those stood for, I'd say you are right. But, I think that you might be 
thinking of it as the nra and ccl being separate licenses so in that case 
they shouldnt be the same object

Here's what I'd recommend. Either put those two booleans directly on the 
profile model or make the License class more generic for any relevant 
details of a potential license. For example

class License(models.Model):
name = models.CharField(max_length=255)
expiration = models.DateField(blank=True, null=True)
details = models.TextField()

With something like this, the User could have multiple licenses like: 
Concealed Carry 5/10/2015 and NRA no expire .

On Wednesday, June 27, 2012 8:57:24 AM UTC-5, David Wagner wrote:
>
> I'm a self taught programmer who hasn't done much of anything for years so 
> please forgive me if this question is naive. I have a hard time sometimes 
> understanding some of the lingo used by trained programmers.
>
> With that said, I'm having trouble wrapping my brain around the ManyToMany 
> and Many-To-One and OneToOne concepts. I'm trying to create a multi-select 
> option for a user profile in which a user can have multiple attributes of a 
> certain kind. Right now I'm just working on the model. This is what I have, 
> is it right?
>
> # Different licenses for instructors to select from
> class Licenses(models.Model):
> nra = models.BooleanField()
> ccl = models.BooleanField()
>
> # User Profile Model
> class UserProfile(models.Model):
> user = models.OneToOneField(User)
> 
>  #...
>
> licensed_instructor = models.ManyToManyField(Licenses)
>

-- 
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/-/VModQy3bu7UJ.
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: ManyToManyField is this right?

2012-06-27 Thread David Wagner
Thanks for all the replies and I think I'm getting it now but it gets more
complex too.

So NRA Licenses is essentialy going to become a type of several
certifications. For instance.

NRA Instructor

   - Home Firearm Safety Instructor
   - Refuse to be a Victim Workshop
   - and many more could be selected.

CCL (or CCW in some states)

   - State in Which your Certified (possibility of multiple states)

Many more different types of licenses and certifications are going to be
added eventually so as you can see these relationships are going to get
complex. So If I'm grasping this correctly let me try some code to see if
I'm on the right track

class NRA_Certs(models.Model):
CRSO = models.BooleanField(blank=True, null=True, "Chief Range Safety
Officer")
HFS = models.BooleanField(blank=True, null=True, "Home Firearm Safety")
MCR = models.BooleanField(blank=True, null=True, "Metallic Cartridge
Reloading")
PPH = models.BooleanField(blank=True, null=True, "Personal Protection
in the Home")
PPO = models.BooleanField(blank=True, null=True, "Personal Protection
Outside the Home")
PS = models.BooleanField(blank=True, null=True, "Pistol Shooting")
RS = models.BooleanField(blank=True, null=True, "Rifle Shooting")
SSR = models.BooleanField(blank=True, null=True, "Shotgun Shell
Reloading")
SS = models.BooleanField(blank=True, null=True, "Shotgun Shooting")
RTBVDW = models.BooleanField(blank=True, null=True, "Refuse to be a
Victim Workshop")
RTBVO = models.BooleanField(blank=True, null=True, "Refuse to be a
Victim Online")
NMLRA_MP = models.BooleanField(blank=True, null=True, "NMLRA
Muzzleloading Pistol Shooting")
NMLRA_MR = models.BooleanField(blank=True, null=True, "NMLRA
Muzzleloading Rifle Shooting")
NMLRA_MS = models.BooleanField(blank=True, null=True, "NMLRA
Muzzleloading Shotgun Shooting")

class NRA(models.Model):
cert_type = models.ForeignKey(NRA_Certs)
name = models.CharField() # Is this necessary? Can the name be set to
text in the boolean fields from NRA_Certs?
expiration = models.DateField(blank=True, null=True)

Does that look right or am I missing it completely. I'm not sure sure on
the NRA_Certs all being boolean, my thinking is that whether they have that
certification should be as simple as true/false.

Thanks once again for all the help.


On Wed, Jun 27, 2012 at 7:38 AM, j_syk  wrote:> One to
One is the right type for linking a user to a profile in the Django

> world. However I think you may be mixed up on the many to many.
> How you have it setup would lead to a User being connected to multiple
> License objects, each with a nra and ccl attribute. If I didn't realize
what
> those stood for, I'd say you are right. But, I think that you might be
> thinking of it as the nra and ccl being separate licenses so in that case
> they shouldnt be the same object
>
> Here's what I'd recommend. Either put those two booleans directly on the
> profile model or make the License class more generic for any relevant
> details of a potential license. For example
>
> class License(models.Model):
> name = models.CharField(max_length=255)
> expiration = models.DateField(blank=True, null=True)
> details = models.TextField()
>
> With something like this, the User could have multiple licenses like:
> Concealed Carry 5/10/2015 and NRA no expire .
>
>
> On Wednesday, June 27, 2012 8:57:24 AM UTC-5, David Wagner wrote:
>>
>> I'm a self taught programmer who hasn't done much of anything for years
so
>> please forgive me if this question is naive. I have a hard time sometimes
>> understanding some of the lingo used by trained programmers.
>>
>> With that said, I'm having trouble wrapping my brain around the
ManyToMany
>> and Many-To-One and OneToOne concepts. I'm trying to create a
multi-select
>> option for a user profile in which a user can have multiple attributes
of a
>> certain kind. Right now I'm just working on the model. This is what I
have,
>> is it right?
>>
>> # Different licenses for instructors to select from
>> class Licenses(models.Model):
>> nra = models.BooleanField()
>> ccl = models.BooleanField()
>>
>> # User Profile Model
>> class UserProfile(models.Model):
>> user = models.OneToOneField(User)
>>
>>  #...
>>
>> licensed_instructor = models.ManyToManyField(Licenses)
>
> --
> 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/-/VModQy3bu7UJ.
>
> 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 u

Re: ManyToManyField is this right?

2012-06-27 Thread Thomas Lockhart

On 12-06-27 8:02 AM, David Wagner wrote:
Thanks for all the replies and I think I'm getting it now but it gets 
more complex too.


So NRA Licenses is essentialy going to become a type of several 
certifications. For instance.


NRA Instructor

  * Home Firearm Safety Instructor
  * Refuse to be a Victim Workshop
  * and many more could be selected.

CCL (or CCW in some states)

  * State in Which your Certified (possibility of multiple states)

Many more different types of licenses and certifications are going to 
be added eventually so as you can see these relationships are going to 
get complex. So If I'm grasping this correctly let me try some code to 
see if I'm on the right track


class NRA_Certs(models.Model):
CRSO = models.BooleanField(blank=True, null=True, "Chief Range 
Safety Officer")
HFS = models.BooleanField(blank=True, null=True, "Home Firearm 
Safety")
MCR = models.BooleanField(blank=True, null=True, "Metallic 
Cartridge Reloading")
PPH = models.BooleanField(blank=True, null=True, "Personal 
Protection in the Home")
PPO = models.BooleanField(blank=True, null=True, "Personal 
Protection Outside the Home")

PS = models.BooleanField(blank=True, null=True, "Pistol Shooting")
RS = models.BooleanField(blank=True, null=True, "Rifle Shooting")
SSR = models.BooleanField(blank=True, null=True, "Shotgun Shell 
Reloading")

SS = models.BooleanField(blank=True, null=True, "Shotgun Shooting")
RTBVDW = models.BooleanField(blank=True, null=True, "Refuse to be 
a Victim Workshop")
RTBVO = models.BooleanField(blank=True, null=True, "Refuse to be a 
Victim Online")
NMLRA_MP = models.BooleanField(blank=True, null=True, "NMLRA 
Muzzleloading Pistol Shooting")
NMLRA_MR = models.BooleanField(blank=True, null=True, "NMLRA 
Muzzleloading Rifle Shooting")
NMLRA_MS = models.BooleanField(blank=True, null=True, "NMLRA 
Muzzleloading Shotgun Shooting")


class NRA(models.Model):
cert_type = models.ForeignKey(NRA_Certs)
name = models.CharField() # Is this necessary? Can the name be set 
to text in the boolean fields from NRA_Certs?

expiration = models.DateField(blank=True, null=True)

Does that look right or am I missing it completely. I'm not sure sure 
on the NRA_Certs all being boolean, my thinking is that whether they 
have that certification should be as simple as true/false.



Probably not. What happens if another new cert gets added to the the 
list? You will want a separate table entry for each kind of cert so when 
"Howitzer" gets added you can make that available without changing your 
models, only changing your data in the database.


afaict your new proposed class "NRA" does not add value here. Have 
certs, and have users. Should be enough.


You do have more than one piece of info for the cert model: an acronym 
and a long name or description. Those should be two fields in the model. 
Then use the many to many relation to allow multiple certs for each user 
and to allow multiple users to have the same cert.


hth

- Tom


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



many "Broken INTERNAL link" with end string "/undefined/"

2012-06-27 Thread ferran
Hello django users,

In the last 3 weeks I'm receiving in my email a many "Broken INTERNAL link" 
how this:

"
Referrer: http://www.marquezshop.com/es/catalogo/sales/
Requested URL: /es/catalogo/sales/undefined/
User agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like 
Gecko) Chrome/19.0.1084.56 Safari/536.5
IP address: ---
"
or

"
Referrer: 
http://www.marquezshop.com/es/catalogo/sales/sal-compactada-en-pastillas-piscinas-salnet.html/
Requested URL: 
/es/catalogo/sales/sal-compactada-en-pastillas-piscinas-salnet.html/undefined/
User agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like 
Gecko) Chrome/12.0.742.122 Safari/534.30
IP address: 
"

The pattern from requested URL can be any, but, always have a end string 
"/undefined/"

I'm not update the code, but update, nginx, mysql, apache

Program versions:
django 1.1.4
localeurl 1.5 (tip version)

Do you have any Idea?

Thanks in advanced
Ferran




-- 
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/-/RewwbdcQ8ywJ.
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: ManyToManyField is this right?

2012-06-27 Thread David Wagner
i think I may just be over thinking this. The last time I did any
significant coding for the web as pre-php5 and so this whole MVC thing is
something to adapt too for sure.

I think I need to start thinking of the Model in the same way I would
design a database back in the day with phpMyAdmin. I think I'm getting
bogged down in trying to understand how it will relate to the View. Perhaps
I need to just put the View out of my mind for the time being.

So thinking of this as just a database schema it would be something like
(in psuedo-code)

cert_types

   - type
   - date_created

certs

   - type = foreignkey(cert_types)
   - name
   - state (optional)
   - date_created

person

   - name
   - etc...
   - certificates = foreignkey(certs)

Does that make sense? If so each table would be represented by a single
class and I think I understand then how they relate to each other and I
just need to stop worrying about the View.

Thanks for all your patience everyone as well. Like I said, I'm not
classically trained in computer science so there are a lot of concepts that
elude me and some lingo that I don't get but the concepts I may grasp if I
just understand the translation.
On Wed, Jun 27, 2012 at 10:55 AM, Dennis Lee Bieber
wrote:

> On Wed, 27 Jun 2012 08:02:37 -0700, David Wagner 
> declaimed the following in gmane.comp.python.django.user:
>
> >
> > class NRA_Certs(models.Model):
> > CRSO = models.BooleanField(blank=True, null=True, "Chief Range Safety
> > Officer")
> > HFS = models.BooleanField(blank=True, null=True, "Home Firearm
> Safety")
> > MCR = models.BooleanField(blank=True, null=True, "Metallic Cartridge
> > Reloading")
> > PPH = models.BooleanField(blank=True, null=True, "Personal Protection
> > in the Home")
> > PPO = models.BooleanField(blank=True, null=True, "Personal Protection
> > Outside the Home")
> > PS = models.BooleanField(blank=True, null=True, "Pistol Shooting")
> > RS = models.BooleanField(blank=True, null=True, "Rifle Shooting")
> > SSR = models.BooleanField(blank=True, null=True, "Shotgun Shell
> > Reloading")
> > SS = models.BooleanField(blank=True, null=True, "Shotgun Shooting")
> > RTBVDW = models.BooleanField(blank=True, null=True, "Refuse to be a
> > Victim Workshop")
> > RTBVO = models.BooleanField(blank=True, null=True, "Refuse to be a
> > Victim Online")
> > NMLRA_MP = models.BooleanField(blank=True, null=True, "NMLRA
> > Muzzleloading Pistol Shooting")
> > NMLRA_MR = models.BooleanField(blank=True, null=True, "NMLRA
> > Muzzleloading Rifle Shooting")
> > NMLRA_MS = models.BooleanField(blank=True, null=True, "NMLRA
> > Muzzleloading Shotgun Shooting")
> >
> Ugh!...
>
>I'm not familiar enough with Django's internal format so I'm using a
> form of old relational theory notation: tablename(_key_, /foreignkey/,
> other, fields...)
>
> NRACertificate(_ID_, certificateName, other, type, specific,
> attributes))
>
>{I forget your individual model so a generic}
>
> Person(_ID_, name, other, stuff)
>
> Person_NRACertificate(_ID_, /personID/, /nracertificateID/,
> dateCertified, dateExpires, other, certificate, specfic, data)
>
>Django can build this intersection table automatically -- but it
> would only have _ID_, /personID/, /nracertificateID/! I think, for your
> information, you'd want to define your own "through" table to hold the
> data specific to an instance of a certificate as held by a person.
>
>Same with concealed carry permits IF you need a list on a, say, per
> state basis.
>
>Note though, that if the /lists/ don't carry any significant
> information beyond the name of the item, you just need one-to-many
> configurations. For example, if the only information you track for CCW
> is: who (foreign key to Person), license number, issuing state (or other
> government entity), date issued, date expires... then a one-to-many is
> all you need. (Though you may find you need another one-to-many --
> California's rare CCW includes a list of /which/ firearm(s) are
> permitted [if you sell one gun and buy a different one, you have to beg
> the government to update the CCW with the new gun's information]).
>
>The NRACertificates table may also not be needed if all it provides
> is a list of names to populate a dropdown selection box -- might speed
> up processing by just hard-coding the list and saving the name directly
> (replace the /nracerticateID/ in the intersect table with the actual
> text of the certificate as selected from the dropdown selection.
>
>Bigger note: You will NOT be using a multiple selection list... More
> reasonable is an "add new certificate" button which brings up a form
> from which to select one certificate (by name in dropdown), and fields
> for the dates, and whatever else is common to certificates.
>
>When displaying a person, the certificates would be (if I recall
> Django terms) a "formset" (where the "form" is for a sin

Re: ManyToManyField is this right?

2012-06-27 Thread David Wagner
Looking at that I think I may need to add a foreignkey to cert_types
relating to person since a person can have multiple certification types
(NRA Instructor, CCL Instructor, etc).

On Wed, Jun 27, 2012 at 11:40 AM, David Wagner  wrote:

> i think I may just be over thinking this. The last time I did any
> significant coding for the web as pre-php5 and so this whole MVC thing is
> something to adapt too for sure.
>
> I think I need to start thinking of the Model in the same way I would
> design a database back in the day with phpMyAdmin. I think I'm getting
> bogged down in trying to understand how it will relate to the View. Perhaps
> I need to just put the View out of my mind for the time being.
>
> So thinking of this as just a database schema it would be something like
> (in psuedo-code)
>
> cert_types
>
>- type
>- date_created
>
> certs
>
>- type = foreignkey(cert_types)
>- name
>- state (optional)
>- date_created
>
> person
>
>- name
>- etc...
>- certificates = foreignkey(certs)
>
> Does that make sense? If so each table would be represented by a single
> class and I think I understand then how they relate to each other and I
> just need to stop worrying about the View.
>
> Thanks for all your patience everyone as well. Like I said, I'm not
> classically trained in computer science so there are a lot of concepts that
> elude me and some lingo that I don't get but the concepts I may grasp if I
> just understand the translation.
> On Wed, Jun 27, 2012 at 10:55 AM, Dennis Lee Bieber  > wrote:
>
>> On Wed, 27 Jun 2012 08:02:37 -0700, David Wagner 
>> declaimed the following in gmane.comp.python.django.user:
>>
>> >
>> > class NRA_Certs(models.Model):
>> > CRSO = models.BooleanField(blank=True, null=True, "Chief Range
>> Safety
>> > Officer")
>> > HFS = models.BooleanField(blank=True, null=True, "Home Firearm
>> Safety")
>> > MCR = models.BooleanField(blank=True, null=True, "Metallic Cartridge
>> > Reloading")
>> > PPH = models.BooleanField(blank=True, null=True, "Personal
>> Protection
>> > in the Home")
>> > PPO = models.BooleanField(blank=True, null=True, "Personal
>> Protection
>> > Outside the Home")
>> > PS = models.BooleanField(blank=True, null=True, "Pistol Shooting")
>> > RS = models.BooleanField(blank=True, null=True, "Rifle Shooting")
>> > SSR = models.BooleanField(blank=True, null=True, "Shotgun Shell
>> > Reloading")
>> > SS = models.BooleanField(blank=True, null=True, "Shotgun Shooting")
>> > RTBVDW = models.BooleanField(blank=True, null=True, "Refuse to be a
>> > Victim Workshop")
>> > RTBVO = models.BooleanField(blank=True, null=True, "Refuse to be a
>> > Victim Online")
>> > NMLRA_MP = models.BooleanField(blank=True, null=True, "NMLRA
>> > Muzzleloading Pistol Shooting")
>> > NMLRA_MR = models.BooleanField(blank=True, null=True, "NMLRA
>> > Muzzleloading Rifle Shooting")
>> > NMLRA_MS = models.BooleanField(blank=True, null=True, "NMLRA
>> > Muzzleloading Shotgun Shooting")
>> >
>> Ugh!...
>>
>>I'm not familiar enough with Django's internal format so I'm using
>> a
>> form of old relational theory notation: tablename(_key_, /foreignkey/,
>> other, fields...)
>>
>> NRACertificate(_ID_, certificateName, other, type, specific,
>> attributes))
>>
>>{I forget your individual model so a generic}
>>
>> Person(_ID_, name, other, stuff)
>>
>> Person_NRACertificate(_ID_, /personID/, /nracertificateID/,
>> dateCertified, dateExpires, other, certificate, specfic, data)
>>
>>Django can build this intersection table automatically -- but it
>> would only have _ID_, /personID/, /nracertificateID/! I think, for your
>> information, you'd want to define your own "through" table to hold the
>> data specific to an instance of a certificate as held by a person.
>>
>>Same with concealed carry permits IF you need a list on a, say, per
>> state basis.
>>
>>Note though, that if the /lists/ don't carry any significant
>> information beyond the name of the item, you just need one-to-many
>> configurations. For example, if the only information you track for CCW
>> is: who (foreign key to Person), license number, issuing state (or other
>> government entity), date issued, date expires... then a one-to-many is
>> all you need. (Though you may find you need another one-to-many --
>> California's rare CCW includes a list of /which/ firearm(s) are
>> permitted [if you sell one gun and buy a different one, you have to beg
>> the government to update the CCW with the new gun's information]).
>>
>>The NRACertificates table may also not be needed if all it provides
>> is a list of names to populate a dropdown selection box -- might speed
>> up processing by just hard-coding the list and saving the name directly
>> (replace the /nracerticateID/ in the intersect table with the actual
>> text of the certificate as selected from the dropdown selection.
>>
>>Bigger note: You

How to make a query?

2012-06-27 Thread galgal
I have a model Article. It has a datetime field, title and description.
How can I get last 5 months from now, where there is at least 1 article 
added? Other words - how to get last 5 months which are not empty?

-- 
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/-/BbMtFrpjLH4J.
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 make a query?

2012-06-27 Thread Nikolas Stevenson-Molnar
Use the 'dates' method:
https://docs.djangoproject.com/en/dev/ref/models/querysets/#dates with
"month" for the kind argument. You can filter the query first to
restrict to last five months. E.g:

>>> oldest = datetime.date.today()-datetime.timedelta(30*5) #roughly 5
months ago
>>> months = Article.objects.filter(date__gte=oldest).dates('date', 'month')

_Nik

Article.objects.filter(date__gte
On 6/27/2012 12:28 PM, galgal wrote:
> I have a model Article. It has a datetime field, title and description.
> How can I get last 5 months from now, where there is at least 1
> article added? Other words - how to get last 5 months which are not empty?
> -- 
> 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/-/BbMtFrpjLH4J.
> 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.



Translated urls and accept-language header

2012-06-27 Thread Jonas Geiregat
Hello,

I've setup translated urls for some languages. The default language 
for django has been set to en-US.

If you request a page /registration/ with nl-NL as Accept-Language
header, I get a 404. 
I wasn't expecting such behaviour. Rather I was hoping I would be 
redirected to /registratie/ ,the tranlated url that corresponds my
Accept-Language header.
Ofcourse /registratie/ with the nl-Nl Accept-Language header, works
fine and gives me the expected 200.

I'm guessing this is just as normal as it can get ?

Isn't there a chance a user might get link from some website and
the link is build for the English language, but the user in question
has a different supported language setting, Accept-Language header ?
In such a case he would be presented with a 404.
He should be presented with or the English (default) content or
or be redirected to the correct url for his language if supported.

Also what happens if a user has a not supported language setting ?
Will the django default LANGUAGE_CODE be used, en-US in my case ?

Is there a way to work around this or handle it in a different better way ?

an extract from my urls.py file, shows how I've setup translated urls:

url(_(r'^step1/$'), AccountTypeSelectionView.as_view(), 
name="registration_step1"),

-- 
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 make a query?

2012-06-27 Thread galgal
I made it that way:

prev_months = Article.objects.dates('add_date', 
> 'month').filter(add_date__lt=datetime.date(int(year), int(month), 1))[:5]
> next_months = Article.objects.dates('add_date', 
> 'month').filter(add_date__gte=datetime.date(int(year), int(month) + 1, 
> 1))[:5]


On Wednesday, June 27, 2012 9:28:27 PM UTC+2, galgal wrote:
>
> I have a model Article. It has a datetime field, title and description.
> How can I get last 5 months from now, where there is at least 1 article 
> added? Other words - how to get last 5 months which are not empty?
>

-- 
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/-/Qa_SJtAS6KwJ.
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: interpretting urls

2012-06-27 Thread Smaran Harihar
Going thru the doc link you gave, I did not understand the term middleware
request processing?

but if the incoming HttpRequest object has an attribute called urlconf (set
by middleware *request
processing*),
its value will be used in place of the
ROOT_URLCONF
 setting.

On Wed, Jun 27, 2012 at 4:16 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On Tuesday, June 26, 2012 6:52:06 PM UTC+2, Sam007 wrote:
>>
>> Hi,
>>
>> I am bit confused about what exactly do these urls imply in the url.py
>>
>>
> This is all documented here :
> https://docs.djangoproject.com/en/dev/topics/http/urls/
>
>  --
> 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/-/Zo3bjY0ZFvgJ.
> 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.
>



-- 
Thanks & Regards
Smaran Harihar

-- 
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: interpretting urls

2012-06-27 Thread Smaran Harihar
The doc did not give details for *r'^(?:index/?)?$'*, in

(r'^(?:index/?)?$', 'geonode.views.index')

Thanks,
Smaran

On Wed, Jun 27, 2012 at 4:16 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On Tuesday, June 26, 2012 6:52:06 PM UTC+2, Sam007 wrote:
>>
>> Hi,
>>
>> I am bit confused about what exactly do these urls imply in the url.py
>>
>>
> This is all documented here :
> https://docs.djangoproject.com/en/dev/topics/http/urls/
>
>  --
> 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/-/Zo3bjY0ZFvgJ.
> 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.
>



-- 
Thanks & Regards
Smaran Harihar

-- 
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: ManyToManyField is this right?

2012-06-27 Thread David Wagner
Ah, I think that makes sense. Sorry if I wasn't clear earlier on but yes, I
am looking for instructors who are certified to teach a certain course. So
basically a user could sign up and select some or none of the types of
courses they are certified to teach this way other users who want to learn
can find them easily. As far as the difference between NRA and CCL, there
are several different types of NRA courses one could take however a
Concealed Carry course is dependent on which state your certified to teach
in. This is what was getting me all confused as I was trying to abstract
the type of course from the actual courses provided since there are a
number of organizations and individuals (not attached to an organization)
that can provide not only courses but services, such as a state certified
hunting guide (for instance in Alaska you need one to hunt large game).

I guess though from your example data structure I could put any type of
organization, state, etc into the IssuingAuthority and when it comes time
to create the profile forms I could just create a drop down list of all
issuing authorities for a person to choose from and then populate a select
box with all classes that belong to that issuing authority. I would like
for people to be able to multi-select and have fields auto-populate all on
one page at one time but I'll jump that hurdle when I get there I suppose.
Probably need to dive into Javascript/Ajax to make that work.

Thanks much for your help.



On Wed, Jun 27, 2012 at 3:31 PM, Dennis Lee Bieber wrote:

> On Wed, 27 Jun 2012 11:48:22 -0700, David Wagner 
> declaimed the following in gmane.comp.python.django.user:
>
> > Looking at that I think I may need to add a foreignkey to cert_types
> > relating to person since a person can have multiple certification types
> > (NRA Instructor, CCL Instructor, etc).
>
> Well, this has just added a different aspect... That of INSTRUCTOR
> (my memory of the first messages came across more as a certificate that
> one had attended a course , not that it meant they could teach the
> course).
>
>In the case of instructors -- what is the difference between "NRA"
> and "CCL" instructor? "NRA" specifies an organization that provides the
> certification in /something/, but "CCL" is a /something/ but who issues
> it?
>
>Okay, looking at these as teaching certificates...
>
> Certificates
>ID #primary key
>Name#text string for the common name of the class
>IssuingAuthority#NRA or government entity
>DateFirstAuthorized #not date of issuance, but a double check
> that
>#an issued
> certificate date does not come
>#before the "class"
> was created
>RenewalPeriod   #how often the certificate needs to be
> renewed
>
> Persons
>ID
>Name
>Address
>whatever
>
> Issued  #or PersonsCertificates if you want to name the
> sources
>ID
>pID foreign key (Persons.ID) #who this certificate
> was issued to
>cID foreign key (Certificates.ID)   #what type of
> certificate
>DateIssued  #constraint DateIssued > DateFirstAuthorized
>CertificateNumber   #document number
>DateExpires #for things that need to be renewed
> periodically
>#= DateIssued +
> RenewalPeriod
>UniqueKey (pID, cID, CertificateNumber)
>#including certificate number means you can track renewals
>#as a renewal would have a different serial number
>
>This is a many-to-many between Persons and Certificates, in which
> the intersection table (Issued) contains additional information.
>
>
> --
>Wulfraed Dennis Lee Bieber AF6VN
>wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.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.
>
>

-- 
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: many "Broken INTERNAL link" with end string "/undefined/"

2012-06-27 Thread Russell Keith-Magee
On Thu, Jun 28, 2012 at 12:37 AM, ferran  wrote:
> Hello django users,
>
> In the last 3 weeks I'm receiving in my email a many "Broken INTERNAL link"
> how this:
>
> "
> Referrer: http://www.marquezshop.com/es/catalogo/sales/
> Requested URL: /es/catalogo/sales/undefined/
> User agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like
> Gecko) Chrome/19.0.1084.56 Safari/536.5
> IP address: ---
> "
> or
>
> "
> Referrer:
> http://www.marquezshop.com/es/catalogo/sales/sal-compactada-en-pastillas-piscinas-salnet.html/
> Requested URL:
> /es/catalogo/sales/sal-compactada-en-pastillas-piscinas-salnet.html/undefined/
> User agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like
> Gecko) Chrome/12.0.742.122 Safari/534.30
> IP address: 
> "
>
> The pattern from requested URL can be any, but, always have a end string
> "/undefined/"
>
> I'm not update the code, but update, nginx, mysql, apache
>
> Program versions:
> django 1.1.4
> localeurl 1.5 (tip version)
>
> Do you have any Idea?

It's impossible to say without seeing all your code, but you only get
those emails if there is a link on your page that returns a 404. That
means that pages on your site are being rendered with  on them.

The link may not be in an obvious location -- I'm going to guess that
they've been found by a robot that is scraping your site -- but if
your getting the emails, you can be fairly certain that the links
exist *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: ManyToManyField is this right?

2012-06-27 Thread Thomas Lockhart

On 6/27/12 11:48 AM, David Wagner wrote:
Looking at that I think I may need to add a foreignkey to cert_types 
relating to person since a person can have multiple certification 
types (NRA Instructor, CCL Instructor, etc).

No. See below.


On Wed, Jun 27, 2012 at 11:40 AM, David Wagner > wrote:


i think I may just be over thinking this. The last time I did any
significant coding for the web as pre-php5 and so this whole MVC
thing is something to adapt too for sure.


Yes you are :)



I think I need to start thinking of the Model in the same way I
would design a database back in the day with phpMyAdmin. I think
I'm getting bogged down in trying to understand how it will relate
to the View. Perhaps I need to just put the View out of my mind
for the time being.

Yes. If you've done databases (that is some of my background too) then 
the models (always the first step here) should become comfortable fairly 
quickly, even if you are rusty. See below...



So thinking of this as just a database schema it would be
something like (in psuedo-code)

cert_types

  * type
  * date_created

certs

  * type = foreignkey(cert_types)
  * name
  * state (optional)
  * date_created

person

  * name
  * etc...
  * certificates = foreignkey(certs)

OK, "cert_types" is good (or at least a good start). "person" needs to 
have a manytomany on cert_types rather than a foreign key on certs. And 
"certs" can be the explicit intermediate table used for the manytomany 
relationship and can hold things like dates. Look at the django docs on 
how to explicitly define the intermediate table, but it is in the 
musician and musical group example; google for "paul ringo django extra 
fields" :)


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.



Re: ManyToManyField is this right?

2012-06-27 Thread David Wagner
Thanks Tom. Is this the example your talking about,
https://docs.djangoproject.com/en/1.4/topics/db/models/#intermediary-manytomany?
If so, I think this should work...

# Different groups and states that issue teaching certificates/licenses
class IssuingAuthority(models.Model):
name = models.CharField(max_length=254)
state = USStateField()
date_added = models.DateTimeField(auto_now_add=True)

# Certifications issued related to IssuingAuthority
class Certifications(models.Model):
certs = models.ManyToManyField(License_Types, through='UserProfile')
name = models.CharField(max_length=254)
date_added = models.DateTimeField(auto_now_add=True)

# User Profile Model
class UserProfile(models.Model):
user = models.OneToOneField(User)
address_1 = models.CharField(max_length=254)
address_2 = models.CharField(max_length=254)
state = USStateField()
zip = models.IntegerField(max_length=7)
phone = PhoneNumberField()
issuing_authority = models.ForeignKey(IssuingAuthority)
certification = models.ForeignKey(Certifications)

I'll try to load that up later (most likely tomorrow) and see if I can get
it to work.

Thanks much.

On Wed, Jun 27, 2012 at 5:27 PM, Thomas Lockhart wrote:

>  On 6/27/12 11:48 AM, David Wagner wrote:
>
> Looking at that I think I may need to add a foreignkey to cert_types
> relating to person since a person can have multiple certification types
> (NRA Instructor, CCL Instructor, etc).
>
> No. See below.
>
>
> On Wed, Jun 27, 2012 at 11:40 AM, David Wagner wrote:
>
>> i think I may just be over thinking this. The last time I did any
>> significant coding for the web as pre-php5 and so this whole MVC thing is
>> something to adapt too for sure.
>>
>  Yes you are :)
>
>
>> I think I need to start thinking of the Model in the same way I would
>> design a database back in the day with phpMyAdmin. I think I'm getting
>> bogged down in trying to understand how it will relate to the View. Perhaps
>> I need to just put the View out of my mind for the time being.
>>
>  Yes. If you've done databases (that is some of my background too) then
> the models (always the first step here) should become comfortable fairly
> quickly, even if you are rusty. See below...
>
>
>> So thinking of this as just a database schema it would be something like
>> (in psuedo-code)
>>
>> cert_types
>>
>>- type
>>- date_created
>>
>> certs
>>
>>- type = foreignkey(cert_types)
>>- name
>>- state (optional)
>>- date_created
>>
>> person
>>
>>- name
>>- etc...
>>- certificates = foreignkey(certs)
>>
>>   OK, "cert_types" is good (or at least a good start). "person" needs to
> have a manytomany on cert_types rather than a foreign key on certs. And
> "certs" can be the explicit intermediate table used for the manytomany
> relationship and can hold things like dates. Look at the django docs on how
> to explicitly define the intermediate table, but it is in the musician and
> musical group example; google for "paul ringo django extra fields" :)
>
> 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.
>

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



locating the functionality behind the HTML element

2012-06-27 Thread Smaran Harihar
Hi Guys,

I am new to Django and have completed the initial basic tutorials in the
django doc. I am presently working on a pre-customized django application.
I was wondering how I can use FireBug to locate the code in a specific
element (like button). In the sense, in general the web development once we
are able to locate the button we are able to then locate the class of the
specific element and JS attached to it and CSS. But in Django this cannot
be done since everything is located in separate directories.

Since I am entering into the Django code, where should I start looking for
the CSS and JS files?

-- 
Thanks & Regards
Smaran Harihar

-- 
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: ZeroMQ / Mongrel2

2012-06-27 Thread esatterwh...@wi.rr.com
You could use WSGID to link mongrel2 with your django app. Its pretty nice 
 and easy to get running.

On Tuesday, November 8, 2011 4:10:02 AM UTC-6, Tom Evans wrote:
>
> On Mon, Nov 7, 2011 at 11:58 PM, Markus Gattol  
> wrote:
> >
> > Maybe sombody has given http://code.google.com/p/django-dmq and 
> Mongrel2 a spin already and can report how it went? The reason I am 
> interested is because it would allow me to get rid of WSGI altogether and 
> have this stack (ZeroMQ being directly Mongrel2 for example):
> >
>
> it would only allow you to get rid of WSGI if you no longer plan on
> serving over HTTP. django-dmq is about serving 0MQ requests - there is
> no magic translation from 0MQ <-> HTTP - and whilst Mongrel2 does
> allow you to connect backends using 0MQ, they are not using the same
> API, just the same transport.
>
> Cheers
>
> Tom
>
>

-- 
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/-/NM7cDspHyzoJ.
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: Where admin classes should be registered ?

2012-06-27 Thread Alireza Savand
Yes, But when my models.py/admin.py reach to +2000 line then django
standard way not gonna help. That's why i seperate the classes into files
and pkgs.
I'm wonder is there any performance issue on this approach, since each
class is in separate file, when i import them i'm sure python should find
them at the filesystem and initial them or they will be initialized by
django ?


On Wed, Jun 27, 2012 at 6:28 PM, Daniel Roseman wrote:

> On Wednesday, 27 June 2012 08:54:07 UTC+1, Alireza Savand wrote:
>>
>> Hi
>> Common way to create [model|admin] classes is implement and create them
>> in [models|admin].py file.
>> But as standard non-django way is to create a python package named admin
>> for AdminClass es and  create a file for each admin class.
>> But i couldn't find any standard way to register those admin classes, i
>> mean should i register them in admin/__init__.py or register each class in
>> it own file then import them at admin/__init__.py ?
>> Sometimes when i register all of them at admin/__init__.py it's happening
>> that classes will initialed multiple times and i don't know the reason.
>> I'm just looking for common or standard way to do it.
>>
>> Thanks.
>>
>
> There is absolutely a standard way to do this, which is fully documented.
>
> Define all your ModelAdmin classes in an admin.py inside each app.
> Register the classes in that file (usually together at the end). In your
> main urls.py, call `admin.autodiscover()`, which imports all the admin.py
> files which causes them to be registered.
>
> If you do anything else, you may well run into multiple registration
> problems. Don't. Follow the standard.
> --
> DR.
>
> --
> 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/-/h2g8jTwkmrAJ.
>
> 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.



replace or regex

2012-06-27 Thread pakyazilim
i have text ;
**
   A
 
 B
 
  
**
*
*
*i want to remove first  end for text end  tag. *
*how can i it?*
*thanks you...*

-- 
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/-/lPA-eOEgEBYJ.
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 1.4 + grappelli 2.4: missing css, img files.

2012-06-27 Thread bruce
Dear All,

I know this problem is related with grappelli. But it may be a django 
configure problem. So I am posting my question here.
If it is inappropriate, please let me know. 

I followed the django 1.4's tutorial to setup the 'polls' app and it was 
successful.
I also followed the grappelli 2.4 quick start guide. 
http://django-grappelli.readthedocs.org/en/grappelli_2_4/quickstart.html

I followed every step and didn't do anything else. 
The last command is:
python manage.py collectstatic
After this command is executed, two new directories were created(admin and 
grappelli).

The directory is as follows:
 root@ubuntu:/home/hduser/django/mysite# pwd
/home/hduser/django/mysite
root@ubuntu:/home/hduser/django/mysite# ls
admin  grappelli  manage.py  mysite  mytemplate  polls

Finally, 
I can access the http://127.0.0.1:8000/admin
But, the css,img files are missing. Please see the attached screen shot 
picture. 

The python manage.py runserver show:
[27/Jun/2012 21:36:19] "GET /admin/css/base.css HTTP/1.1" 404 4468
[27/Jun/2012 21:36:19] "GET 
/admin/jquery/ui/css/custom-theme/jquery-ui-1.8.custom.css HTTP/1.1" 404 
4585
[27/Jun/2012 21:36:19] "GET /admin/css/jquery-ui-grappelli-extensions.css 
HTTP/1.1" 404 4546
[27/Jun/2012 21:36:19] "GET /admin/jquery/jquery-1.6.2.min.js HTTP/1.1" 404 
4510
[27/Jun/2012 21:36:19] "GET 
/admin/jquery/ui/js/jquery-ui-1.8.15.custom.min.js HTTP/1.1" 404 4561
[27/Jun/2012 21:36:19] "GET /admin/js/grappelli/grappelli.js HTTP/1.1" 404 
4507
[27/Jun/2012 21:36:20] "GET /admin/js/grappelli/jquery.grp_collapsible.js 
HTTP/1.1" 404 4546
[27/Jun/2012 21:36:20] "GET /admin/js/grappelli/jquery.grp_timepicker.js 
HTTP/1.1" 404 4543
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_collapsible_group.js HTTP/1.1" 404 4564
[27/Jun/2012 21:36:20] "GET /admin/js/grappelli/jquery.grp_related_fk.js 
HTTP/1.1" 404 4543
[27/Jun/2012 21:36:20] "GET /admin/js/grappelli/jquery.grp_related_m2m.js 
HTTP/1.1" 404 4546
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_related_generic.js HTTP/1.1" 404 4558
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_autocomplete_fk.js HTTP/1.1" 404 4558
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_autocomplete_m2m.js HTTP/1.1" 404 4561
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_autocomplete_generic.js HTTP/1.1" 404 4573
[27/Jun/2012 21:36:20] "GET /admin/js/grappelli/jquery.grp_timepicker.js 
HTTP/1.1" 404 4543
[27/Jun/2012 21:36:20] "GET /admin/js/grappelli/jquery.grp_related_fk.js 
HTTP/1.1" 404 4543
[27/Jun/2012 21:36:20] "GET /admin/js/grappelli/jquery.grp_related_m2m.js 
HTTP/1.1" 404 4546
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_related_generic.js HTTP/1.1" 404 4558
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_autocomplete_fk.js HTTP/1.1" 404 4558
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_autocomplete_m2m.js HTTP/1.1" 404 4561
[27/Jun/2012 21:36:20] "GET 
/admin/js/grappelli/jquery.grp_autocomplete_generic.js HTTP/1.1" 404 4573



Would you please tell me how to fix it? 
Why 404? 
I know I am supposed to read some web links. Please tell me. 
Thank you!!

-- 
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/-/egmDj5ZbW40J.
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: Where admin classes should be registered ?

2012-06-27 Thread Shane Shane Bichel
jjcjgxydhfxydzh

On Wed, Jun 27, 2012 at 12:54 AM, Alireza Savand
wrote:

> Hi
> Common way to create [model|admin] classes is implement and create them in
> [models|admin].py file.
> But as standard non-django way is to create a python package named admin
> for AdminClass es and  create a file for each admin class.
> But i couldn't find any standard way to register those admin classes, i
> mean should i register them in admin/__init__.py or register each class in
> it own file then import them at admin/__init__.py ?
> Sometimes when i register all of them at admin/__init__.py it's happening
> that classes will initialed multiple times and i don't know the reason.
> I'm just looking for common or standard way to do it.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/_UjokPA1WgYJ.
> 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.