Re: Stripping HTML tags and replacing for newlines

2018-04-18 Thread Andréas Kühne
Thanks guys - I knew I could rely on getting good suggestions even in my
sleep :-)

@James: I was thinking about going with regexp, but my regexp fu isn't to
great - would take me too much time to sort through the regexp required.
However I am thinking about doing something along those lines anyway. I
will be looking into the html2text library you pointed out as well.

Regards,

Andréas

2018-04-18 6:27 GMT+02:00 James Schneider :

>
>> Now when I send the emails I of course want to send both text content and
>> HTML. My idea from the beginning was to take my HTML content and strip the
>> HTML tags and then send that. I did this via the django utils that strip
>> tags. Now this works, HOWEVER I don't get any newlines for my  and
>>  tags.
>>
>> I was wondering if anyone has had any similar issues and has found a good
>> solution? What I want to do is strip all of the html tags and at the same
>> time replace the  and  tags.
>>
>
> Why not regex substitute all of the tags you listed with newlines before
> stripping the HTML out? I say use regex because you can do things like
> specify multiple tags and account for things like case sensitivity.
>
> I would also look at a Python HTML to plain text conversion library,
> something like this:
>
> https://github.com/aaronsw/html2text/blob/master/README.md
>
> Never needed something like this, but looks interesting.
>
> -James
>
>> --
> 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-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciVF2nFyF%2BfH74vaeYtFutsmdCxjtMf%
> 3D9JhcHNrRD5njdg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCeDnhNosCoH3TffP_pLm5ZN7f2Ndh%2BS6rOrfqOVoQer%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Error with channels and celery

2018-04-18 Thread Sergio Lopez


I'm trying to create a chat that when it meets the condition of "hola" is 
sent by a task in celery. However, when it enters the condition the status 
is not updated, can someone help me?

I leave my code, please help!

Mi error is:

raise OSError(err, 'Connect call failed %s' % (address,)) 
ConnectionRefusedError: [Errno 10061] Connect call failed ('::1', 6379)

*consumers.py*

import jsonfrom channels.generic.websocket import 
AsyncWebsocketConsumerfrom .tasks import MensajeAlGrupo
class Consumidor(AsyncWebsocketConsumer):
async def connect(self):
# Join room group
await self.channel_layer.group_add(
'grupo',
self.channel_name
)
await self.accept()

async def disconnect(self, close_code):
await self.channel_layer.group_discard(
'grupo',
self.channel_name
 )

# Receive message from WebSocket
async def receive(self, text_data):
text_data_json = json.loads(text_data)
message = text_data_json['message']
if str(message) == "hola":
MensajeAlGrupo.delay()
else:

# Send message to room group
await self.channel_layer.group_send(
'grupo',
{
'type': 'chat_message',
'message': message
}
)

# Receive message from room group
async def chat_message(self, event):
message = event['message']

# Send message to WebSocket
await self.send(text_data=json.dumps({
'message': message
}))

*Tasks.py*

#De celeryfrom Filtros.celery import appfrom channels.layers import 
get_channel_layer

@app.task()def MensajeAlGrupo():
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(
'grupo',
{"type": "chat.message", "message": "Hello World"},
)

*celery.py*

#De celeryfrom __future__ import absolute_import, unicode_literalsimport 
osfrom celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Filtros.settings')

app = Celery('Proyecto')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

app.conf.update(
BROKER_URL = 'redis://127.0.0.1:6379/0',)

Please help me, thx!

Sorry for my english :s

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e5cebcf-8bbd-442a-81cd-092c6f261fed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Adding stored procedures

2018-04-18 Thread Matthew Pava
Hi Chris,
SQL Server is not one of the databases that Django supports out of the box.  
There are third party packages available, though, but I haven’t tested any of 
them with recent versions.
Saying that, you can create views in your database backend.  In your migrations 
file, use the RunSQL operation.
https://docs.djangoproject.com/en/2.0/ref/migration-operations/#runsql

In your models file, change the Meta option, managed, to False.
https://docs.djangoproject.com/en/2.0/ref/models/options/#managed

Good luck!

As for stored procedures and functions, I haven’t worked enough with those 
mixed in with Django to give you much guidance except to do some more searching 
on the web.  And I would also advise against using them so that you can keep 
your code in your Django project.  I haven’t found a need for them myself while 
using Django.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Chris Wedgwood
Sent: Wednesday, April 18, 2018 1:50 AM
To: django-users@googlegroups.com
Subject: Adding stored procedures

Hi All

I am using SQL SERVER in my latest django project and I am going to be using 
some stored procedures.

My question is about how to go about deploying stored procedure changes with 
django. I have looked through the migrations documentation which looks very 
specific to model changes.

Has anyone had experience of having to create other things such a stored 
procedures/views/functions?

thanks
Chris




--
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACQBJYU5CDhCrP7cNRpzp7fRDr1pyf48css-EaVW%3Drj65SmEsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/58f5f935832647b0afd58ac5105b45f0%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple settings files with sites framework

2018-04-18 Thread Simon Barnett
Ah, I think you've slightly misunderstood me.

I already have staging and production sites and settings files - I don't 
use the Sites framework for that - I just use the DJANGO_SETTINGS_MODULE to 
control which settings file to use.

But now, I need to start using the Sites framework to serve mutliple (live) 
sites using the same code and database. So a.com and b.com, both displaying 
different data from the same database.

For this, I think I'll need a settings file for each site - a.py and b.py - 
which define the SITE_ID and templates dir for each one. But then, how do I 
structure all these settings files I now have?

base.py - main settings
staging.py - staging settings
production.py - production settings
a.py - settings for a.com
b.py - settings for b.com

and how do I use them for local development?

On Wednesday, 18 April 2018 04:53:56 UTC+1, Mike Dewhirst wrote:
>
> On 17/04/2018 8:51 PM, sbarnett wrote: 
> > What is the best way to structure multiple settings files when using 
> > the Sites framework? 
> > 
> > I've already got a base settings file along with a local, staging and 
> > production file which inherits from this and makes some 
> changes/additions. 
> > 
> > But now I need to use the Sites framework so I need another bunch of 
> > files that set the relevant SITE_ID, change the TEMPLATES directory etc. 
> > 
> > I'm just not sure how to lay all of this out so that the site settings 
> > files can inherit (and then potentially override) the correct settings 
> > from local, staging or production. 
>
> I ship staging.py (has SITE_ID = 2)  and production.py (has SITE_ID = 1) 
> to both machines and use wsgi.py to select the correct one. Here is mine 
> ... 
>
> import os 
> import sys 
> from socket import gethostname 
>
> from django.core.wsgi import get_wsgi_application 
>
> # hard coded paths in buildbot master.cfg 
> project = "ssds" 
> srvroot = "/var/www" 
> site_root = "%s/%s" % (srvroot, project)   # as per bot master.cfg 
>
> hname = gethostname() 
> if "pq4" in hname: 
>  site = "production" 
> elif "pq3" in hname: 
>  site = "staging" 
> else: 
>  site = "dev" 
>
> if site_root not in sys.path: 
>  sys.path.insert(0, site_root) 
>
> os.environ["DJANGO_SETTINGS_MODULE"] = "%s.settings.%s" % (project, site) 
> os.environ["PYTHON_EGG_CACHE"] = site_root 
>
> # this is the public API - returns django.core.handlers.wsgi.WSGIHandler() 
> application = get_wsgi_application() 
>
>
>
>
>
> > 
> > Any ideas? 
> > -- 
> > 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-users...@googlegroups.com  
> > . 
> > To post to this group, send email to django...@googlegroups.com 
>  
> > . 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/f72d6853-e16d-4d82-b2f5-fede38ea9f63%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/f72d6853-e16d-4d82-b2f5-fede38ea9f63%40googlegroups.com?utm_medium=email&utm_source=footer>.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/07686134-881e-4bb0-aff9-fb35b9e4f988%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[no subject]

2018-04-18 Thread Muwanguzi Derrick
Hello

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKMyrdAntaQpOS5gKPpj33bH%2BbNgZY1sq%2BYToxm974LRr_a0JA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Struggling with pulling information out of a class in models.py (Thank you in advance for any help!)

2018-04-18 Thread Derek

You will need to gve an example of your struggles (witth code being used to 
pull info, and with error traces) before we can help; all you have shown is 
model code. 

On Sunday, 15 April 2018 05:55:21 UTC+2, coreyj...@gmail.com wrote:
>
> Dear all,
>
> I am really struggling with pulling information out of a class object. I 
> have tried doing this with FK field, proxy models (shown below as I feel 
> this is the closest to working), etc. and cannot get it to work. I cannot 
> pull the information from my database. I would greatly appreciate help. 
> What I want is to have access to all of these fields independently. I feel 
> like what I have should work but I cannot get the information out of my 
> proxy models (shown below). I see what I want in the admin, however. How 
> can I get the information out independently? 
>
> class aichatbox_input2(models.Model):
> aichatbox_input2_text = models.CharField(max_length=2000) 
> def __str__(self):
> return self.aichatbox_input2_text
>
>
> class aichatbox_response2(models.Model):
> image_url2 =models.CharField(max_length=1000, default='https://www.') 
> response2_text = models.CharField(max_length=1000) 
> aichatbox_response_input2 = models.ManyToManyField(aichatbox_input2)  
> views_aichatbox = models.IntegerField(default=0)
> pw_aichatbox = models.CharField(max_length=12, default='00')
> link_aichatbox = models.CharField(max_length=250, default='None')
> nickname_aichatbox = models.CharField(max_length=100, 
> default='Pseudonym')
> email_aichatbox = models.EmailField(max_length=100, default='
> bl...@blank.com ')
>
> 
>
> def __str__(self):
>  
> return u'%s %s' % (self.response2_text, self.image_url2) 
>   
> class image_url2_class(aichatbox_response2):
> class Meta:
> proxy = True
> def __str__(self):
> return self.image_url2
>
> class response2_text_class(aichatbox_response2):
> class Meta:
> proxy = True
> def __str__(self):
> return self.response2_text
>
> class aichatbox_response_input2_class(aichatbox_response2):
> class Meta:
> proxy = True
> def __str__(self):
> return self.aichatbox_response_input2
>
> class views_aichatbox_class(aichatbox_response2): 
> class Meta:
> proxy = True
> 
> def __str__(self):
> return str(self.views_aichatbox)# is it best to have 
> this be str() here? I don't know of a better way to do this...
>
> class pw_aichatbox_class(aichatbox_response2):
> class Meta:
> proxy = True
> def __int__(self):
> return self.pw_aichatbox
>
> class link_aichatbox_class(aichatbox_response2):
> class Meta:
> proxy = True
> def __str__(self):
> return self.link_aichatbox
>
> class nickname_aichatbox_class(aichatbox_response2):
> class Meta:
> proxy = True
> def __str__(self):
> return self.nickname_aichatbox
>
> class email_aichatbox_class(aichatbox_response2):
> class Meta:
> proxy = True
> def __str__(self):
> return self.email_aichatbox
>
>

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64640e1d-9989-41e6-9fd5-c14d04bf0bdc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Struggling with deployment

2018-04-18 Thread mansi thakkar
Hello , 

I am trying to deploy my project on Heroku. I haven't created Virtual 
Environment in my app. Is it necessary to have virtual environment to 
install white noise and deploy my app to Heroku? Please respond me back as 
soon as possible. 

Thanks in advance. 

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8774428c-6d6e-4a33-af04-adb289cc30b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Struggling with deployment

2018-04-18 Thread Ketul Suthar
It's not necessary to create virtual environment on production. You must
have to install all dependencies which are on development.

On Apr 18, 2018 9:02 PM, "mansi thakkar"  wrote:

Hello ,

I am trying to deploy my project on Heroku. I haven't created Virtual
Environment in my app. Is it necessary to have virtual environment to
install white noise and deploy my app to Heroku? Please respond me back as
soon as possible.

Thanks in advance.

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8774428c-6d6e-4a33-af04-adb289cc30b2%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout.

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANuqdaVE7w3s9EzqdztvO2gHwjgi7szGKrjyUctwpUxhJ08FPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Input and output is single page using forms.py

2018-04-18 Thread sathish ponaganti
Hi All,

I'm create a one applications using django frame work, my requirement is
input and our  should be on the same page (like input test box and output
text box)


please help me how to create a forms.py and views.py

appreciate your help.

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH%3DM-vgG3YFHJ%3DgJL1tU%3DExnxrZyJeK3hs5W4oy3MH9V9tFhNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Struggling with pulling information out of a class in models.py (Thank you in advance for any help!)

2018-04-18 Thread coreyjbishop
Hi! Thanks for your response! I feel I have gone about this in a very odd 
way. I don't think that it is actually the answer but it works now. 
I am able to get the information out now without errors. What is your 
thought approaching it this way? Thank you for your time and help!
I am hoping that someone might be able to tell me a better way to do this:
 
Counter = aichatbox_response2.objects.filter().count()
for i in range(1,Counter+1):
v = views_aichatbox_class
n = nickname_aichatbox_class
#i = image_url2_class
r = response2_text_class
a = aichatbox_input2_class
p = pw_aichatbox_class
l = link_aichatbox_class
e = email_aichatbox_class
if i == 1:
v2 = str(v.objects.all()[:i])
n2 = str(n.objects.all()[:i])
#i2 = str(i.objects.all()[:i])
#r2 = str(r.objects.all()[:i])
a2 = str(a.objects.all()[:i])
#p2 = str(p.objects.all()[:i])
l2 = str(l.objects.all()[:i])
e2 = str(e.objects.all()[:i])
else:
v2 = str(v.objects.all()[i-1:i])
n2 = str(n.objects.all()[i-1:i])
a2 = str(a.objects.all()[i-1:i])

l2 = str(l.objects.all()[i-1:i])
e2 = str(e.objects.all()[i-1:i])

v2 = v2[35:len(v2)-3]
n2 = n2[38:len(n2)-3]


a2 = a2[36:len(a2)-3]

l2 = l2[34:len(l2)-3]
e2 = e2[35:len(e2)-3]

Best wishes,

Corey



On Wednesday, April 18, 2018 at 10:20:15 AM UTC-5, Derek wrote:
>
>
> You will need to gve an example of your struggles (witth code being used 
> to pull info, and with error traces) before we can help; all you have shown 
> is model code. 
>
> On Sunday, 15 April 2018 05:55:21 UTC+2, coreyj...@gmail.com wrote:
>>
>> Dear all,
>>
>> I am really struggling with pulling information out of a class object. I 
>> have tried doing this with FK field, proxy models (shown below as I feel 
>> this is the closest to working), etc. and cannot get it to work. I cannot 
>> pull the information from my database. I would greatly appreciate help. 
>> What I want is to have access to all of these fields independently. I feel 
>> like what I have should work but I cannot get the information out of my 
>> proxy models (shown below). I see what I want in the admin, however. How 
>> can I get the information out independently? 
>>
>> class aichatbox_input2(models.Model):
>> aichatbox_input2_text = models.CharField(max_length=2000) 
>> def __str__(self):
>> return self.aichatbox_input2_text
>>
>>
>> class aichatbox_response2(models.Model):
>> image_url2 =models.CharField(max_length=1000, default='https://www.
>> ') 
>> response2_text = models.CharField(max_length=1000) 
>> aichatbox_response_input2 = models.ManyToManyField(aichatbox_input2)  
>> views_aichatbox = models.IntegerField(default=0)
>> pw_aichatbox = models.CharField(max_length=12, default='00')
>> link_aichatbox = models.CharField(max_length=250, default='None')
>> nickname_aichatbox = models.CharField(max_length=100, 
>> default='Pseudonym')
>> email_aichatbox = models.EmailField(max_length=100, default='
>> bl...@blank.com')
>>
>> 
>>
>> def __str__(self):
>>  
>> return u'%s %s' % (self.response2_text, self.image_url2) 
>>   
>> class image_url2_class(aichatbox_response2):
>> class Meta:
>> proxy = True
>> def __str__(self):
>> return self.image_url2
>>
>> class response2_text_class(aichatbox_response2):
>> class Meta:
>> proxy = True
>> def __str__(self):
>> return self.response2_text
>>
>> class aichatbox_response_input2_class(aichatbox_response2):
>> class Meta:
>> proxy = True
>> def __str__(self):
>> return self.aichatbox_response_input2
>>
>> class views_aichatbox_class(aichatbox_response2): 
>> class Meta:
>> proxy = True
>> 
>> def __str__(self):
>> return str(self.views_aichatbox)# is it best to have 
>> this be str() here? I don't know of a better way to do this...
>>
>> class pw_aichatbox_class(aichatbox_response2):
>> class Meta:
>> proxy = True
>> def __int__(self):
>> return self.pw_aichatbox
>>
>> class link_aichatbox_class(aichatbox_response2):
>> class Meta:
>> proxy = True
>> def __str__(self):
>> return self.link_aichatbox
>>
>> class nickname_aichatbox_class(aichatbox_response2):
>> class Meta:
>> proxy = True
>> def __str__(self):
>> return self.nickname_aichatbox
>>
>> class email_aichatbox_class(aichatbox_response2):
>> class Meta:
>> proxy = True
>> def __str__(self):
>> return self.email_aichatbox
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving ema

Django generated migration fails with KeyError for field that was removed from the model.

2018-04-18 Thread jackotonye
A migration generated with `python manage.py makemigrations` Fails to 
execute using `python manage.py migrate`.


Model Layout:

class Offer(BaseModel):
client = models.ForeignKey(Client, on_delete=models.PROTECT, 
related_name='offers')
amount_off = models.DecimalField(max_digits=5, decimal_places=2, 
default=Decimal('0.00')).  # Removed this field from the model



Generated Migration file:

# Generated by Django 2.0.2 on 2018-04-18 21:36

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('my_app', '0031_auto_20180418_1802'),
]

operations = [
migrations.RemoveField(
model_name='offer',
name='amount_off',
),
]





Error:
Running migrations:

  Applying my_app.0032_auto_20180418_2136...Traceback (most recent call last
):

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/models/options.py"
, line 566, in get_field

return self.fields_map[field_name]

KeyError: 'amount_off'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "manage.py", line 22, in 

execute_from_command_line(sys.argv)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/core/management/__init__.py"
, line 371, in execute_from_command_line

utility.execute()

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/core/management/__init__.py"
, line 365, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/core/management/base.py"
, line 288, in run_from_argv

self.execute(*args, **cmd_options)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/core/management/base.py"
, line 335, in execute

output = self.handle(*args, **options)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/core/management/commands/migrate.py"
, line 200, in handle

fake_initial=fake_initial,

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/migrations/executor.py"
, line 117, in migrate

state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
fake_initial=fake_initial)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/migrations/executor.py"
, line 147, in _migrate_all_forwards

state = self.apply_migration(state, migration, fake=fake, fake_initial=
fake_initial)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/migrations/executor.py"
, line 244, in apply_migration

state = migration.apply(state, schema_editor)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/migrations/migration.py"
, line 122, in apply

operation.database_forwards(self.app_label, schema_editor, old_state, 
project_state)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/migrations/operations/models.py"
, line 525, in database_forwards

getattr(new_model._meta, self.option_name, set()),

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/backends/base/schema.py"
, line 342, in alter_unique_together

self._delete_composed_index(model, fields, {'unique': True}, self.
sql_delete_unique)

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/backends/base/schema.py"
, line 365, in _delete_composed_index

columns = [model._meta.get_field(field).column for field in fields]

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/backends/base/schema.py"
, line 365, in 

columns = [model._meta.get_field(field).column for field in fields]

  File 
"/Users/myuser/.virtualenvs/my_app/lib/python3.6/site-packages/django/db/models/options.py"
, line 568, in get_field

raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name
, field_name))

django.core.exceptions.FieldDoesNotExist: Offer has no field named 
'amount_off'







-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/423f74f4-3966-4f0f-ba20-a9008d240966%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple settings files with sites framework

2018-04-18 Thread Mike Dewhirst

On 18/04/2018 6:09 PM, Simon Barnett wrote:

Ah, I think you've slightly misunderstood me.

I already have staging and production sites and settings files - I 
don't use the Sites framework for that - I just use the 
DJANGO_SETTINGS_MODULE to control which settings file to use.


But now, I need to start using the Sites framework to serve mutliple 
(live) sites using the same code and database. So a.com and b.com, 
both displaying different data from the same database.


For this, I think I'll need a settings file for each site - a.py and 
b.py - which define the SITE_ID and templates dir for each one. But 
then, how do I structure all these settings files I now have?


base.py - main settings
staging.py - staging settings
production.py - production settings
a.py - settings for a.com

from production import *


b.py - settings for b.com

from production import *


and how do I use them for local development?


dev-a.py
from a import *

dev-b.py
from b import *




On Wednesday, 18 April 2018 04:53:56 UTC+1, Mike Dewhirst wrote:

On 17/04/2018 8:51 PM, sbarnett wrote:
> What is the best way to structure multiple settings files when
using
> the Sites framework?
>
> I've already got a base settings file along with a local,
staging and
> production file which inherits from this and makes some
changes/additions.
>
> But now I need to use the Sites framework so I need another
bunch of
> files that set the relevant SITE_ID, change the TEMPLATES
directory etc.
>
> I'm just not sure how to lay all of this out so that the site
settings
> files can inherit (and then potentially override) the correct
settings
> from local, staging or production.

I ship staging.py (has SITE_ID = 2)  and production.py (has
SITE_ID = 1)
to both machines and use wsgi.py to select the correct one. Here
is mine ...

import os
import sys
from socket import gethostname

from django.core.wsgi import get_wsgi_application

# hard coded paths in buildbot master.cfg
project = "ssds"
srvroot = "/var/www"
site_root = "%s/%s" % (srvroot, project)   # as per bot master.cfg

hname = gethostname()
if "pq4" in hname:
 site = "production"
elif "pq3" in hname:
 site = "staging"
else:
 site = "dev"

if site_root not in sys.path:
 sys.path.insert(0, site_root)

os.environ["DJANGO_SETTINGS_MODULE"] = "%s.settings.%s" %
(project, site)
os.environ["PYTHON_EGG_CACHE"] = site_root

# this is the public API - returns
django.core.handlers.wsgi.WSGIHandler()
application = get_wsgi_application()





>
> Any ideas?
> --
> 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-users...@googlegroups.com 
> .
> To post to this group, send email to django...@googlegroups.com

> .
> Visit this group at https://groups.google.com/group/django-users
.
> To view this discussion on the web visit
>

https://groups.google.com/d/msgid/django-users/f72d6853-e16d-4d82-b2f5-fede38ea9f63%40googlegroups.com



>

>.

> For more options, visit https://groups.google.com/d/optout
.

--
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-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/07686134-881e-4bb0-aff9-fb35b9e4f988%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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-users+unsubscr...@googlegroups.com.
To post to this group, sen

Reverse for '' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

2018-04-18 Thread tango ward
Hi,

I just need some suggestions with this error that I am getting. I searched
some related posts in Stackoverflow but most of the posts related were
problems with urls.py or name in urls. My issue is that the page loads if I
just put a plain HTML text in the page but the error occurs when I try to
use extend template tags.

Here's the my in stackoverflow:
https://stackoverflow.com/questions/49910783/django-error-reverse-for-with-arguments-and-keyword-arguments-not?noredirect=1#comment86838457_49910783

Any suggestions will be highly appreciated.


Thanks,
J

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA6wQLLD8Pvr06b9573PNWrxn8m2At6DjAFARGP1eRsfi6Lp8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple settings files with sites framework

2018-04-18 Thread m1chael
I have an apps dir, and several project dirs (one per domain/subdomain)

the settings files for  are kinda like this:

from mainproject.settings import *

then i'll just re-define what i'm overwriting.. like SITE_ID, or urls, etc..

it seems to work good for me

On Wed, Apr 18, 2018 at 8:39 PM, Mike Dewhirst 
wrote:

> On 18/04/2018 6:09 PM, Simon Barnett wrote:
>
>> Ah, I think you've slightly misunderstood me.
>>
>> I already have staging and production sites and settings files - I don't
>> use the Sites framework for that - I just use the DJANGO_SETTINGS_MODULE to
>> control which settings file to use.
>>
>> But now, I need to start using the Sites framework to serve mutliple
>> (live) sites using the same code and database. So a.com and b.com, both
>> displaying different data from the same database.
>>
>> For this, I think I'll need a settings file for each site - a.py and b.py
>> - which define the SITE_ID and templates dir for each one. But then, how do
>> I structure all these settings files I now have?
>>
>> base.py - main settings
>> staging.py - staging settings
>> production.py - production settings
>> a.py - settings for a.com
>>
> from production import *
>
> b.py - settings for b.com
>>
> from production import *
>
> and how do I use them for local development?
>>
>
> dev-a.py
> from a import *
>
> dev-b.py
> from b import *
>
>
>
>> On Wednesday, 18 April 2018 04:53:56 UTC+1, Mike Dewhirst wrote:
>>
>> On 17/04/2018 8:51 PM, sbarnett wrote:
>> > What is the best way to structure multiple settings files when
>> using
>> > the Sites framework?
>> >
>> > I've already got a base settings file along with a local,
>> staging and
>> > production file which inherits from this and makes some
>> changes/additions.
>> >
>> > But now I need to use the Sites framework so I need another
>> bunch of
>> > files that set the relevant SITE_ID, change the TEMPLATES
>> directory etc.
>> >
>> > I'm just not sure how to lay all of this out so that the site
>> settings
>> > files can inherit (and then potentially override) the correct
>> settings
>> > from local, staging or production.
>>
>> I ship staging.py (has SITE_ID = 2)  and production.py (has
>> SITE_ID = 1)
>> to both machines and use wsgi.py to select the correct one. Here
>> is mine ...
>>
>> import os
>> import sys
>> from socket import gethostname
>>
>> from django.core.wsgi import get_wsgi_application
>>
>> # hard coded paths in buildbot master.cfg
>> project = "ssds"
>> srvroot = "/var/www"
>> site_root = "%s/%s" % (srvroot, project)   # as per bot master.cfg
>>
>> hname = gethostname()
>> if "pq4" in hname:
>>  site = "production"
>> elif "pq3" in hname:
>>  site = "staging"
>> else:
>>  site = "dev"
>>
>> if site_root not in sys.path:
>>  sys.path.insert(0, site_root)
>>
>> os.environ["DJANGO_SETTINGS_MODULE"] = "%s.settings.%s" %
>> (project, site)
>> os.environ["PYTHON_EGG_CACHE"] = site_root
>>
>> # this is the public API - returns
>> django.core.handlers.wsgi.WSGIHandler()
>> application = get_wsgi_application()
>>
>>
>>
>>
>>
>> >
>> > Any ideas?
>> > --
>> > 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-users...@googlegroups.com 
>> > .
>> > To post to this group, send email to django...@googlegroups.com
>> 
>> > .
>> > Visit this group at https://groups.google.com/group/django-users
>> .
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/django-users/f72d6853-e16d
>> -4d82-b2f5-fede38ea9f63%40googlegroups.com
>> > d-4d82-b2f5-fede38ea9f63%40googlegroups.com>
>>
>> >
>> > d-4d82-b2f5-fede38ea9f63%40googlegroups.com?utm_medium=email
>> &utm_source=footer
>> > d-4d82-b2f5-fede38ea9f63%40googlegroups.com?utm_medium=email
>> &utm_source=footer>>.
>>
>> > For more options, visit https://groups.google.com/d/optout
>> .
>>
>> --
>> 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-users+unsubscr...@googlegroups.com > django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> .
>> V