Re: Need to Replace django default I'd with UUID field

2022-11-22 Thread Jason Turner
I would just add another column that holds the UUID value instead of changing the default ID. On Tue, Nov 22, 2022, 12:55 PM Rajesh Kumar wrote: > Hi everyone! > Hope everyone is doing well... > > Actually I have 100+ existing data in my database with default I'd field > of django > Now I need t

Re: Model Design

2022-05-05 Thread 'David Turner' via Django users
We receive the data every two weeks and then use django-import-export to import the data into our database. There is no mention of the account manager in these as this is something on our side. Am I missing the point in that by having the foreign key to the account manager this would impact on t

Re: How to update old data with new data everyday from a scraper

2021-09-18 Thread Jason Turner
Take a look at update_or_create() https://docs.djangoproject.com/en/3.2/ref/models/querysets/#update-or-create On Sat, Sep 18, 2021, 9:27 AM Adib Neymar Jr. wrote: > Hello, > > What is a good way to compare new data with old data which is updated > everyday with Django ORM? Basically I have a s

Re: how to prevent Django do auto capitalize static text in templates

2021-05-18 Thread Jason Turner
Have you tried Bootstrap's class="text-lowercase"? On Tue, May 18, 2021, 8:23 AM Samuel Nogueira wrote: > I am using bootstrap, so my CSS shouldn't go wrong > > > Em ter., 18 de mai. de 2021 às 10:04, 712189512 < > gabrielstonede...@gmail.com> escreveu: > >> It’s not django that’s doing that,hav

Re: Try to make startapps but getting error

2021-04-15 Thread Jason Turner
Name the app something other than hello_world. It appears as if there is a conflict. On Thu, Apr 15, 2021, 8:23 AM Binay kumar wrote: > CommandError: 'hello_world' conflicts with the name of an existing Python > module and cannot be used as an app name. Plea se try another name. > > please help

Re: how to make docker image of your django app

2020-06-17 Thread Jason Turner
https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/ Also, Will Vincent's book "Django for Professionals" is a good resource. On Wed, Jun 17, 2020, 8:51 AM Anirudh choudhary < anirudhchoudary...@gmail.com> wrote: > I Want to make make a docker image of my Django app us

Re: EmptyDataError at /upload_reading while reading csv file using pandas

2020-05-26 Thread Jason Turner
Is the csv something you created? Or was it given to you? I use pandas extensively & the times I've received that error, the issue has been with the file itself. Ard there blank line(s) at the top of the file? On Tue, May 26, 2020, 4:11 AM jakote lejaha wrote: > The same very same file works f

Re: EmptyDataError at /upload_reading while reading csv file using pandas

2020-05-25 Thread Jason Turner
Are you sure the file is coma delimited? This error is usually because the file is not coma separated. On Mon, May 25, 2020, 5:04 PM jakote lejaha wrote: > Ideally I would have wanted to use the "csv.reader" function, but in this > case it becomes complicated as I would like to load the cvs file

Re: Dynamic Radio Form

2020-05-05 Thread Jason Turner
Thanks. That makes sense. Appreciate your help. On Tue, May 5, 2020, 11:11 AM Chetan Ganji wrote: > To answer your question, you could add an extra field on schedule model to > store the winner > e.g. winner = models.CharField(max_length=55) > > IMO, league and team in the schedule model should

Re: Import a float field using a script

2019-10-16 Thread 'David Turner' via Django users
d > > On 16/10/2019 14.22, 'David Turner' via Django users wrote: >> Thanks for pointing me in the right direction. > > No problem. Happy to help. > > Just a pedantic note on your solution: > >> I added a simple >> try: >> y =

Re: Import a float field using a script

2019-10-16 Thread 'David Turner' via Django users
gt; > On 16/10/2019 13.02, 'David Turner' via Django users wrote: >> Thanks for your response > > You're welcome. > >> I am using djjango-extensions to run the script. Everything imports fine >> except the one field. The Category, Region, County and I

Re: Import a float field using a script

2019-10-16 Thread 'David Turner' via Django users
Thanks for your response I am using djjango-extensions to run the script. Everything imports fine except the one field. The Category, Region, County and Iso’s are foreign keys to the property. The data in the csv for the area_hectares does contain in some cases no data but the format for the d

Re: What is the proper workflow before first migration?

2019-04-12 Thread 'David Turner' via Django users
If you are using django allauth and include this in your settings.py ACCOUNT_EMAIL_VERIFICATION = 'mandatory' then you will be good to go. On Apr 12 2019, at 10:03 pm, Flip Matter wrote: > Django you so much, I believe having a separate Post model would be the way > to go. Recifes to get going o

Re: Custom Model Manager

2017-05-25 Thread 'David Turner' via Django users
Apologies I was being really a bit too clever. I just need to put the deault manager first in my model and then use my custom manager in my view queryset and everything is fine. On 25 May 2017 at 18:01, David Turner wrote: > That would be fine if I was using 1.10 but this is a legacy sys

Re: Custom Model Manager

2017-05-25 Thread 'David Turner' via Django users
That would be fine if I was using 1.10 but this is a legacy system using 1.9. This will be upgraded in the foreseeable future to 1.11 Thanks On 25 May 2017 at 17:01, Melvyn Sopacua wrote: > On Thursday 25 May 2017 08:37:32 'dtdave' via Django users wrote: > > > > > My application model has fiel

Re: Link to urls containing slug

2017-02-02 Thread 'David Turner' via Django users
Hi Matthew Yes the error was in the view. Many thanks for all you help. On 2 February 2017 at 14:14, David Turner wrote: > Hi Matthew > I understand what you are saying but I think the issue rests with my view > as the link does not resolve but effectively creates the following: &g

Re: Link to urls containing slug

2017-02-02 Thread 'David Turner' via Django users
Use the job object you passed into the detail view to > obtain the job_id and slug of the job. > > Thank you, > > Matthew > > > > *From:* 'David Turner' via Django users [mailto:django-users@ > googlegroups.com] > *Sent:* Wednesday, February 1, 2017 1:44 AM >

Re: Link to urls containing slug

2017-01-31 Thread 'David Turner' via Django users
bApplication > model in order for that to work and that you passing job_application in > through the context in the template. > > If you don’t have that method, you could use the {% url %} tag, but you > would have to provide the pk and slug as arguments. > > slug=job_appl

Re: Link to urls containing slug

2017-01-31 Thread 'David Turner' via Django users
I had tried that but unfortunately it doesn't work but thanks anyway. On 31/01/2017 14:57, Matthew Pava wrote: > > Assuming I’m understanding your question correctly, all you need to do > is reference get_absolute_url in your template. > > Something like so: > > > > {{ job_application }} > >

Re: Template Data

2016-11-18 Thread 'David Turner' via Django users
Thankyou for this, although for some reason it does not work. What other infromation would you need to further advise me. Thanks On 18 November 2016 at 13:42, Vijay Khemlani wrote: > In your model a contact may have multiple phone numbers (multiple > Contactnumber instances with foreign key to t

Re: Postcode Search

2016-08-25 Thread 'David Turner' via Django users
gt; > HTH > > On 25 August 2016 at 10:25, 'David Turner' via Django users > wrote: > > Thanks for this but am looking for Uk Postcodes. Will continue my > research. > > > > On 24 August 2016 at 15:10, Derek wrote: > >> > >> The Google g

Re: Postcode Search

2016-08-25 Thread 'David Turner' via Django users
Thanks for this but am looking for Uk Postcodes. Will continue my research. On 24 August 2016 at 15:10, Derek wrote: > The Google geocoding API can help - see: > https://developers.google.com/maps/documentation/geocoding/intro > Their example shows the ZIP code being returned in the JSON/XML res

Re: Generic Foreign Key

2016-07-21 Thread 'David Turner' via Django users
21 13:15 GMT+02:00 'David Turner' via Django users > : > > Hi > > > > Thanks for this. > > So basically if I am using the county Foreign key in a few different > models > > I am fine. I am not sure what you meant by this > > "as long as no mo

Re: Generic Foreign Key

2016-07-21 Thread 'David Turner' via Django users
Hi Thanks for this. So basically if I am using the county Foreign key in a few different models I am fine. I am not sure what you meant by this "as long as no models can link to notes or counties and not both, simple foreign key are fine." On 21 July 2016 at 11:13, ludovic coues wrote: > Gener

Re: Email List

2016-07-18 Thread 'David Turner' via Django users
Hello Thanks for this. Would then the suggested route be to export my email list via an admin action and use this list via Sendmail? On 18 July 2016 at 15:11, Shem Nashon wrote: > Integrating email to django is a good but complex feature, My advice if > you want your emails in the inbox and no

Re: Best Practices URL Patterns

2016-07-07 Thread 'David Turner' via Django users
g_field to the correct > name. > > > 2016-07-06 19:46 GMT+02:00 'David Turner' via Django users > : > > As far as putting the id in the url it was a way of distinguishing the > job > > form others. As I said a number of listings will be made on the same day

Re: Best Practices URL Patterns

2016-07-07 Thread 'David Turner' via Django users
ield isn't named slug, don't forget to set slug_field to the correct >> name. >> >> >> 2016-07-06 19:46 GMT+02:00 'David Turner' via Django users >> : >> > As far as putting the id in the url it was a way of distinguishing the >> j

Re: Best Practices URL Patterns

2016-07-06 Thread 'David Turner' via Django users
As far as putting the id in the url it was a way of distinguishing the job form others. As I said a number of listings will be made on the same day with exactly the same content with regard to the title. My thoughts therefore were that if the id plus the tile were included in the url then this woul

Re: Django Filter

2016-06-17 Thread 'David Turner' via Django users
The issue is that one of the fields use choices. If I remove this everything is fine! On 17 June 2016 at 16:58, 'David Turner' via Django users < django-users@googlegroups.com> wrote: > I am using django-filter > > I have create the the filter as follows: > filter

Django Filter

2016-06-17 Thread 'David Turner' via Django users
I am using django-filter I have create the the filter as follows: filters.py import django_filters from .models import Job class JobFilter(django_filters.FilterSet): class Meta: model = Job fields = ['practice_type'] And I have created the following view: from .models import

Re: Expiration date option

2016-06-13 Thread 'David Turner' via Django users
Hi James Thanks for your answer as it has made me go back to putting business logic first which has then enabled me to come up with the right solution. Best -david On 10 June 2016 at 01:16, James Schneider wrote: > > > On Wed, Jun 8, 2016 at 9:25 AM, 'David Turner

Re: Expiration date option

2016-06-08 Thread 'David Turner' via Django users
I be better treating these as a many to many model and using them that way and how would I filter them in django admin? Best -david On 8 June 2016 at 16:04, David Turner wrote: > Many thanks for the answer especially the amount of detail in it. > > Best > > -david > > On

Re: Expiration date option

2016-06-08 Thread 'David Turner' via Django users
Many thanks for the answer especially the amount of detail in it. Best -david On 8 June 2016 at 09:26, James Schneider wrote: > > > > Many thanks for your answer which makes perfect sense and yes, this is > only required for a single view. > > The expiry_date is needed as items are listed by e

Re: Expiration date option

2016-06-07 Thread 'David Turner' via Django users
, James Schneider wrote: > > On Jun 7, 2016 1:35 PM, "'David Turner' via Django users" < > django-users@googlegroups.com> wrote: > > > > Being new to Django I have a problem which I am not able to resolve. > > > > I have a model which h

Expiration date option

2016-06-07 Thread 'David Turner' via Django users
Being new to Django I have a problem which I am not able to resolve. I have a model which has the following fields: expiry_date = models.DateField(null=True, blank=True,) has_expired = models.BooleanField(verbose_name='Has Expired', defau

Django and Plesk

2016-04-03 Thread 'David Turner' via Django users
Does anyone have any advice/recommendations for hosting a Django Site via Plesk running Centos 6.5/nginx? Our understanding is that the ideal route is Passenger? Any advicerecommendations would be greatly appreciated. -- You received this message because you are subscribed to the Google Group

Python on the web

2016-03-07 Thread Gregg Turner
Hey, Need a simple python script put into a website. It uses the requests module. $20? Any takers? -- 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 django-user

Búsquedas en una aplicacion

2015-07-05 Thread Carlos Alonso Turner Benites
Buen día, me podrían dar una idea sobre como seria la forma mas adecuada para búsquedas en una aplicación. -- 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 djang

Re: code 128 or code 39 barcode generation

2011-06-07 Thread Thomas Turner
see https://code.djangoproject.com/wiki/Barcodes On Apr 18, 7:12 pm, Steven L Smith wrote: > There's a great wrapper you can use to generate these in PIL using a > postscript library.http://pypi.python.org/pypi/elaphe/ > > I did something similar with pyqrnative to generate QR Codes for a > confe

Selecting distinct months from a QuerySet

2011-05-18 Thread Ian Turner
Hi, I would like to get a distinct list of months from a datetime field on an already defined QuerySet. SQL that I would use manually to get distinct from all records on the model. SELECT DISTINCT MONTH(`some_datetime_field`) as `month` FROM `some_model` ORDER BY `month` I don't need the year

Accessing ImageField temporary file to dynamically change upload_to storage path

2011-04-26 Thread Ian Turner
I'm in need of direction to access the temporary file that is stored in memory or on disk from an ImageField/FileField so that I can read it before it gets moved to its final location. The topics I've found all deal with only modifying the storage path based on other fields in a model. My require

Re: Parse template variables in custom tag

2011-03-22 Thread Turner
I think I've solved the issue. Rather than create a Variable object, I called parser.compile_filters(value) in the parsing function for my tag. That seems to have done the trick, and seems to internally resolve with a Variable object all the same. On Mar 21, 9:05 pm, Turner wrote: > O

Re: Parse template variables in custom tag

2011-03-21 Thread Turner
On Mar 20, 11:15 pm, Daniel Roseman wrote: > On Sunday, March 20, 2011 9:57:04 PM UTC, Turner wrote: > > > I'm working on a custom tag to which I would like to be able to pass > > template variables and filters. I found > > Variable(value).resolve(context) in th

Parse template variables in custom tag

2011-03-20 Thread Turner
I'm working on a custom tag to which I would like to be able to pass template variables and filters. I found Variable(value).resolve(context) in the Django source. I have a couple of questions: 1) Is it safe to use Variable()? That is, is it part of the public API? Not having visibility modifiers

Re: New to Django, sheet music organization site

2011-01-03 Thread Greg Turner
On 3 January 2011 23:00, Tim Sawyer wrote: > On 03/01/11 03:53, Kyle wrote: > >> When I try to access my Object, I get an error "invalid literal for >> int() with base 10". I know it has something to do with ForeignKeys, >> but cannot find how to fix it. >> > > It helps if you post the full stack

Re: Too many items in my drowndown list

2011-01-03 Thread Greg Turner
users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Dr Greg Turner Director, the Interaction Consortium http://interaction.net.au Phone: +61 2 8060 1067 skype: gregturner Follow us on twitter:

Re: render_to_response

2011-01-03 Thread Greg Turner
subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://gro

Re: SAAS User and Auth situation.

2010-02-22 Thread Wes Turner
On Feb 21, 11:09 pm, orokusaki wrote: > I'm developing an SAAS which means that I will have Accounts and those > Accounts will have Users. Each account's Users are completely > orthogonal to the Users of another Account. When a user logs in, > they'll supply an Account ID, a username, and a pass

Re: Unicode name of field in form

2010-02-10 Thread Thomas Turner
In django you would do from django.utils.safestring import mark_safe forms.CharField(label = mark_safe('Ø')) On Dec 24 2009, 9:17 am, Andrij Skalyuk wrote: > Thanks for reply. > > I see, that in this case, i will use replacement system of Unicode > characters to ASCII. > > On Dec 23, 6:09 pm,

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Andrew Turner
On Feb 2, 1:45 pm, Russell Keith-Magee wrote: > Correct. I'm guessing that the same thing is happening - the default > value is being used because the fixture doesn't specify a value. Feel > free to update the ticket so the auto_now case isn't forgotten. Done ;) Kind regards, Andrew -- You rec

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Andrew Turner
On Feb 2, 1:29 pm, Russell Keith-Magee wrote: > The cause of the problem is your initial fixture. Django doesn't > listen to auto_now_add or auto_now fields on fixture loading - fixture > objects are saved in "raw" mode, so it is assumed that the fixture > should have data for all the fields. In t

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Andrew Turner
On Feb 2, 8:07 am, Russell Keith-Magee wrote: > It is possible you've found a bug, but in order to verify that, we > need a minimal example that reproduces the problem - that is, the > simplest possible model and fixture combination that fails on the > second syncdb like you describe. Thanks for

Re: Initial data fixtures and auto_now_add=True

2010-02-01 Thread Andrew Turner
On Jan 19, 1:36 pm, Andrew Turner wrote: > I have an initial_data.json file which provides some, er, initial data > whenever I run syncdb. One of my models has a DateTimeField with > auto_now_add=True. The data is loaded first time round, but on > subsequent syncdbs, I get &qu

Initial data fixtures and auto_now_add=True

2010-01-19 Thread Andrew Turner
I have an initial_data.json file which provides some, er, initial data whenever I run syncdb. One of my models has a DateTimeField with auto_now_add=True. The data is loaded first time round, but on subsequent syncdbs, I get "IntegrityError: posts_entry.pub_date may not be NULL". Is this the expec

Re: Custom filters and partial mark_safe?

2010-01-17 Thread Andrew Turner
On 16 Jan, 23:05, "pjrhar...@gmail.com" wrote: > It's not as bad as you fear! Just escape it, then apply your filter, > then mark it all safe. Genius! This is so obvious in hindsight. Much better than all of the outrageously complicated possible solutions I have been going over in my head that pr

Re: Custom filters and partial mark_safe?

2010-01-16 Thread Andrew Turner
On 15 Jan, 12:57, Tomasz Zieliński wrote: > I'm not 100% sure, but after doing quick review of django/utils/ > safestring.py, > I would say that string is either safe or unsafe, it cannot be only > half-safe. Just as I feared. Thanks for the reply. -- You received this message because you are su

Custom filters and partial mark_safe?

2010-01-15 Thread Andrew Turner
I have a custom filter parses a CharField for usernames marked with '@', and replaces them with a hyperlink to their profile page:- def hyperlink_usernames(note): for word in note.split(): if '@' in word: try: User.objects.get(username=word.strip('@'))

Re: Using a dynamically created ImageField filename prior to save?

2009-07-06 Thread Andrew Turner
2009/7/5 Mirat Can Bayrak : > I have another question. You are naming images as hash of random number. > There is a small chance to produce same name i think. It is not good way to > give name ha? The slug field has a unique=True argument, so if the same file name does happen to be produced, it

Re: Using a dynamically created ImageField filename prior to save?

2009-07-02 Thread Andrew Turner
On Jul 2, 12:29 pm, Andrew Turner wrote: > Talking to myself again, I've changed the save method slightly:- > >     def save(self): >         if not self.slug: >             name = hashlib.sha1(str(random.random())).hexdigest()[:16] >             self._my_file

Re: Using a dynamically created ImageField filename prior to save?

2009-07-02 Thread Andrew Turner
2009/7/2 Andrew Turner : > 2009/7/2 Andrew Turner : >> Would it be possible to define the hashed filename in the save method, >> and then pass it to the upload_to argument of the ImageField? > > In answer to my own question, this seems to work:- > > def get_path(

Re: Using a dynamically created ImageField filename prior to save?

2009-07-02 Thread Andrew Turner
2009/7/2 Andrew Turner : > Would it be possible to define the hashed filename in the save method, > and then pass it to the upload_to argument of the ImageField? In answer to my own question, this seems to work:- def get_path(instance, name): return instance._my_filename class

Re: Using a dynamically created ImageField filename prior to save?

2009-07-02 Thread Andrew Turner
2009/7/1 Rajesh D : > Judging by the discussions on the above mentioned ticket, it may be a > while before this behaviour is reverted back (if it is reverted back > at all.) I'm not seeking to have the new behaviour reversed - if the powers that be say the new way is more robust, I'm happy to go

Re: Using a dynamically created ImageField filename prior to save?

2009-07-01 Thread Andrew Turner
2009/6/30 Andrew Turner : > Hi, > > This is an issue which, I believe, is related to Ticket #10788 > (http://code.djangoproject.com/ticket/10788). > > The following code snippet used to work with Django 1.0.2, but with > the latest svn version the slug is not being set to th

Using a dynamically created ImageField filename prior to save?

2009-06-30 Thread Andrew Turner
Hi, This is an issue which, I believe, is related to Ticket #10788 (http://code.djangoproject.com/ticket/10788). The following code snippet used to work with Django 1.0.2, but with the latest svn version the slug is not being set to the filename produced by get_path because, as I understand it,

Re: Username Blacklist

2009-03-17 Thread Andrew Turner
2009/3/17 Dougal Matthews : > or just have the other pages above the users in the url conf and register > the other usernames yourself so nobody else can and they wont be viewable > anyway. > Dougal Yep, that's what I was doing originally, but I like the complicated way! Cheers, Andrew --~--~--

Re: Username Blacklist

2009-03-17 Thread Andrew Turner
2009/3/17 P M : > why don't you use > ABSOLUTE_URL_OVERRIDES = { >    'auth.user': lambda o: "/user/%s/" % o.username, > } > > so username will not collide with application name !!! > Greetings. > Puneet Because I wanted the user's home page to be of the form http://mydomain.com/username !! --~-

Re: Username Blacklist

2009-03-17 Thread Andrew Turner
Just for the record, I have created the following class (subclassing RegistrationFormUniqueEmail):- class RegistrationFormNonBlacklisted(RegistrationFormUniqueEmail): def clean_username(self): if self.cleaned_data['username'] in settings.BLACKLISTED_USERNAMES: raise forms.

Re: Username Blacklist

2009-03-17 Thread Andrew Turner
2009/3/17 Alex Gaynor : > django-registration's views take a custom formclass, just subclsas the > default form and add a clean_username function to do the validation as > usuall.  If you want to get really clever about how you do it you could > import the Django resolver, test if "/%s/" % usernam

Re: Username Blacklist

2009-03-17 Thread Andrew Turner
2009/3/17 Alex Gaynor : > One way is to actively validate these, another is to just list that URL > pattern after your other ones, so that if someone goes to /admin/ it goes to > your admin, no they're profile. > > Alex Thanks for your reply. I do have the other url patterns listed before the pro

Username Blacklist

2009-03-17 Thread Andrew Turner
Hi, I have overridden my absolute urls like thus:- ABSOLUTE_URL_OVERRIDES = { 'auth.user': lambda o: "/%s/" % o.username, } so that users can access their profiles via http://mydomain.com/username However, if someone creates a user called, say, 'admin' or 'blog', it will conflict with othe

Re: ManyToMany reverse query

2009-03-12 Thread Andrew Turner
2009/3/12 Malcolm Tredinnick : > Aah... sorry. Too quick on the draw, there. :-) > > This does what you're after: > >        User.objects.filter(userprofile__friends=user) > > UserProfile.objects.filter(friends=user) is correct if you want the > respective UserProfile objects back, but it sounds l

Re: ManyToMany reverse query

2009-03-12 Thread Andrew Turner
In case this isn't very clear due to my poor explanation, say I have three users: Bob, Jane and Dave. Now, Jane calls Dave a friend Bob calls Jane a friend Bob calls Dave a friend Asking who Bob calls a friend will obviously return Jane and Dave. But if I ask who is a fan of Dave, I want to ret

Re: ManyToMany reverse query

2009-03-12 Thread Andrew Turner
2009/3/12 Malcolm Tredinnick : > The second one is close. However, since "user" is a User object, you > need to be a little more careful in the filter comparison and filter > against the UserProfile.user attribute. Thus: > >        User.objects.filter(friend__user=user) > > Regards, > Malcolm Tha

ManyToMany reverse query

2009-03-12 Thread Andrew Turner
Hi, I've got a UserProfile model:- class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) ... friends = models.ManyToManyField(User, related_name='friend', blank=True) ... I'm trying to do a query which will return all the users who call a given user a 'fri