On Wednesday, December 2, 2015 at 6:31:31 PM UTC+10:30, john@gmail.com
wrote:
>
> +1 for disabling migrations completely - for several reasons.
>
> 1. Right now, I'm trying to run tests against a production database with
> runserver, in *read-only* mode - but it fails because it can't
Your ADMINS setting is incorrect.
In python, the value ((a,b)) is not a 1-tuple containing a 2-tuple, as you
want,
but a single 2-tuple, which django interprets as a tuple containing _just_
email
addresses.
Try:
ADMINS = (('Mark', 'x...@example.com'),)
Note the trailing comma after the
On Friday, April 12, 2013 9:52:10 AM UTC+9:30, Lachlan Musicman wrote:
>
> On 12 April 2013 08:43, Dennis Lee Bieber
> wrote:
> > On Thu, 11 Apr 2013 16:41:37 +1000, Lachlan Musicman
> >
>
> > declaimed the following in gmane.comp.python.django.user:
Following up: if it affects a single instance of an object, then it belongs
as a model method.
If it affects any number of them, then it should perhaps go on the manager
(or even the queryset: I use django-model-utils PassThroughManager for this
a lot).
Matt.
On Sunday, November 11, 2012
You may want to look into requests, which wraps http request-response
handling in a nicer wrapper.
http://pypi.python.org/pypi/requests/
Matt.
On Friday, October 19, 2012 1:15:06 PM UTC+10:30, Aaron C. de Bruyn wrote:
>
> On Thu, Oct 18, 2012 at 6:55 PM, django >wrote:
>
user.get_profile() returns a model instance, not a dict. Model instances
have no .items() method.
Matt.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
An even better solution is to always work in a virtualenv: that way you can
easily try out new packages, and not worry about conflicts.
Matt.
On Thursday, October 4, 2012 10:30:06 PM UTC+9:30, Ramiro Morales wrote:
>
> I think so. The usual reason for the problem you are experiencing is a
>
One really small nitpick: when returning a 405, it is a requirement that
you return a header with the acceptable methods:
>
>
> 10.4.6 405 Method Not Allowed
> The method specified in the Request-Line is not allowed for the resource
identified by the Request-URI. The response MUST include an
Michael,
I've been able to reproduce it: I'm not quite sure of the best way to deal
with it.
One solution is to set either null=True, or blank=True on the field, or set
a default.
The trick is, an empty string isn't valid JSON. I guess I've always been
using a default (usually of {} or [],
Hi Michael.
It should 'just work' in the admin: I'm using it fairly extensively, and
most of our access is through the admin (or a JSON api).
If we can get a minimal failing test, then I'll make sure it gets fixed.
(And thanks, Reinout, for the referral/comment)
Matt.
On Wednesday, July 11,
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
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
The admin.*Inline objects will not render nested inlines.
See https://code.djangoproject.com/ticket/9025
Matt.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
You may be able to use prefetch_related to do what you want: it will all
depend upon your model structure. select_related is easier, but only
follows an fk in one direction.
Matt.
On Sunday, May 20, 2012 12:27:57 AM UTC+9:30, Aditya Sriram M wrote:
>
> Hi,
>
> again, my models are Customer,
I'll preface this by saying I work with postgres, so some syntax stuff may
be different.
To work within a different schema, you just need to tell the database to
use that schema as part of the connection process. In postgres, this means
issuing the command:
SET search_path TO schema;
I'm
Generally, I just use syntax highlighting in my text editor: that usually
helps me find errors.
TextMate has a nice HTML (Django Template) mode.
Matt.
On Monday, April 16, 2012 2:12:14 AM UTC+9:30, Marcin wrote:
>
> Hi all,
>
> I've got a template that isn't parsing, but the error is the
>
If you install django-devserver, and enable SQL queries in the console, then
every query will be displayed as it happens, and you should be able to
track them
down.
Matt.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion
All installed ModelAdmin models:
>>> from django.contrib.admin import site
>>> site._registry.keys()
If you only got at this from `manage.py shell`, then you may need to import
your urls.py file first.
Getting those that are not registered is a bit longer:
>>> from django.db.models import
I don't use a setup.py for my _project_ deployment, but I do have a
setup.py for each of the apps that I use within a project (or at least
those that are 'reusable')
For project deployment, I use a fabfile that does the following:
* installs public keys onto the server (if necessary)
* creates
That response indicates you do not have permission to access that resource
on that server. Are you sure you are hitting the correct URL?
You may want to look into requests, it is a nicer interface for interacting
with http servers.
Matt.
--
You received this message because you are
You are mixing up views and forms. The OP was asking about forms, not views.
Personally, I'm starting to hit more and more cases where I would like the
form to be able to access the request (and associated data). For instance,
being able to limit the queryset of choices for a related field,
Not sure if it was mentioned earlier in this thread (couldn't find it), but
what some people miss is that virtualenv is not just for development. You
can, and should, deploy to a virtualenv on your server too.
Matt.
--
You received this message because you are subscribed to the Google Groups
The other option, which should work in your case:
expcodes = ['...', '...']
Result.objects.filter(analysis__experiment__experiment_code__in=expcodes)
Q objects are great, but not always needed.
Matt.
--
You received this message because you are subscribed to the Google Groups
You can use the @method_decorator decorator decorator.
https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-class-based-views
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
You can probably use a form to do most of what you want, with the caveat
that as long as your restrictions are more restrictive than any db
constraints that auth.User puts in there are.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view
The way I generally do this type of thing
is: https://gist.github.com/1591723
Lately, I've been using model validation: the clean() method instead of the
save() method, but I can't remember if this is always called.
https://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects
I have a reusable application I use for generating site-wide menu items. It
does this (as well as dynamically showing/hiding menu items based on if the
logged in user can access the view).
https://bitbucket.org/schinckel/django-menus
Actually, I think that was the one I put on pypi today,
I've been playing around with a reusable/declarative syntax for doing this,
as I seem to do it all of the time.
https://bitbucket.org/schinckel/django-filtered-form
You inherit from FilteredForm, and set either simple 'filters' or
'instance_filters' attributes on the form class:
class
I'm guessing it's got to do with testing for equality. It will be
restricted to how the field prepares data for querying the database, and
(speaking as the maintainer of JSONField) you need to be very careful with
querying on json fields, as the data is stored as a string, so changes
about how
Tip: have a teddy bear/rubber ducky/other toy that you can explain your
problem too. They (probably) won't be able to solve it, but formulating it
in a way to explain what is wrong to someone else is a great way to get
more clarity on exactly what the problem is, and then solving it yourself.
Russ mentioned it in passing, but I'll point it out for clarity: Celery is
a great framework for handling background tasks.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
If you are in an instance method of a ModelAdmin, you can use `self.model`
to get the model associated with the ModelAdmin.
Have a look in django.contrib.admin's source for what methods you can
override, or hook into.
--
You received this message because you are subscribed to the Google
That line (p = ...) is in a view, right?
It will probably want to be:
p = Publisher.objects.filter(status='p', pub_type='private_gallery',
user_gallery=request.user).order_by('-id')
Matt.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
I use virtualenv in production. It means you can install python packages using
pip without having root or sudo access on the server.
You can also isolate installs, and use no-site-packages.
I can't think of a reason not to use it.
Matt.
--
You received this message because you are subscribed
You can find it in django.forms.forms.BaseForm._clean_fields
(django/forms/forms.py line 271, the line you'll want to look at is 286).
To solve your specific problem, you'll want to do something like:
for field in self.model._meta.fields:
if hasattr(self, "process_%s" % field.name):
The advantage of using post_save or overriding save() is that it is
immediate: if you then return a representation of the parent model, it will
be up-to-date.
If you use django-celery (or similar) it may take some time to update.
Of course, the disadvantages is that your request has to wait
OS:
- Mac OS X (Lion / Snow Leopard, depending on machine).
Editor:
- Formerly TextMate, now BBEdit
Database:
- Postgres installed locally
General (python/os) tools:
- virtualenv, pip, fabric, mercurial, git (for -e installation of dev
versions on github)
Server tools:
- memcached, Werkzeug
You haven't really provided a reason why to 'do it the django way', rather
than inheriting from User.
You do make a valid point about the separate data being in a different
table: the difference would be that with using UserProfile, you need to
either do the .select_related() yourself, of have
On Friday, August 19, 2011 12:07:44 PM UTC+9:30, Andre Terra (airstrike)
wrote:
>
> Until you install some third party app that accesses
> User.objects.all() and then suddenly nothing works as it's supposed
> to.
>
> Why wouldn't it? The User subclasses will still appear in the
Lately, I have been looking at using subclasses of auth.User as a way of
segmenting users.
This appears (to me, at this stage, anyway) to have several advantages over
using the UserProfile approach.
* You can have extra attributes on the subclass. For instance, one set of
users belong to a
I had similar problems, but I put it down to doing something 'unusual'.
Try setting a pdb breakpoint in your admin class, and see if there is
anything odd. I found that I was getting failures due to save(commit=False)
meaning that an object had no primary key, and I had to do some fancy stuff
I've also created a TimeDeltaField.
It stores internally in PG as an INTERVAL, but as a string in other dbs.
http://hg.schinckel.net/django-timedelta-field
Matt.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the
That's nice.
I've figured out how to enable this and django-devserver (since they both
override 'runserver', they clash).
You can just install the middleware (dependent upon settings.DEBUG,
naturally).
Documentation patch forthcoming.
Matt.
--
You received this message because you are
On May 3, 8:23 am, Spaceman Paul wrote:
> I can't find the ticket, Matt. If you could forward me a link, or
> just
> dig that patch up for me, I'd greatly appreciate it.
http://code.djangoproject.com/ticket/9025
I haven't looked at this much since November, so it may not
I have a patch: it was a while ago, but I was about to dig it up
again.
In the meantime, there is an open ticket - I think my patch is
attached.
Matt
On Apr 20, 10:49 am, Spaceman Paul wrote:
> I'm looking at extending the django admin app for a project, as it
> does
On Apr 13, 11:12 pm, Mister Yu wrote:
> Hi Ian,
>
> Thanks for replying. The information is really useful.
>
> however, when i checked out the openid link you gave me, the project
> seems still on a testing stage, and on the website, it says: "A modern
> library for
On Apr 10, 8:30 am, Kevin Teague wrote:
> There is nothing exceptional about exceptions in Python. McDonc does a
> good job at explaining how to think about exceptions as less than
> exceptional:
>
> http://plope.com/Members/chrism/exceptions_arent_errors/view
>
> The only arguably
rmschne wrote:
> I have a query in Django with returns a queryset.
>
> c1=Contact.objects.filter(hostid__tablename=s)
>
> where "s" is a string holding a tablename.
>
> What I want to do is have Django return a query set where "s" is not
> just a string, but a Python list, e.g.
On Mar 28, 3:35 am, Rolando Espinoza La Fuente
wrote:
> On Fri, Mar 26, 2010 at 7:39 PM, Bjunix wrote:
> > django-extensions[1] brings the shell_plus command which auto-imports
> > all models in installed apps. You can use this or have a look at it's
> >
On Mar 26, 11:11 am, Continuation wrote:
> I have 2 models: A, B
>
> I need a form that inserts/updates both fields of A and fields of B.
>
> Is there any way to create a ModelForm tied to A & B? Or do I need to
> use the plain old Form?
You can use a ModelForm on one,
On Mar 23, 11:23 pm, "Vinicius Mendes | meiocodigo.com"
wrote:
> Ok. The code proposed by Tim Shaffer works and gives only one query.
> But it makes use of subselects, what is heavy for the database. Take a
> look at the generated SQL:
>
> 'SELECT `auth_user`.`id`,
On Mar 23, 6:17 am, Phlip wrote:
> > Just create another queryset that excludes everything in your first
> > queryset:
>
> > negated_queryset = User.objects.exclude(id__in=queryset.values("id"))
>
> QuerySets are already so easy to plug-n-play... Ain't there a way to
> do it
On Feb 26, 11:45 am, sixpackistan wrote:
> Anybody have any ideas on this?
> I am running django 1.1.1 using mod_python on apache 2.2.
> We have a large database of items (defined in the model as "item")
> that are searchable by serial number (which is indexed in the
>
On Feb 24, 6:59 am, Nick wrote:
> In the view set up something like
>
> all = [Books.objects.all() & Movies.objects.all()].orderby('date')
>
I thought: "super, I have been looking for this", but:
"Cannot combine queries on two different base models."
Matt.
> On Feb 23,
On Feb 16, 10:43 pm, Masklinn <maskl...@masklinn.net> wrote:
> On 16 Feb 2010, at 13:29 , Matt Schinckel wrote:
>
> > On Feb 16, 5:37 pm, Masklinn <maskl...@masklinn.net> wrote:
> >> On 16 Feb 2010, at 08:13 , harryos wrote:
>
> >>> hi
> >>&
On Feb 16, 6:00 pm, Masklinn wrote:
> On 16 Feb 2010, at 08:51 , harryos wrote:
>
> > thanks ,that worked..
>
> > any idea about calculating the duration? I can do a - between two
> > datetime.datetime objects to get a timedelta.. but that doesn't work
> > with
On Feb 16, 5:37 pm, Masklinn wrote:
> On 16 Feb 2010, at 08:13 , harryos wrote:
>
>
>
> > hi
> > I am using a TimeField and want to set the default value as current
> > time.I know the field normalizes to a datetime.time object.In a
> > DateField ,I can put
On Feb 14, 3:49 pm, john wrote:
>
> Yes, the Items model data can be accessed through another part of the
> Admin interface, but I think the purpose of the Green Plus Sign was to
> alleviate this extra step.
Try registering the model of that type with the admin. The
On Feb 14, 9:30 am, john wrote:
> Hi, I just had fun creating a new Custom Admin Form to sort a
> ManyToMany field by ABC order (why isnt it in ABC order by default on
> the "def __unicode__" item?) It works great, but now the Green Plus
> Sign to add more items to the
Oh, and it is not flawless, there were still some issues I didn't get
sorted out. I had some validation errors of some sort, I think, when
updating data under certain circumstances, but I never quite
completely tracked it down.
--
You received this message because you are subscribed to the
On Feb 14, 6:19 am, Ogi Vranesic wrote:
> Hi all
>
> I read the very good tutorial
> onhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/
> and understood that the admin interface has the ability to edit models on the
> same page as a parent model and these are called
On Jan 22, 12:00 am, Filip Gruszczyński wrote:
> I would like to go through all registered apps before server is
> started and check if certain modules (and then process them). I guess
> this mechanism is similar to the one, which looks for models or tests
> in django
On Jan 20, 9:25 pm, Olivier Guilyardi <m...@xung.org> wrote:
> On 01/20/2010 10:58 AM, Matt Schinckel wrote:
>
> > On Jan 19, 7:21 am, Olivier Guilyardi <m...@xung.org> wrote:
> >> On 01/18/2010 10:04 PM, Ramiro Morales wrote:
>
> >>> On Mo
On Jan 19, 7:21 am, Olivier Guilyardi wrote:
> On 01/18/2010 10:04 PM, Ramiro Morales wrote:
>
>
>
>
>
> > On Mon, Jan 18, 2010 at 4:40 PM, Olivier Guilyardi wrote:
> >> Hi,
>
> >> I'm trying to split tests.py into individual files into a tests/
> >> subfolder, but
On Jan 16, 8:41 am, Malcolm Box wrote:
> On Fri, Jan 15, 2010 at 6:37 PM, Jonathan Eatherly <
>
> jonathan.eathe...@gmail.com> wrote:
> > One of these days I would like to make a DMG that sets up
> > everything for the user. If anyone would be interested in a DMG single
On Jan 14, 11:07 pm, Russell Keith-Magee
wrote:
> On Thu, Jan 14, 2010 at 4:43 PM, Piotr Czachur wrote:
> > Guys,
> > I was really unhappy to see how slow fixtures are loaded before every
> > test. I'm not talking about initial_data stuff that is loaded
On Jan 14, 8:12 pm, Alexander Dutton wrote:
> On 14/01/10 09:51, nameless wrote:> I am asking whether is a good solution to
> having 2 fields with the
> > same value ( username and email ) because both are required.
> > Or is there another solution ?
>
> This depends on
On Jan 12, 4:11 am, Tomasz Zieliński
wrote:
> On 11 Sty, 16:23, Marco Rogers wrote:
>
> > I'm reposting this from earlier to see if I have better luck. I need
> > to be able to get the ModelAdmin associated with a model at runtime.
> >
On Dec 20, 2:22 pm, Todd Blanchard wrote:
> I think what i actually want is a form set, but I don't find that all that
> well done either.
>
> What I'm finding lacking is the ability to put a master/detail relationship
> in a single form. For instance, Author/Books.
You
On Dec 17, 12:03 pm, Streamweaver wrote:
> Is it possible to display calculated values for models in the admin
> interface. I know about the list_display attribute for model.Admin
> but all I really want to do is add text to a model edit form so I can
> see calculated
On Dec 17, 2:07 am, Shawn Milochik wrote:
> You can do it easily with middleware.
>
> Here's what I wrote for this exact purpose:http://pastebin.com/f52e6ef04
>
> You will have to add it to MIDDLEWARE_CLASSES in your settings.py.
I use a similar middleware for putting the
On Dec 15, 4:13 am, Continuation wrote:
> When using get_or_create(), when created=True, is there any way to
> make it so that it creates an object without saving it to DB?
>
> I want to take the newly created object, do some validation tests, and
> only save it to DB if
On Dec 4, 8:50 am, Todd Blanchard wrote:
> I'd gotten nearly a dozen responses to a later question so I figured the
> threshold of awareness had passed on this one.
Don't assume that everyone who reads is in a similar timezone as you.
My machine shows your first post in this
On Dec 4, 5:26 am, Kai Timmer wrote:
> 2009/12/3 bax...@gretschpages.com :
>
> > How, exactly? I tried this, with no luck:
>
> I can't get it working too. Can someone please provide a simple
> example? That would be really great.
I have an app called person
On Nov 20, 7:52 pm, leoz01 wrote:
> I think the easiest way is to make your own widget or otherwise you
> can make your own form field.
>
> On 19 nov, 10:19, Benjamin Wolf wrote:
>
>
>
> > Hello,
>
> > I'm using Django's form and ModelMultipleChoiceField.
>
On Nov 17, 6:57 am, Christophe Pettus wrote:
> On Nov 16, 2009, at 12:55 PM, Alessandro Ronchi wrote:
>
> > I'm using mod_passenger.
>
> Isn't that for Ruby rather than Python?
You can use mod_passenger for python, with a passenger_wsgi.py file.
(I use it on my development
On Nov 14, 1:01 am, Chris wrote:
> Thanks for your reply.
>
> From reading around it sounds as though I am probably not meant to
> solve this in the template (though this does seem like the easier
> option).
>
> I have figured out that I could solve this through an
On Nov 13, 1:40 pm, Rick Caudill wrote:
> I do have non-ascii data in my database. That is allowed, right???
Yeah, in general. What appears to be happening here (and Karen is
right, we need more to go on), but data that is being loaded into a
DecimalField contains non-ascii
On Nov 13, 7:06 am, Rick Caudill wrote:
> Hi Everyone,
>
> This is my first time posting but I have been using Django for about a
> year now and love it. I am having one problem that I can't solve
> though and it is taking too long so I thought I would ask and see if
> someone
On Nov 12, 4:18 pm, neridaj wrote:
> since FlatPage is already registered how do I properly register an
> InlineModelAdmin object?
>
You can use:
admin.site.unregister(FlatPage)
and then re-register with your FlatPageAdmin class:
admin.site.register(FlatPage,
On Nov 9, 11:45 am, Russell Keith-Magee <freakboy3...@gmail.com>
wrote:
> On Mon, Nov 9, 2009 at 9:40 AM, Matt Schinckel <matt.schinc...@gmail.com>
> wrote:
>
> > I am developing a django site that has a RESTful API, and allows for
> > json representations o
I am developing a django site that has a RESTful API, and allows for
json representations of the resources.
I have hit a bit of a hitch with respect to the data that I need to
PUT, to do with the inbuilt test client.
If I use client.post(url, data, content_type='application/json',
**AUTH), then
On Nov 6, 7:34 am, Sandra Django wrote:
> Hi friends, I have a problem. I'm trying to add to User class of Django an
> attribute. For that I'm using add_to_class method. I did the following:
>
> 1. Delete from Data Base the tables: «auth_user», «auth_user_groups» y
>
On Oct 30, 3:53 am, Alessandro Ronchi
wrote:
> I've made a Profile model (Socio) for my users and now I need to be able to
> edit the users detail in profile model in admin.
>
> THe problem is that I can add an Inline only from User to Profile, because
> User doesn't
On Oct 27, 8:56 am, TheIvIaxx wrote:
> Hello, I have a simple page model that has created and modified fields
> with auto_add and auto_now set to True. I'd like to keep track of the
> number of views per page so i added a views field to the model.
> However if i increment
On Oct 24, 5:14 am, Tim Valenta wrote:
> I've been searching for a while on how to intercept querysets in
> forms, to apply a custom filter to the choices on both foreignkey and
> m2m widgets. I'm surprised at how there are so many similar questions
> out there,
On Oct 14, 9:57 am, Christophe Pettus wrote:
> On Oct 13, 2009, at 4:46 PM, Geobase Isoscale wrote:
>
> > Do your mean that its not possible for Django to recognize
> > postgreSQL defined Check constraints when data is entered in the Form?
>
> That's correct. CHECK
On Oct 14, 12:55 am, Geobase Isoscale wrote:
> Hi All,
>
> I'm working with PostgreSQL database.
> I wonder how Django handles Check Constraints both (range and value based).
> To ensure integrity of data in the database as postresql does.
>
> How are they implemented in
On Oct 8, 6:18 pm, Marek Pietrucha wrote:
> I see that all of you guy's know what your talking about. I was
> thinking way won't you share some knowledge to this
> topic:http://groups.google.com/group/django-users/browse_thread/thread/1517...
>
What does this have to
On Oct 2, 8:58 am, Matt Schinckel <matt.schinc...@gmail.com> wrote:
> On Oct 2, 3:20 am, booty <boot...@gmail.com> wrote:> I am creating an
> application where I want the admin site to display
>
> > But I am not able to sort by these values (nor filter, nor sear
On Oct 2, 3:20 am, booty wrote:
> I am creating an application where I want the admin site to display
> the User and the UserProfile (my extensions to the User class)
> together in the list view.
>
[snip]
> My problem is that I want my User Profile fields to be displayed in
On Sep 28, 11:27 pm, Iqbal Abdullah wrote:
> Hi guys,
>
> I have a quick question:
>
> I have set auto_now=True for one of my DateTimeFields.
>
> Lets say I have a model object like so:
>
> >> a = MyModel.objects.get(id="10")
> >> print a.id
> >> "10"
> >> a.id = "10"
> >>
92 matches
Mail list logo