Re: Django models and json integration

2019-08-10 Thread Suraj Thapa FC
Can you pls elaborate or have any working code On Sat, 10 Aug, 2019, 9:40 PM Andrew C., wrote: > Two options: > > 1) Save the JSON files and link it with a FileField > > 2) Use PostgreSQL’s Django-specific JSONField. > > On Sat, Aug 10, 2019 at 9:46 AM Suraj Thapa FC > wrote: > >> How can I

Re: Django models and json integration

2019-08-10 Thread Andrew C.
Two options: 1) Save the JSON files and link it with a FileField 2) Use PostgreSQL’s Django-specific JSONField. On Sat, Aug 10, 2019 at 9:46 AM Suraj Thapa FC wrote: > How can I linked a JSON file with my db... Json files contains the key > value pair of the user data.. > If the id in the db

Re: django models

2019-05-07 Thread sachinbg sachin
On Tue, May 7, 2019, 12:35 PM Soumen Khatua Hi Folks, > > I didn't understand this code please help me to understand this code. > > class AddressQueryset(models.QuerySet): > def annotate_default(self, user): > # Set default shipping/billing address pk to None > # if default

Re: django models

2019-05-07 Thread Soumen Khatua
Yes,You are right as_data is custom made function inside the same class,here is the code: def as_data(self): """Return the address as a dict suitable for passing as kwargs.Result does not contain the primary key or an associated user.""" data =

Re: django models

2019-05-06 Thread Skyisblue
Soumen, The function looks to compare two Address objects. The as_data() call is custom made. I saw it documented in your other post. It removes the Primary Key and User from the Address object. I presume this is so they can compare the hash of one address to the hash of another. Regards, Joe

Re: django models

2018-08-14 Thread Andréas Kühne
Hi, The error is pretty self explanatory. There is a missing migration file: (u'training_kits', u'0003_auto_20160914_0722') So check your training_kits app for a migration that is called 0003_auto_20160914_0722.py. This migration is a dependency for the migration:

Re: django models

2018-08-14 Thread Ramandeep Kaur
hi guys, i need your help when i run makemigrations command, i got error: django.db.migrations.exceptions.NodeNotFoundError: Migration task_types.0004_tasktype_training_kit dependencies reference nonexistent parent node (u'training_kits', u'0003_auto_20160914_0722') On Fri, Aug 10, 2018 at 8:21

Re: django models

2018-08-10 Thread Kasper Laudrup
Hi Ramandeep, The problem is pretty much the same as before: Mismatched parentheses, but I'll leave to you to figure out where. It's pretty easy to spot. Did you find an editor that helps you syntax check python code? It'll make your life a lot easier. Kind regards, Kasper Laudrup On August

Re: django models

2018-08-10 Thread Ramandeep Kaur
thanks i got my mistake but now again i am getting an error. my urls.py: from django.conf.urls import patterns, include, url from django.contrib import admin from django.views.generic import TemplateView from rest_framework_nested import routers from rest_auth.views import LogoutView from

Re: django models

2018-08-10 Thread Kasper Laudrup
Hi Ramandeep, On 08/10/2018 07:36 AM, Ramandeep Kaur wrote: > strange thing is that it indicates the error in line 395 which is in > the end where i dont write any code. It looks like your error is not closing the call to url() here: url('^api/v1/calls/beneficiary/(?P\w+)/$', #

Re: django models

2018-08-09 Thread Mike Dewhirst
lto:django-users@googlegroups.com>>         [mailto:django-users@googlegroups.com <mailto:django-users@googlegroups.com>         <mailto:django-users@googlegroups.com <mailto:django-users@googlegroups.com>>] *On Behalf Of

Re: django models

2018-08-09 Thread Mike Dewhirst
        <mailto:django-users@googlegroups.com <mailto:django-users@googlegroups.com>>         [mailto:django-users@googlegroups.com <mailto:django-users@googlegroups.com>         <mailto:django-users@googlegroups.com

Re: django models

2018-08-09 Thread Kasper Laudrup
Hi Ramandeep, On 08/09/2018 09:57 AM, Ramandeep Kaur wrote: hi kasper,this is my settings.py What you have added to your settings.py doesn't make any sense. It is not valid Python code as your Python interpreter correctly tells you. I have no idea what you tried to achieve by writing

Re: django models

2018-08-09 Thread Ramandeep Kaur
import os import sys from django.core.exceptions import ImproperlyConfigured from .base import *pip install django-generate-secret-key def get_env_variable(var_name): try: return os.environ[var_name] except KeyError: error_msg = "Set the %s environment variable" % var_name raise

Re: django models

2018-08-09 Thread Kasper Laudrup
Hi Ramandeep, On 08/09/2018 09:25 AM, Ramandeep Kaur wrote: when i run my manage.py server its giving me invalid syntax error.   File "C:\Users\Dell\vms2\vms2\settings\base.py", line 18     from .base import *pip install django-generate-secret-key                          ^ SyntaxError: invalid

Re: django models

2018-08-09 Thread Ramandeep Kaur
ret key but its again giving me the same errror. >>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY >>> setting must not be empty. >>> >> >> Try running the migrations command with the settings option so >> manage.py can find

Re: django models

2018-08-09 Thread Mike Dewhirst
/settings/#secret-key> *From:*django-users@googlegroups.com <mailto:django-users@googlegroups.com> [mailto:django-users@googlegroups.com <mailto:django-users@googlegroups.com>] *On Behalf Of *Ramandeep Kaur *Sent:* Wednesday, August

Re: django models

2018-08-08 Thread Ramandeep Kaur
.com [mailto:django-users@ > googlegroups.com] *On Behalf Of *Ramandeep Kaur > *Sent:* Wednesday, August 8, 2018 8:50 AM > *To:* django-users@googlegroups.com > *Subject:* Re: django models > > > > I am new at Django so I don't know how to create secret key. please > exp

RE: django models

2018-08-08 Thread Matthew Pava
@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Ramandeep Kaur Sent: Wednesday, August 8, 2018 8:50 AM To: django-users@googlegroups.com Subject: Re: django models I am new at Django so I don't know how to create secret key. please explain me. On Wed, Aug 8, 2018, 1:20 PM Gerald Brown

Re: django models

2018-08-08 Thread Ramandeep Kaur
I am new at Django so I don't know how to create secret key. please explain me. On Wed, Aug 8, 2018, 1:20 PM Gerald Brown wrote: > The last line of the error message tells you what to do. Create a Secret > Key in your settings.py file because it says it is now empty. > > On Wednesday, 08

Re: django models

2018-08-08 Thread Balasriharsha Cheeday
You must have removed the secret key in settings.py file, try re-adding that secret key, then it should work just fine On Tuesday, August 7, 2018 at 10:17:00 AM UTC-7, Ramandeep Kaur wrote: > > My question is that how to delete models in django? > -- You received this message because you are

Re: django models

2018-08-08 Thread Gerald Brown
The last line of the error message tells you what to do.  Create a Secret Key in your settings.py file because it says it is now empty. On Wednesday, 08 August, 2018 02:43 PM, Ramandeep Kaur wrote: when i run this ./manage.py makemigrations it gives some error. Don't know what to do.

Re: django models

2018-08-08 Thread Ramandeep Kaur
when i run this ./manage.py makemigrations it gives some error. Don't know what to do. Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 353, in

Re: django models

2018-08-07 Thread Gerald Brown
Just delete the code in models.py and run ./manage.py makemigrations and ./manage.py migrate. On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote: My question is that how to delete models in django? -- You received this message because you are subscribed to the Google Groups "Django

Re: django models

2018-08-07 Thread Christophe Pettus
> On Aug 7, 2018, at 10:14, Ramandeep Kaur wrote: > > My question is that how to delete models in django? Do you need to delete a model *class*, or a model *instance*? -- -- Christophe Pettus x...@thebuild.com -- You received this message because you are subscribed to the Google Groups

Re: Django Models

2016-05-27 Thread Ken Edem
Wow, Derek what a great link. Thanks very much. Ken On Friday, May 27, 2016 at 4:47:56 PM UTC+2, Derek wrote: > > There a number of designs for similar situations online; a quick Google > showed me: > > * http://www.databasedev.co.uk/student_courses_data_model.html > *

Re: Django Models

2016-05-27 Thread Derek
There a number of designs for similar situations online; a quick Google showed me: * http://www.databasedev.co.uk/student_courses_data_model.html * http://databaseanswers.org/data_models/ And I am sure there are more... If this is your first project. I would not be too fussed about making it

Re: Django Models

2016-05-06 Thread Sergiy Khohlov
simplest way is using filter() against all() Take a look at https://docs.djangoproject.com/en/1.9/ref/models/querysets/ Many thanks, Serge +380 636150445 skype: skhohlov On Fri, May 6, 2016 at 5:27 PM, Omar wrote: > Gretting, I have in my DataBase (Directorios)

Re: Django models choices

2016-03-21 Thread Mike Dewhirst
On 21/03/2016 7:29 PM, Amine Yaiche wrote: Hi everyone, Given a field in a model that uses choices: | CHOICES =( Â Â (0,"choice_0"), Â Â (1,"choice_1") ) foo =models.IntegerField(choices=CHOICES) | If i put a value other than 0 or 1, django will accept it. Is that possible that we

Re: Django models choices

2016-03-21 Thread Amandeep Singh
The choices don't enforce any default validation. But if you are populating the data from a http call then use ModelForm they show the invalid_choice error message on entering value other than defined choices On Mon, Mar 21, 2016 at 1:59 PM, Amine Yaiche wrote: > Hi

Re: Django models in file sharing system

2015-12-11 Thread Vasu Dev Garg
creating a sharing manytomany field is right but how to call it in views and verify that user filled in the form exists? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an

Re: Django models in file sharing system

2015-12-10 Thread Mike Dewhirst
On 11/12/2015 5:00 AM, Vasu Dev Garg wrote: models.py : Â `class Document(models.Model): Â Â Â docfile = models.FileField(upload_to='documents/%Y/%m/%d') Â Â Â user = models.ForeignKey(User, null=False, blank= False) ` I have created a model for file upload as shown above. docfile is the

Re: Django Models Joining and Normalising

2015-10-28 Thread Collin Anderson
Hello, I'd personally keep it all in one model for as long as possible. It will really simplify queries and it should make your code a lot cleaner. Wait til you have some actual performance problems before splitting the models up. Collin On Wednesday, October 14, 2015 at 12:11:55 PM UTC-4,

Re: Django models relation about user user_group asset asset group

2015-09-17 Thread
I think you shoud use ForeignKey. 2015-09-17 23:49 GMT+08:00 周建华 : > I have design the base model like this: > > class User > some user attr > > class UserGroup > some user_group attr > > class Asset >... > > class AssetGroup >... > > > I want to authorize

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-16 Thread G Z
Thanks, I eventually solved it by using django to generate the models i believe it was because i was defining the db_column in the primary key and django said whatever, so when inspectdb built the models file it took that out and it started to work. On Wednesday, July 16, 2014 12:28:27 PM

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-16 Thread Frank Bieniek
Hi there, you are telling django, you know what you are doing via managed = False -> no batteries included, please read the details here https://docs.djangoproject.com/en/dev/ref/models/options/ There are great books out there explaining django from other perspectives than the online

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-16 Thread G Z
so I added a db trigger in oracle and it still said the same thing when ever I tried to save the new addition. Also whenever I try to go to an existing vm the manytomany field throws an exception that table or view doesn't exist but when I goto add new it doesnt and the correct field is

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread Tom Evans
On Tue, Jul 15, 2014 at 11:16 PM, G Z wrote: > Tom, > > It fails with both autofield and bigintergerfield > > class License(models.Model): >license_id = models.AutoField(primary_key = True, editable = False, > db_column='license_id') >license_authority_id =

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread G Z
http://www.oracle.com/technetwork/articles/dsl/vasiliev-django-100257.html the guide I followed from oracle. On Tuesday, July 15, 2014 4:16:54 PM UTC-6, G Z wrote: > > Tom, > > It fails with both autofield and bigintergerfield > > class License(models.Model): >license_id =

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread G Z
Tom, It fails with both autofield and bigintergerfield class License(models.Model): license_id = models.AutoField(primary_key = True, editable = False, db_column='license_id') license_authority_id = models.ForeignKey(License_authoritie, on_delete = models.PROTECT,

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread Tom Evans
On Tue, Jul 15, 2014 at 10:23 PM, G Z wrote: > So I have a database that we are using to collect vm statistics. It is > always running and writing to a django database. > I built my models file to resemble the db. However I have run into quite a > few issues. I was wondering if

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread G Z
I can update items just not add them always the same error cannot insert null for the primary key -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: django models

2014-06-04 Thread ngangsia akumbo
Thanks for this reply , am not using anybody's code. I am still studying django and was wondering where those fields where from. Thanks for the clarification. With time i will write my own field since am from Cameroon. On Tuesday, June 3, 2014 2:16:37 AM UTC+1, Andrew Farrell wrote: > > Hi Mr.

Re: django models

2014-06-02 Thread Andrew Farrell
Hi Mr. Akumbo, The options for Model Fields that come with django in the django.db library and are listed and explained here: https://docs.djangoproject.com/en/dev/ref/models/fields/#model-field-types Each corresponds to a different type of data. For example name =

Re: django models

2014-06-02 Thread ngangsia akumbo
On Sunday, June 1, 2014 7:42:13 PM UTC+1, Thomas wrote: > > > On 2014-05-31, at 4:41 AM, ngangsia akumbo > wrote: > > please i need some legit answer please > > > Please give one or two specific examples of functionality you need. There > are parameters for fields which

Re: django models

2014-06-01 Thread Tom Lockhart
On 2014-05-31, at 4:41 AM, ngangsia akumbo wrote: > please i need some legit answer please Please give one or two specific examples of functionality you need. There are parameters for fields which can help specialize some behaviours without needing a new model. And there

Re: Django Models: How to allow users to select an image from a choice of 3 pictures

2012-07-24 Thread Melvyn Sopacua
On 16-7-2012 3:26, croberts wrote: > I am familiar with the use of Field.choices for text. Then that's all you need. Let the template handle the image rendered: EMO_CHOICES = ( ('smiley_sad.png', 'sad sad emo'), ('smiley_neutral.png', 'ask me later'),

Re: Django Models: How to allow users to select an image from a choice of 3 pictures

2012-07-15 Thread Ivan Ivanov
На Sun, 15 Jul 2012 18:26:02 -0700 (PDT) croberts написа: > I am familiar with the use of Field.choices for text. > > However, I'd like the same option for images. Is this possible? I > want users to select one image from a list of 3 and be able to save > this. They

Re: Django Models Foreign Key Issue!

2012-05-29 Thread Eugène Ngontang
Hi all! The issue was not from Django side, but really from my models implementation. I made mistake when propagating my associative tables through other tables. And there was another unity constraint blocking the one i wanted to set. I don't think it's necessary to explain you all here,

Re: Django models and different types

2012-05-11 Thread Michael da Silva Pereira
Hi, Using a form did the trick, I did however have a issue with datetime formats. It appears the formats I got from the string values are not recognized. This sorted me out with that: from dateutil import parser if str(Customer._meta.get_field("pastel_"+col).get_internal_type())

Re: Django models and different types

2012-05-11 Thread Tom Evans
On Fri, May 11, 2012 at 12:39 PM, Michael da Silva Pereira wrote: > > Hi, > > Looking for some ideas around a type / conversion matching > issue I'm having with a big django model. > The model has tons of variables, and all being of different types > (int, nullbool, date,

Re: Django models

2012-01-30 Thread Stanwin Siow
ok got it. I read the document and it was good stuff. Just got confused with copying pasting into my models.py. Thanks alot once again. :) Best Regards, Stanwin Siow On Jan 30, 2012, at 10:02 PM, Michael Elkins wrote: > On Mon, Jan 30, 2012 at 09:53:18PM +0800, Stanwin Siow wrote: >> but

Re: Django models

2012-01-30 Thread Michael Elkins
On Mon, Jan 30, 2012 at 09:53:18PM +0800, Stanwin Siow wrote: but once my terminal creates the model classes do i have to copy it into my app's model.py? yes, you will need to copy the output to your models.py. you may need to edit it to put the models in order so that dependencies like

Re: Django models

2012-01-30 Thread Stanwin Siow
sorry to bother you again michael but once my terminal creates the model classes do i have to copy it into my app's model.py? I wanted to be sure. Best Regards, Stanwin Siow On Jan 30, 2012, at 9:35 PM, Michael Elkins wrote: > On Mon, Jan 30, 2012 at 09:26:10PM +0800, Stanwin Siow wrote:

Re: Django models

2012-01-30 Thread Stanwin Siow
Thank you so much. This information is very useful. It work like a charm for me. Thank you once again mike. Cheers Best Regards, Stanwin Siow On Jan 30, 2012, at 9:35 PM, Michael Elkins wrote: > On Mon, Jan 30, 2012 at 09:26:10PM +0800, Stanwin Siow wrote: >> However what does this error

Re: Django models

2012-01-30 Thread Michael Elkins
On Mon, Jan 30, 2012 at 09:26:10PM +0800, Stanwin Siow wrote: However what does this error say? ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. If you have a manage.py for your project, you can just run "manage.py inspectdb" and it

Re: Django models

2012-01-30 Thread Stanwin Siow
hi michael, Thanks for the tip. It is a huge step in my progress. However what does this error say? ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. Best Regards, Stanwin Siow On Jan 30, 2012, at 8:37 PM, Michael Elkins wrote: >

Re: Django models

2012-01-30 Thread Michael Elkins
On Mon, Jan 30, 2012 at 04:13:50AM -0800, St@n wrote: How do i ask django to query for a table that is already created in the database but not part of the models.py? the models.py is used to described the database and to create tables with that models.py. However i already have my tables

Re: Django models design question

2011-10-17 Thread omerd
Thank you very much! I choose the first option for now. If I have any problems, I will write them here On Oct 17, 2:51 pm, Stuart wrote: > Hello Omer -- > > I believe you have two options. You could use the AttributeValue > approach I described earlier. You could add

Re: Django models design question

2011-10-17 Thread Stuart
Hello Omer -- I believe you have two options. You could use the AttributeValue approach I described earlier. You could add features to take care of 'data types' and the like. The work may be quite tedious, but it has the advantage of not being clever. In other words, you would do the work to

Re: Django models design question

2011-10-16 Thread omerd
I should also mention that one AttributeValue table for all the registrations isn't good for my purpose, because it says that the Value column must have a specific type field. I want that every detail (Atrribute) will have the option to be from any field type (CharField,DateTimeField, etc). On

Re: Django models design question

2011-10-15 Thread omerd
Thank you for the response. As stuart wrote, i should give more details about the website. Currently let's suppose I have 2 interesting tables (I'm not sure that the relationship between these 2 tables is well designed): 1. Details, that contains all the possible information that should be

Re: Django models design question

2011-10-14 Thread Stuart
Hello omerd -- If you give some concrete examples of what you are trying to do, including providing your current models.py code, it will make it easier for us to help you. Since you have Registration and Details models, I am assuming you want the user to be able to create/define these items,

Re: Django models and inheritance

2011-03-12 Thread Mark J. Nenadov
> When you define an abstract model, you have to define the ``abstract'' > property inside its > Meta.http://docs.djangoproject.com/en/1.2/ref/models/options/#abstracthttp://docs.djangoproject.com/en/1.2/topics/db/models/#abstract-base-... > > That way your abstract class can inherit models.Model

Re: Django models and inheritance

2011-03-11 Thread Michal Petrucha
> If I have my abstract super classes inherit models.Model, things > technically can work. However, I arrive with a rather overly complex > SQL design generated from them (like needless tables for abstract > super classes). > > On the other hand, if I have my abstract super classes NOT inherit >

Re: django models: two foreignky for "User"

2010-11-09 Thread Marcos Moyano
Use related_name (http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name) Rgds, Marcos At Tue, 9 Nov 2010 07:20:45 -0800 (PST), luckrill wrote: > > I write following models: > > class article(models.Model): > created_by = models.ForeignKey('User')

Re: django models/ sqlalchemy

2009-08-26 Thread drakkan
You can: 1) redefine your sa models in django models.py 2) use sqlalchemy-migrate for database migration and initial data population, I never used json for initial data with migrate drakkan On 26 Ago, 17:29, ajay wrote: > HI, >     I have used sqlalchemy for database

Re: Django Models blank=False Problem

2009-02-19 Thread Karen Tracey
On Thu, Feb 19, 2009 at 7:45 AM, madhav wrote: > > I have a model something like this: > class CandidateEmailMessage(models.Model): >from_email = models.EmailField(max_length=100) >to_email = models.EmailField(max_length=100) >body = models.TextField() >

Re: Django Models + ManyToMany

2009-01-08 Thread Karen Tracey
On Thu, Jan 8, 2009 at 7:08 PM, rabbi wrote: > > Thanks Karen, > I actually deleted the thread soon after posting it as I came across > what you have written above. > Somehow you still managed to reply to a deleted thread though...? > Impressive > I don't use the Google

Re: Django Models + ManyToMany

2009-01-08 Thread rabbi
Thanks Karen, I actually deleted the thread soon after posting it as I came across what you have written above. Somehow you still managed to reply to a deleted thread though...? Impressive On Jan 9, 1:04 am, "Karen Tracey" wrote: > On Thu, Jan 8, 2009 at 12:06 PM, rabbi

Re: Django Models + ManyToMany

2009-01-08 Thread Karen Tracey
On Thu, Jan 8, 2009 at 12:06 PM, rabbi wrote: > > Hi, > I have a question that is probably very simple to answer. > > class Example(models.Model): >value = models.CharField(max_length=200) >related_examples = models.ManyToMany >

Re: Django models

2008-12-22 Thread kev
Alright thanks a lot. On Dec 22, 3:06 pm, bruno desthuilliers wrote: > On 22 déc, 17:10, kev wrote: > > > > > Hello, > > Im reading a django book and it adds friends to user authentication > > system by making: > > > (was .96) > > > class

Re: Django models

2008-12-22 Thread bruno desthuilliers
On 22 déc, 17:10, kev wrote: > Hello, > Im reading a django book and it adds friends to user authentication > system by making: > > (was .96) > > class Friendship(models.Model): > from_friend = models.ForeignKey( > User, related_name='friend_set' > ) > to_friend

Re: Django models

2008-12-22 Thread kev
I see what you are saying but there are few drawbacks: 1) 2 queries instead of one. 2) When you combine into friends_all or something, you need to keep track of which was friend vs which is user. I was thinking more on the lines of this: Each User has a UserProfile which i defined. In

Re: Django models

2008-12-22 Thread Jason Sidabras
The way I was thinking of doing it was to have two foreignkeys named friend1 and friend2 then when you do your list you could run (something like) friends = Friendship.objects.get(friend1__exact=user) and friends2 = Friendship.objects.get(friend2__exact=user) Then you have a complete instance

Re: Django models - newbie question

2008-06-07 Thread Alex Koshelev
Hmm.. def __unicode__( self ): return "%s" % self.team1 # if Teams model has its own __unicode__ method On Jun 7, 5:34 pm, nikosk <[EMAIL PROTECTED]> wrote: > Hi all > > Does anyone know how to do something like this : > > class Game(models.Model): > team1 = models.ForeignKey(Teams,

Re: Django models - newbie question

2008-06-07 Thread Sebastian Bauer
ups i think return Teams.objects.get(self.team1_id).name will be better :) Sebastian Bauer pisze: > try this: > > return Teams.objects.get(self.team1).name > > > nikosk pisze: > >> Hi all >> >> Does anyone know how to do something like this : >> >> class Game(models.Model): >> team1 =

Re: Django models - newbie question

2008-06-07 Thread Sebastian Bauer
try this: return Teams.objects.get(self.team1).name nikosk pisze: > Hi all > > Does anyone know how to do something like this : > > class Game(models.Model): > team1 = models.ForeignKey(Teams, related_name=u'team_home') > team2 = models.ForeignKey(Teams , related_name=u'team_away') >

Re: django models

2007-05-28 Thread Lic. José M. Rodriguez Bacallao
So, if I add a ForeignKey field to my model it simply add a "related_model_id" column to my table, let me ask something, how django enforce that when I add a repeated value to that field it will an error, I mean, a foreign key value that does not exist in the original table in a one to many

Re: django models

2007-05-28 Thread Marc Fargas
Hi Jos�, As the documentation says, the best alternative right now is to set a ForeignKey from one of the models to the other, on which you should place the ForeignKey really depends on every specific case, normaly it should go to the one that "cannot live with the other" (hence, the dependent

Re: Django models to SqlAlchemy models | preliminary implementation

2007-04-09 Thread limodou
On 4/10/07, Norjee <[EMAIL PROTECTED]> wrote: > > Quite often there has been talk about using SqlALchemy in Django, but > as far as I'm aware there is no implementation yet. > > For me, replacing Django's model is definitely too ambitious, so I > tried the next best thing, use Django's model

Re: Django models, detect whether value comes from db, or has explicitly been supplied.

2007-03-15 Thread Norjee
I now sort of do what you proposed. I override the init. But for the attributes that I want to keep track of I create create a property. Then it's a matter of counting how often it has been accessed. Now I just need inherit from both Model and DateTimeFieldHelper :)

Re: Django models, detect whether value comes from db, or has explicitly been supplied.

2007-03-15 Thread Norjee
I now sort of do what you proposed. I override the init. But for the attributes that I want to keep track of I create create a property. Then it's a matter of counting how often it has been accessed. Now I just need inherit from both Model and DateTimeFieldHelper :)

Re: Django models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Malcolm Tredinnick
On Thu, 2007-03-15 at 08:37 +1100, Malcolm Tredinnick wrote: > On Wed, 2007-03-14 at 20:26 +, Norjee wrote: > > Imagine the following model: > > > > class Article(models.Model): > > title = models.IntegerField() > > > > Then when you do case 1): > > art = Article.objects.get(pk=1) > >

Re: Django models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Norjee
Thanks, I was hoping I was overlooking some Django internals, but apparently not ;) I'll just stick to using two queries. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Django models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Rubic
Assuming you've got a 'mydate' attribute: mydate = models.DateField(null=True) You can conditionally assign it if null: import datetime art = Article.objects.get(pk=1) if not art.mydate: art.mydate = datetime.date.today() art.save() -- Jeff Bauer Rubicon, Inc.

Re: Django models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Malcolm Tredinnick
On Wed, 2007-03-14 at 20:26 +, Norjee wrote: > Imagine the following model: > > class Article(models.Model): > title = models.IntegerField() > > Then when you do case 1): > art = Article.objects.get(pk=1) > art.title = "New title" > art.save() > > or case 2): > art =

Re: Django Models, DRY, Scalability

2006-08-22 Thread Sean Perry
bayerj wrote: > As soon as I change my database schema, I have several possibilites to > get my app up again: > (a) Change the model. Then drop the current db schema, fire up the new > one. Drawback: I lose my data. > (b) Change the model and change the schema manually. Drawback: I am > repeating

Re: Django Models, DRY, Scalability

2006-08-21 Thread bayerj
This seems very promising to me. Although I personally would be more comfortable with sql being the root of datastructures, this would be against django's philosophy. I'm looking forward to the implementation! --~--~-~--~~~---~--~~ You received this message

Re: Re: Django Models, DRY, Scalability

2006-08-20 Thread James Bennett
On 8/20/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote: > There's a Google Summer of Code project going on at the moment to > support model evolution throughout a project's development. I haven't > played with it, but I've heard it's coming along. Actually, we've got a new tune: there's a *finished*

Re: Django Models, DRY, Scalability

2006-08-20 Thread Todd O'Bryan
On Sun, 2006-08-20 at 09:43 -0700, bayerj wrote: > As soon as I change my database schema, I have several possibilites to > get my app up again: > (a) Change the model. Then drop the current db schema, fire up the new > one. Drawback: I lose my data. > (b) Change the model and change the schema

Re: Django Models, DRY, Scalability

2006-08-20 Thread Maciej Bliziński
On Sun, 2006-08-20 at 09:43 -0700, bayerj wrote: > (b) Change the model and change the schema manually. Drawback: I am > repeating myself. Personally, I prefer this method. Yes, I am repeating myself, but I'm still saving time by not re-importing or re-entering the data. At first I didn't like

Re: Django Models, DRY, Scalability

2006-08-20 Thread Antonio Cavedoni
Hi Justin, On 20 Aug 2006, at 18:43, bayerj wrote: > As soon as I change my database schema, I have several possibilites > to get my app up again: > (a) Change the model. Then drop the current db schema, fire up the > new one. Drawback: I lose my data. > (b) Change the model and change the

Re: Django models question

2006-06-02 Thread Guillermo Fernandez Castellanos
I'm a beginner, but I would do like this: class Reservation(models.Model): properties=model.CharField(maxlength=7,primary_key=True) class Restaurant(models.Model): name=models.CharField(maxlength=30,primary_key=True) reservations=models.ForeignKey(Reservation) class